forked from jasder/antlr
remove % from ActionSplitter.g
[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9790]
This commit is contained in:
parent
5c3c8d6e7a
commit
2d9139ca4d
|
@ -76,47 +76,13 @@ ATTR
|
||||||
: '$' x=ID {delegate.attr($text, $x);}
|
: '$' x=ID {delegate.attr($text, $x);}
|
||||||
;
|
;
|
||||||
|
|
||||||
/** %foo(a={},b={},...) ctor */
|
|
||||||
TEMPLATE_INSTANCE
|
|
||||||
: '%' ID '(' ( WS? ARG (',' WS? ARG)* WS? )? ')'
|
|
||||||
;
|
|
||||||
|
|
||||||
/** %({name-expr})(a={},...) indirect template ctor reference */
|
|
||||||
INDIRECT_TEMPLATE_INSTANCE
|
|
||||||
: '%' '(' ACTION ')' '(' ( WS? ARG (',' WS? ARG)* WS? )? ')'
|
|
||||||
;
|
|
||||||
|
|
||||||
/** %{expr}.y = z; template attribute y of StringTemplate-typed expr to z */
|
|
||||||
SET_EXPR_ATTRIBUTE
|
|
||||||
: '%' a=ACTION '.' ID WS? '=' expr=ATTR_VALUE_EXPR ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
/* %x.y = z; set template attribute y of x (always set never get attr)
|
|
||||||
* to z [languages like python without ';' must still use the
|
|
||||||
* ';' which the code generator is free to remove during code gen]
|
|
||||||
*/
|
|
||||||
SET_ATTRIBUTE
|
|
||||||
: '%' x=ID '.' y=ID WS? '=' expr=ATTR_VALUE_EXPR ';'
|
|
||||||
;
|
|
||||||
|
|
||||||
/** %{string-expr} anonymous template from string expr */
|
|
||||||
TEMPLATE_EXPR
|
|
||||||
: '%' a=ACTION
|
|
||||||
;
|
|
||||||
|
|
||||||
UNKNOWN_SYNTAX
|
|
||||||
@after {delegate.unknownSyntax(emit());}
|
|
||||||
: '%' (ID|'.'|'('|')'|','|'{'|'}'|'"')*
|
|
||||||
;
|
|
||||||
|
|
||||||
// Anything else is just random text
|
// Anything else is just random text
|
||||||
TEXT
|
TEXT
|
||||||
@init {StringBuilder buf = new StringBuilder();}
|
@init {StringBuilder buf = new StringBuilder();}
|
||||||
@after {delegate.text(buf.toString());}
|
@after {delegate.text(buf.toString());}
|
||||||
: ( c=~('\\'| '$'|'%') {buf.append((char)$c);}
|
: ( c=~('\\'| '$') {buf.append((char)$c);}
|
||||||
| '\\$' {buf.append("$");}
|
| '\\$' {buf.append("$");}
|
||||||
| '\\%' {buf.append("\%");}
|
| '\\' c=~('$') {buf.append("\\"+(char)$c);}
|
||||||
| '\\' c=~('$'|'%') {buf.append("\\"+(char)$c);}
|
|
||||||
)+
|
)+
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue