diff --git a/src/strace/parser/peg.pest b/src/strace/parser/peg.pest index c99c47d..1ef6113 100644 --- a/src/strace/parser/peg.pest +++ b/src/strace/parser/peg.pest @@ -12,13 +12,13 @@ name = { (ASCII_ALPHA_LOWER | ASCII_DIGIT | "_")+ } arguments = { "(" ~ (expression ~ (", " ~ expression)*)? ~ ")" } -ret_val = { expression_int ~ (" " ~ ANY*)? } +ret_val = { int ~ (" " ~ ANY*)? } // Subrules expression = { - #expr_int = expression_int | + #int = int | #struct = struct | #buf = buffer | #macro = macro | @@ -26,18 +26,18 @@ expression = { #array = array } -expression_int = { - #or = expression_int_or | - #lit = expression_int_literal | - #named = expression_named_constant +int = { + #or = or | + #lit = literal_int | + #named = named_constant } -expression_int_literal = { #hex = literal_int_hex | #int = literal_int } -expression_int_or = { expression_named_constant ~ ("|" ~ expression_int)+ } -expression_named_constant = { (ASCII_ALPHA_UPPER | ASCII_DIGIT | "_")+ } +literal_int = { #hex = literal_int_hex | #dec = literal_int_dec } +or = { named_constant ~ ("|" ~ int)+ } +named_constant = { (ASCII_ALPHA_UPPER | ASCII_DIGIT | "_")+ } literal_int_hex = { "0x" ~ ASCII_HEX_DIGIT+ } -literal_int = { int_val ~ int_metadata? } -int_val = { "-"? ~ ASCII_DIGIT+ } +literal_int_dec = { literal_int_dec_val ~ int_metadata? } +literal_int_dec_val = { "-"? ~ ASCII_DIGIT+ } int_metadata = { "<" ~ buffer_byte+ ~ ">" } struct = { "{" ~ (struct_member ~ (", " ~ struct_member)*)? ~ "}" } @@ -64,10 +64,10 @@ set = { "~"? ~ "[" ~ ( - expression_int ~ + int ~ ( " " ~ - expression_int + int )* )? ~ "]" diff --git a/src/strace/parser/peg.rs b/src/strace/parser/peg.rs index fbfb1a4..d1d0d56 100644 --- a/src/strace/parser/peg.rs +++ b/src/strace/parser/peg.rs @@ -40,7 +40,7 @@ fn pair_descend(pair: Pair<'_, Rule>, levels: usize) -> Option> { impl From> for Expression { fn from(pair: Pair) -> Self { match pair.as_node_tag() { - Some("expr_int") => Expression::Integer(pair_descend(pair, 1).unwrap().into()), + Some("int") => Expression::Integer(pair_descend(pair, 1).unwrap().into()), Some("buf") => Expression::Buffer(pair.into()), Some("struct") => Expression::Struct( pair.into_inner() @@ -122,7 +122,7 @@ impl From> for IntegerExpression { .unwrap(), None, ), - Some("int") => { + Some("dec") => { let mut children = pair.into_inner(); let val_pair = children.next().unwrap(); let metadata_pair = children.next();