From 47cf86131bea474e775c4c11863d7a4ff81c9184 Mon Sep 17 00:00:00 2001 From: desbma-s1n Date: Thu, 30 May 2024 11:31:57 +0200 Subject: [PATCH] feat: improve comment handling --- src/strace/parser/peg.pest | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/strace/parser/peg.pest b/src/strace/parser/peg.pest index 0093d39..c11fbfc 100644 --- a/src/strace/parser/peg.pest +++ b/src/strace/parser/peg.pest @@ -32,15 +32,21 @@ argument = { #in = in_argument } in_argument = { expression } -in_out_argument = { expression ~ " => " ~ expression} +in_out_argument = { + ("[" ~ expression ~ " => " ~ expression ~ "]" ) | + (expression ~ " => " ~ expression) +} expression = { - #macro = macro | - #int = int | - #struct = struct | - #buf = buffer | - #set = set | - #array = array + ( + #macro = macro | + #int = int | + #struct = struct | + #buf = buffer | + #set = set | + #array = array + ) ~ + comment? } symbol_name = { (ASCII_ALPHA | ASCII_DIGIT | "_")+ } @@ -59,19 +65,13 @@ literal_int = { } or = { named_constant ~ ("|" ~ int)+ } multiplication = { literal_int ~ ("*" ~ int)+ } -named_constant = { symbol_name ~ int_metadata? } +named_constant = { symbol_name ~ metadata? } literal_int_oct = { "0" ~ ASCII_OCT_DIGIT+ } literal_int_hex = { "0x" ~ ASCII_HEX_DIGIT+ } -literal_int_dec = { - literal_int_dec_val ~ - ( - #mdata = int_metadata | - #com = comment - )? -} +literal_int_dec = { literal_int_dec_val ~ metadata? } literal_int_dec_val = { "-"? ~ ASCII_DIGIT+ } -int_metadata = { "<" ~ buffer_byte+ ~ ">" } +metadata = { "<" ~ buffer_byte+ ~ ">" } struct = { "{" ~