diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index f0f634b3ef7d2338320aca2ecfe29d3c30cae8e1..5ce65c46b90c91cf2ef44016bb29f5885473bbe0 100644 --- a/libwccl/parser/grammar.g +++ b/libwccl/parser/grammar.g @@ -2299,11 +2299,18 @@ match_fit } : ( ret = match_var_val [tagset, vars] - | "M" { ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M"))); } + | {LA(1)==LITERAL_M || LA(1)==COLON}? ("M")? { + ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M"))); + ret.reset(new Submatch(ret, 1)); + } + | "MA" { + ret.reset(new VarGetter<Match>(vars.create_accessor<Match>("_M"))); + ret.reset(new Submatch(ret, 2)); + } | LPAREN ret = match_fit [tagset, vars] RPAREN ) ( // if there's an arrow after the match, we have a submatch reference - ARROW i: UNSIGNED_INT { ret.reset(new Submatch(ret, token_ref_to_int(i))); } + COLON i: UNSIGNED_INT { ret.reset(new Submatch(ret, token_ref_to_int(i))); } )* ; @@ -2478,6 +2485,13 @@ options { : "->" ; +COLON +options { + paraphrase = ":"; +} + : ':' +; + SYMBOL options { paraphrase = "Symbol";