Skip to main content

Module grammar

Module grammar 

Source
Expand description

Grammar parsing for magic files using nom parser combinators

This module implements the parsing logic for magic file syntax, converting text-based magic rules into the AST representation defined in ast.rs.

Functionsยง

has_continuation
Check if a line ends with a continuation character ()
is_comment_line
Check if a line is a comment (starts with #)
is_empty_line
Check if a line is empty or contains only whitespace
is_strength_directive
Check if a line is a strength directive (starts with !:strength)
parse_comment
Parse a comment line (starts with #)
parse_magic_rule
Parse a complete magic rule line from text format
parse_message
Parse the message part of a magic rule
parse_number
Parse a decimal or hexadecimal number
parse_offset
Parse an offset specification for absolute offsets
parse_operator
Parse comparison operators for magic rules
parse_rule_offset
Parse the indentation level and offset for magic rules
parse_strength_directive
Parse a strength directive (!:strength line)
parse_type
Parse a type specification (byte, short, long, quad, string, etc.)
parse_type_and_operator
Parse a type specification with an optional attached bitwise-AND mask operator (e.g., lelong&0xf0000000).
parse_value
Parse string and numeric literals for magic rule values