Crate yara_x_parser

Crate yara_x_parser 

Source
Expand description

Parses YARA source code and produces either a Concrete Syntax Tree (CST) or an Abstract Syntax Tree (AST).

A CST (also known as a lossless syntax tree) is a structured representation of the source code that retains all its details, including punctuation, spacing, comments, etc. The CST is appropriate for traversing the source code as it appears in its original form.

Typical uses of CSTs are code formatters, documentation generators, source code analysis tools, etc. One of the limitations of the CST is that it doesn’t know about operator’s associativity or precedence rules. Expressions appear in the CST as they are in the source code, without any attempt from the parser to group them according to operator precedence rules.

In the other hand, an AST is a simplified, more abstract representation of the code. The AST drops comments, spacing and syntactic details and focus on the code semantics. When building an AST, operator precedence rules are applied, providing a more accurate representation of expressions.

Deciding whether to use a CST or AST depends on the kind of problem you want to solve.

Modules§

ast
Abstract Syntax Tree (AST) for YARA rules.
cst
Concrete Syntax Tree (CST) for YARA rules.

Structs§

Parser
Produces a CST or AST given some YARA source code.
Span
Starting and ending positions of some token inside the source code.