Some changes in the C++ target doc + a some template fixes.

- Avoiding double semicolons is tricky with the kind of rule nesting. Previous changes for that caused the tests to break as there were semicolons missing then.
- VS complained about the shift code generated using 1L as base, which is signed. Changed that to 1ULL, which is what is actually intended.
- Reverted the change to avoid a warning in RuleSempredFunction() in Cpp.stg as the fix didn't work 100%. We need a different solution.
This commit is contained in:
Mike Lischke 2016-06-05 14:35:11 +02:00
parent d6339f5cf4
commit 73248ac2e3
11 changed files with 104 additions and 100 deletions

View File

@ -24,7 +24,7 @@ Once you've generated the lexer and/or parser code, you need to download or buil
* http://www.antlr.org
Use CMake to build a Linux library (works also on OSX, if you don't have XCode, as we use pure C++ code). Building your own library on OSX or Windows is trivial, however. Just open the VS or XCode project, select target + arch and build it. Should work out of the box without any additional dependency.
Use CMake to build a Linux library (works also on OSX, however not for the iOS library). Building your own library on OSX or Windows is trivial, however. Just open the VS or XCode project, select target + arch and build it. Should work out of the box without any additional dependency.
## How do I run the generated lexer and/or parser?
@ -33,7 +33,7 @@ Putting it all together to get a working parser is really easy. Look in the [run
## How do I create and run a custom listener?
The generation step above created a listener and base listener class for you. The listener class is an abstract interface, which declares enter and exit methods for each of your parser rules. The base listener is implements all those abstract methods with an empty body, so you don't have to do it yourself if you just want to implement a single function. Hence use this base listener as the base class for your custom listener:
The generation step above created a listener and base listener class for you. The listener class is an abstract interface, which declares enter and exit methods for each of your parser rules. The base listener implements all those abstract methods with an empty body, so you don't have to do it yourself if you just want to implement a single function. Hence use this base listener as the base class for your custom listener:
```c++
#include <iostream>
@ -74,15 +74,17 @@ This example assumes your grammar contains a parser rule named `key` for which t
### Specialities of this ANTLR target
There are a couple of things that only the C++ ANTLR target has to deal with. They are described here.
### Memory Management
Caused by the nature of C++ there are a couple of things that only the C++ ANTLR target has. Since C++ has no built-in memory management we need to take extra care for that. For that we rely mostly on smart pointers, which however might cause time penalties or memory side effects (like cyclic references) if not used with care. Currently however the memory household looks very stable.
Since C++ has no built-in memory management we need to take extra care for that. For that we rely mostly on smart pointers, which however might cause time penalties or memory side effects (like cyclic references) if not used with care. Currently however the memory household looks very stable.
### Unicode Support
Encoding is mostly an input issue, i.e. when the lexer converts text input into lexer tokens. The parser is completely encoding unaware. However, lexer input in in the grammar is defined by character ranges with either a single member (e.g. 'a' or [a]), an explicit range (e.g. 'a'..'z' or [a-z]), the full Unicode range (for a wildcard) and the full Unicode range minus a sub range (for negated ranges, e.g. ~[a]). The explicit ranges are encoded in the serialized ATN by 16bit numbers, hence cannot reach beyond 0xFFFF (the Unicode BMP), while the implicit ranges can include any value (and hence support the full Unicode set, up to 0x10FFFF).
> An interesting side note here is that the Java target fully supports Unicode as well, despite the inherent limitations from the serialized ATN. That's possible because the Java String class represents characters beyond the BMP as surrogate pairs (two 16bit values) and even reads them as 2 characters. To make this work a character range for an identifier in a grammar must include the surrogate pairs area (for a Java parser).
The C++ target however always expects UTF-8 input (either in a string or via a wide stream) which is then converted to a char32_t array and fed to the lexer. ANTLR, when parsing your grammar, limits character ranges explicitly to the BMP currently. So, in order to allow specifying the full Unicode set the C++ target uses a little trick: whenever an explicit character range includes the (unused) codepoint 0xFFFF in a grammar it is silently extended to the full Unicode range. It's clear that this is an all-or-nothing solution. You cannot define a subset of Unicode codepoints > 0xFFFF that way. This can only be solved if ANTLR supports larger character intervals.
The C++ target however always expects UTF-8 input (either in a string or via a wide stream) which is then converted to UTF-32 (a char32_t array) and fed to the lexer. ANTLR, when parsing your grammar, limits character ranges explicitly to the BMP currently. So, in order to allow specifying the full Unicode set the C++ target uses a little trick: whenever an explicit character range includes the (unused) codepoint 0xFFFF in a grammar it is silently extended to the full Unicode range. It's clear that this is an all-or-nothing solution. You cannot define a subset of Unicode codepoints > 0xFFFF that way. This can only be solved if ANTLR supports larger character intervals.
The differences in handling characters beyond the BMP leads to a difference between Java and C++ parsers: the character offsets may not concur. This is because Java reads two 16bit values per Unicode char (if that falls into the surrogate area) while a C++ parser only reads one 32bit value. That usually doesn't have practical consequences, but might confuse people when comparing token positions.

View File

@ -172,7 +172,7 @@ Concat(a,b) ::= "<a><b>"
DeclareLocal(s,v) ::= "<s> = <v>"
AssertIsList(v) ::= "assert(<v>.size() >= 0);" // Use a method that exists only on a list (vector actually).
AssignLocal(s,v) ::= "<s> = <v>"
AssignLocal(s,v) ::= "<s> = <v>;"
InitIntMember(n,v) ::= "int <n> = <v>;"
InitBooleanMember(n,v) ::= "bool <n> = <v>;"

View File

@ -25,5 +25,5 @@ e : a=e op=('*'|'/') b=e {}{<True()>}?
| '(' x=e ')' {}{}
;
INT : '0'..'9'+ ;
WS : (' '|'\n') -> skip ;
WS : (' '|'\n') -> skip;
>>

View File

@ -33,5 +33,5 @@ ID : 'a'..'z'+ ;
INT : '0'..'9'+ ;
INC : '++' ;
DEC : '--' ;
WS : (' '|'\n') -> skip ;
WS : (' '|'\n') -> skip;
>>

View File

@ -1755,7 +1755,7 @@ public class TestLeftRecursion extends BaseCppTest {
public void testMultipleActionsPredicatesOptions_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(254);
StringBuilder grammarBuilder = new StringBuilder(253);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {std::cout << $ctx->toStringTree(this) << std::endl;} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1764,7 +1764,7 @@ public class TestLeftRecursion extends BaseCppTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1781,7 +1781,7 @@ public class TestLeftRecursion extends BaseCppTest {
public void testMultipleActionsPredicatesOptions_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(254);
StringBuilder grammarBuilder = new StringBuilder(253);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {std::cout << $ctx->toStringTree(this) << std::endl;} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1790,7 +1790,7 @@ public class TestLeftRecursion extends BaseCppTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1807,7 +1807,7 @@ public class TestLeftRecursion extends BaseCppTest {
public void testMultipleActionsPredicatesOptions_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(254);
StringBuilder grammarBuilder = new StringBuilder(253);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {std::cout << $ctx->toStringTree(this) << std::endl;} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1816,7 +1816,7 @@ public class TestLeftRecursion extends BaseCppTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1918,13 +1918,13 @@ public class TestLeftRecursion extends BaseCppTest {
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
grammarBuilder.append(" | left=e DEC {$v = $left.v - 1;} # unary\n");
grammarBuilder.append(" | ID {$v = 3} # anID\n");
grammarBuilder.append(" | ID {$v = 3;} # anID\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1951,13 +1951,13 @@ public class TestLeftRecursion extends BaseCppTest {
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
grammarBuilder.append(" | left=e DEC {$v = $left.v - 1;} # unary\n");
grammarBuilder.append(" | ID {$v = 3} # anID\n");
grammarBuilder.append(" | ID {$v = 3;} # anID\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1984,13 +1984,13 @@ public class TestLeftRecursion extends BaseCppTest {
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
grammarBuilder.append(" | left=e DEC {$v = $left.v - 1;} # unary\n");
grammarBuilder.append(" | ID {$v = 3} # anID\n");
grammarBuilder.append(" | ID {$v = 3;} # anID\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -2017,13 +2017,13 @@ public class TestLeftRecursion extends BaseCppTest {
grammarBuilder.append(" | '(' e ')' {$v = $e.v;} # parens\n");
grammarBuilder.append(" | left=e INC {$v = $left.v + 1;} # unary\n");
grammarBuilder.append(" | left=e DEC {$v = $left.v - 1;} # unary\n");
grammarBuilder.append(" | ID {$v = 3} # anID\n");
grammarBuilder.append(" | ID {$v = 3;} # anID\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("ID : 'a'..'z'+ ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();

View File

@ -1553,7 +1553,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleActionsPredicatesOptions_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(246);
StringBuilder grammarBuilder = new StringBuilder(245);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {Console.WriteLine($ctx.ToStringTree(this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1562,7 +1562,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="4";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
@ -1574,7 +1574,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleActionsPredicatesOptions_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(246);
StringBuilder grammarBuilder = new StringBuilder(245);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {Console.WriteLine($ctx.ToStringTree(this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1583,7 +1583,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="1*2/3";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
@ -1595,7 +1595,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleActionsPredicatesOptions_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(246);
StringBuilder grammarBuilder = new StringBuilder(245);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {Console.WriteLine($ctx.ToStringTree(this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1604,7 +1604,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="(1/2)*3";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
@ -1676,7 +1676,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(741);
StringBuilder grammarBuilder = new StringBuilder(740);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1692,7 +1692,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="4";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
@ -1704,7 +1704,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(741);
StringBuilder grammarBuilder = new StringBuilder(740);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1720,7 +1720,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="1+2";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
@ -1732,7 +1732,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(741);
StringBuilder grammarBuilder = new StringBuilder(740);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1748,7 +1748,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="1+2*3";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);
@ -1760,7 +1760,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(741);
StringBuilder grammarBuilder = new StringBuilder(740);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {Console.WriteLine($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1776,7 +1776,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="i++*3";
String found = execParser("T.g4", grammar, "TParser", "TLexer", "s", input, false);

View File

@ -1715,7 +1715,7 @@ public class TestLeftRecursion extends BaseTest {
public void testMultipleActionsPredicatesOptions_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(247);
StringBuilder grammarBuilder = new StringBuilder(246);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {System.out.println($ctx.toStringTree(this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1724,7 +1724,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1740,7 +1740,7 @@ public class TestLeftRecursion extends BaseTest {
public void testMultipleActionsPredicatesOptions_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(247);
StringBuilder grammarBuilder = new StringBuilder(246);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {System.out.println($ctx.toStringTree(this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1749,7 +1749,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1765,7 +1765,7 @@ public class TestLeftRecursion extends BaseTest {
public void testMultipleActionsPredicatesOptions_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(247);
StringBuilder grammarBuilder = new StringBuilder(246);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {System.out.println($ctx.toStringTree(this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1774,7 +1774,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1862,7 +1862,7 @@ public class TestLeftRecursion extends BaseTest {
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(730);
StringBuilder grammarBuilder = new StringBuilder(729);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1878,7 +1878,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1894,7 +1894,7 @@ public class TestLeftRecursion extends BaseTest {
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(730);
StringBuilder grammarBuilder = new StringBuilder(729);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1910,7 +1910,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1926,7 +1926,7 @@ public class TestLeftRecursion extends BaseTest {
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(730);
StringBuilder grammarBuilder = new StringBuilder(729);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1942,7 +1942,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1958,7 +1958,7 @@ public class TestLeftRecursion extends BaseTest {
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(730);
StringBuilder grammarBuilder = new StringBuilder(729);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {System.out.println($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1974,7 +1974,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();

View File

@ -1635,7 +1635,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleActionsPredicatesOptions_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(246);
StringBuilder grammarBuilder = new StringBuilder(245);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {console.log($ctx.toStringTree(null, this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1644,7 +1644,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="4";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -1658,7 +1658,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleActionsPredicatesOptions_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(246);
StringBuilder grammarBuilder = new StringBuilder(245);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {console.log($ctx.toStringTree(null, this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1667,7 +1667,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="1*2/3";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -1681,7 +1681,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleActionsPredicatesOptions_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(246);
StringBuilder grammarBuilder = new StringBuilder(245);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {console.log($ctx.toStringTree(null, this));} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{true}?\n");
@ -1690,7 +1690,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="(1/2)*3";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -1770,7 +1770,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(639);
StringBuilder grammarBuilder = new StringBuilder(638);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {console.log($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1786,7 +1786,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="4";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -1800,7 +1800,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(639);
StringBuilder grammarBuilder = new StringBuilder(638);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {console.log($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1816,7 +1816,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="1+2";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -1830,7 +1830,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(639);
StringBuilder grammarBuilder = new StringBuilder(638);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {console.log($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1846,7 +1846,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="1+2*3";
String found = execParser("T.g4", grammar, "TParser", "TLexer",
@ -1860,7 +1860,7 @@ public class TestLeftRecursion extends BaseTest {
@Test
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(639);
StringBuilder grammarBuilder = new StringBuilder(638);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {console.log($e.v);};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1876,7 +1876,7 @@ public class TestLeftRecursion extends BaseTest {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
String input ="i++*3";
String found = execParser("T.g4", grammar, "TParser", "TLexer",

View File

@ -1755,7 +1755,7 @@ public class TestLeftRecursion extends BasePython2Test {
public void testMultipleActionsPredicatesOptions_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(239);
StringBuilder grammarBuilder = new StringBuilder(238);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
@ -1764,7 +1764,7 @@ public class TestLeftRecursion extends BasePython2Test {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1781,7 +1781,7 @@ public class TestLeftRecursion extends BasePython2Test {
public void testMultipleActionsPredicatesOptions_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(239);
StringBuilder grammarBuilder = new StringBuilder(238);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
@ -1790,7 +1790,7 @@ public class TestLeftRecursion extends BasePython2Test {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1807,7 +1807,7 @@ public class TestLeftRecursion extends BasePython2Test {
public void testMultipleActionsPredicatesOptions_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(239);
StringBuilder grammarBuilder = new StringBuilder(238);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
@ -1816,7 +1816,7 @@ public class TestLeftRecursion extends BasePython2Test {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1908,7 +1908,7 @@ public class TestLeftRecursion extends BasePython2Test {
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1924,7 +1924,7 @@ public class TestLeftRecursion extends BasePython2Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1941,7 +1941,7 @@ public class TestLeftRecursion extends BasePython2Test {
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1957,7 +1957,7 @@ public class TestLeftRecursion extends BasePython2Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1974,7 +1974,7 @@ public class TestLeftRecursion extends BasePython2Test {
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1990,7 +1990,7 @@ public class TestLeftRecursion extends BasePython2Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -2007,7 +2007,7 @@ public class TestLeftRecursion extends BasePython2Test {
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -2023,7 +2023,7 @@ public class TestLeftRecursion extends BasePython2Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();

View File

@ -1755,7 +1755,7 @@ public class TestLeftRecursion extends BasePython3Test {
public void testMultipleActionsPredicatesOptions_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(239);
StringBuilder grammarBuilder = new StringBuilder(238);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
@ -1764,7 +1764,7 @@ public class TestLeftRecursion extends BasePython3Test {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1781,7 +1781,7 @@ public class TestLeftRecursion extends BasePython3Test {
public void testMultipleActionsPredicatesOptions_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(239);
StringBuilder grammarBuilder = new StringBuilder(238);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
@ -1790,7 +1790,7 @@ public class TestLeftRecursion extends BasePython3Test {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1807,7 +1807,7 @@ public class TestLeftRecursion extends BasePython3Test {
public void testMultipleActionsPredicatesOptions_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(239);
StringBuilder grammarBuilder = new StringBuilder(238);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s @after {print($ctx.toStringTree(recog=self))} : e ;\n");
grammarBuilder.append("e : a=e op=('*'|'/') b=e {}{True}?\n");
@ -1816,7 +1816,7 @@ public class TestLeftRecursion extends BasePython3Test {
grammarBuilder.append(" | '(' x=e ')' {}{}\n");
grammarBuilder.append(" ;\n");
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1908,7 +1908,7 @@ public class TestLeftRecursion extends BasePython3Test {
public void testMultipleAlternativesWithCommonLabel_1() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1924,7 +1924,7 @@ public class TestLeftRecursion extends BasePython3Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1941,7 +1941,7 @@ public class TestLeftRecursion extends BasePython3Test {
public void testMultipleAlternativesWithCommonLabel_2() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1957,7 +1957,7 @@ public class TestLeftRecursion extends BasePython3Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -1974,7 +1974,7 @@ public class TestLeftRecursion extends BasePython3Test {
public void testMultipleAlternativesWithCommonLabel_3() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -1990,7 +1990,7 @@ public class TestLeftRecursion extends BasePython3Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();
@ -2007,7 +2007,7 @@ public class TestLeftRecursion extends BasePython3Test {
public void testMultipleAlternativesWithCommonLabel_4() throws Exception {
mkdir(tmpdir);
StringBuilder grammarBuilder = new StringBuilder(561);
StringBuilder grammarBuilder = new StringBuilder(560);
grammarBuilder.append("grammar T;\n");
grammarBuilder.append("s : e {print($e.v)};\n");
grammarBuilder.append("e returns [int v]\n");
@ -2023,7 +2023,7 @@ public class TestLeftRecursion extends BasePython3Test {
grammarBuilder.append("INT : '0'..'9'+ ;\n");
grammarBuilder.append("INC : '++' ;\n");
grammarBuilder.append("DEC : '--' ;\n");
grammarBuilder.append("WS : (' '|'\\n') -> skip ;");
grammarBuilder.append("WS : (' '|'\\n') -> skip;");
String grammar = grammarBuilder.toString();

View File

@ -241,9 +241,11 @@ bool <r.name>Sempred(Ref\<<r.ctxType>\> _localctx, int predicateIndex);
>>
RuleSempredFunction(r, actions) ::= <<
bool <r.factory.grammar.name>::<r.name>Sempred(Ref\<<r.ctxType>\> _localctx, int predicateIndex) {
<! Called for both lexer and parser. But only one of them is actually available. Testing for the parser directly
generates a warning, however. So do the check via the factory instead. !>
bool <if (parser)><parser.name><else><lexer.name><endif>::<r.name>Sempred(Ref\<<r.ctxType>\> _localctx, int predicateIndex) {
switch (predicateIndex) {
<actions: {index | case <index>: return <actions.(index)>}; separator="\n">
<actions: {index | case <index>: return <actions.(index)>}; separator=";\n">;
default:
break;
@ -762,7 +764,7 @@ testShiftInRange(shiftAmount) ::= <<
// produces smaller bytecode only when bits.ttypes contains more than two items
bitsetBitfieldComparison(s, bits) ::= <<
(<testShiftInRange({<offsetShift(s.varName, bits.shift)>})> &&
((1L \<\< <offsetShift(s.varName, bits.shift)>) & (<bits.ttypes: {ttype | (1L \<\< <offsetShift(ttype, bits.shift, true)>)}; separator = "\n | ">)) != 0)
((1ULL \<\< <offsetShift(s.varName, bits.shift)>) & (<bits.ttypes: {ttype | (1ULL \<\< <offsetShift(ttype, bits.shift, true)>)}; separator = "\n | ">)) != 0)
>>
isZero ::= [
@ -823,7 +825,7 @@ setState(<w.stateNumber>);
// ACTION STUFF
ActionHeader(a, foo, chunks) ::= "<chunks>"
Action(a, foo, chunks) ::= "<if (chunks)><chunks>;<endif>"
Action(a, foo, chunks) ::= "<chunks>"
ArgAction(a, chunks) ::= "ArgAction(a, chunks) <chunks>"
@ -881,7 +883,7 @@ ListLabelRefHeader(t) ::= "<! Required but unused. !>"
ListLabelRef(t) ::= "<ctx(t)>-><ListLabelName(t.name)>"
SetAttrHeader(t) ::= "<! Required but unused. !>"
SetAttr(s,rhsChunks) ::= "<ctx(s)>-><s.name> = <rhsChunks>"
SetAttr(s,rhsChunks) ::= "<ctx(s)>-><s.name> = <rhsChunks>;"
InputSymbolType() ::= "<file.InputSymbolType; null = {Token}> *"
@ -1058,12 +1060,12 @@ ctx(actionChunk) ::= "std::dynamic_pointer_cast\<<actionChunk.ctx.name>>(_localc
// used for left-recursive rules
recRuleAltPredicate(ruleName,opPrec) ::= "precpred(_ctx, <opPrec>)"
recRuleSetReturnAction(src,name) ::= "recRuleSetReturnAction(src,name) $<name>=$<src>.<name>;"
recRuleSetStopToken() ::= "_ctx->stop = _input->LT(-1)"
recRuleSetStopToken() ::= "_ctx->stop = _input->LT(-1);"
recRuleAltStartAction(ruleName, ctxName, label) ::= <<
_localctx = std::make_shared\<<ctxName>Context>(parentContext, parentState);
<if (label)>_localctx-><label> = previousContext;<endif>
pushNewRecursionContext(_localctx, startState, Rule<ruleName; format = "cap">)
pushNewRecursionContext(_localctx, startState, Rule<ruleName; format = "cap">);
>>
// Separate context variable to avoid frequent pointer type casts.
@ -1083,13 +1085,13 @@ pushNewRecursionContext(newContext, startState, Rule<ruleName; format = "cap">);
recRuleReplaceContext(ctxName) ::= <<
_localctx = std::make_shared\<<ctxName>Context>(_localctx);
_ctx = _localctx;
previousContext = _localctx
previousContext = _localctx;
>>
recRuleSetPrevCtx() ::= <<
if (!_parseListeners.empty())
triggerExitRuleEvent();
previousContext = _localctx
previousContext = _localctx;
>>
/** Using a type to init value map, try to init a type; if not in table