Skip to content
Snippets Groups Projects
Commit 30f1eae8 authored by Adam Wardynski's avatar Adam Wardynski
Browse files

Changing submatching syntax from "->" to ":" and M, MA to be shorthand for...

Changing submatching syntax from "->" to ":"  and M, MA to be shorthand for ($m:_M):1 and ($m:_M):2, respectively.
Also, "M" is optional if followed by ":", "M:1" is same as ":1"
parent 9716df81
Branches
No related merge requests found
......@@ -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";
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment