Skip to content

Commit

Permalink
Merge pull request #5 from TommYDeeee/full_language_support
Browse files Browse the repository at this point in the history
Full ruleset support
  • Loading branch information
TommYDeeee authored Apr 17, 2024
2 parents 85f79fd + 31e1cc7 commit f501ca0
Show file tree
Hide file tree
Showing 112 changed files with 6,810 additions and 467 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name = "yara-parser"
version = "0.1.0"
edition = "2021"

[lib]
name = "yara_parser"
path = "src/lib.rs"

[[bin]]
name = "yara-parser"
path = "src/bin.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
Expand Down
12 changes: 8 additions & 4 deletions example.yar
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import "macho"
include "test"
//Global comment

//Rule comment
rule test
rule test : bla test
{
//Rule block comment

meta:
author = "Author"
description = 20
//String comment
strings:
$a = "foo"
$b = "bar"
$b = "bar" ascii
condition:
$b and not true or false
$b and not true or true
}
11 changes: 11 additions & 0 deletions src/bin.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use std::fs;
use yara_parser::{AstNode, SourceFile};

fn main() {
let filename = std::env::args().nth(1).expect("No arguments provided");
let file_content =
fs::read_to_string(filename).expect("Something went wrong while reading the file");
let ast = SourceFile::parse(&file_content);
println!("AST:\n\n{:#?}", ast.tree().syntax());
println!("Errors: {:?}", ast.errors());
}
Loading

0 comments on commit f501ca0

Please sign in to comment.