diff --git a/tool/test/org/antlr/v4/test/rt/gen/Generator.java b/tool/test/org/antlr/v4/test/rt/gen/Generator.java index b26120556..c15a95673 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/Generator.java +++ b/tool/test/org/antlr/v4/test/rt/gen/Generator.java @@ -34,9 +34,11 @@ public class Generator { Map configs = new HashMap(); configs.put("Source", readGrammarDir()); // source of test templates configs.put("Java", readJavaDir()); // generated Java tests + configs.put("Python2", readPython2Dir()); // generated Python2 tests + configs.put("Python3", readPython3Dir()); // generated Python3 tests configs.put("NodeJS", readNodeJSDir()); // generated NodeJS tests configs.put("Safari", readSafariDir()); // generated Firefox tests - configs.put("Firefox", readFirefoxDir()); // generated Firefox tests + // configs.put("Firefox", readFirefoxDir()); // generated Firefox tests return configs; } @@ -48,6 +50,16 @@ public class Generator { return new File(new URI(uri)); } + private static File readPython2Dir() { + // TODO Auto-generated method stub + return new File("/Users/ericvergnaud/Development/antlr4/antlr/antlr4-python2/tool/test/org/antlr/v4/test/rt/py2"); + } + + private static File readPython3Dir() { + // TODO Auto-generated method stub + return new File("/Users/ericvergnaud/Development/antlr4/antlr/antlr4-python3/tool/test/org/antlr/v4/test/rt/py3"); + } + private static File readNodeJSDir() { // TODO Auto-generated method stub return new File("/Users/ericvergnaud/Development/antlr4/antlr/antlr4-javascript/tool/test/org/antlr/v4/test/rt/js/node"); @@ -802,12 +814,12 @@ public class Generator { "a >> b", "(s (e (e a) >> (e b)) )\n", "a=b=c", "(s (e (e a) = (e (e b) = (e c))) )\n", "a^b^c", "(s (e (e a) ^ (e (e b) ^ (e c))) )\n", - "(T)x", "(s (e ( (type T) ) (e x)) )\n", - "new A().b", "(s (e (e new (type A) ( )) . b) )\n", - "(T)t.f()", "(s (e (e ( (type T) ) (e (e t) . f)) ( )) )\n", + "(T)x", "(s (e ( (type_ T) ) (e x)) )\n", + "new A().b", "(s (e (e new (type_ A) ( )) . b) )\n", + "(T)t.f()", "(s (e (e ( (type_ T) ) (e (e t) . f)) ( )) )\n", "a.f(x)==T.c", "(s (e (e (e (e a) . f) ( (expressionList (e x)) )) == (e (e T) . c)) )\n", "a.f().g(x,1)", "(s (e (e (e (e (e a) . f) ( )) . g) ( (expressionList (e x) , (e 1)) )) )\n", - "new T[((n-1) * x) + 1]", "(s (e new (type T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) )\n"); + "new T[((n-1) * x) + 1]", "(s (e new (type_ T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) )\n"); file.addParserTests(input, "Declarations", "T", "s", "a", "(s (declarator a) )\n", "*a", "(s (declarator * (declarator a)) )\n", diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/DelegatorRuleOverridesLookaheadInDelegate_S.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/DelegatorRuleOverridesLookaheadInDelegate_S.st index c60a2288d..c00963f02 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/DelegatorRuleOverridesLookaheadInDelegate_S.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/DelegatorRuleOverridesLookaheadInDelegate_S.st @@ -1,7 +1,5 @@ parser grammar S; type_ : 'int' ; decl : type_ ID ';' - | type_ ID init ';' { - - }; + | type_ ID init ';' {}; init : '=' INT; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/KeywordVSIDOrder.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/KeywordVSIDOrder.st index 6e137e60e..f0620d567 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/KeywordVSIDOrder.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/CompositeParsers/KeywordVSIDOrder.st @@ -1,5 +1,5 @@ grammar M; import S; -a : A {}; +a : A {}; A : 'abc' {}; WS : (' '|'\n') -> skip ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/JavaExpressions.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/JavaExpressions.st index c23d612af..2cb9f774a 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/JavaExpressions.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/JavaExpressions.st @@ -8,14 +8,14 @@ e : '(' e ')' | 'super' | INT | ID - | type '.' 'class' + | type_ '.' 'class' | e '.' ID | e '.' 'this' | e '.' 'super' '(' expressionList? ')' | e '.' 'new' ID '(' expressionList? ')' - | 'new' type ( '(' expressionList? ')' | ('[' e ']')+) + | 'new' type_ ( '(' expressionList? ')' | ('[' e ']')+) | e '[' e ']' - | '(' type ')' e + | '(' type_ ')' e | e ('++' | '--') | e '(' expressionList? ')' | ('+'|'-'|'++'|'--') e @@ -46,7 +46,7 @@ e : '(' e ')' |'\<\<=' |'%=') e ; -type: ID +type_: ID | ID '[' ']' | 'int' | 'int' '[' ']' diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/MultipleActionsPredicatesOptions.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/MultipleActionsPredicatesOptions.st index 91a8b0a65..aa74f8906 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/MultipleActionsPredicatesOptions.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/MultipleActionsPredicatesOptions.st @@ -1,7 +1,7 @@ grammar ; s @after {} : e ; -e : a=e op=('*'|'/') b=e {}{true}? - | a=e op=('+'|'-') b=e {}\{true}?\ +e : a=e op=('*'|'/') b=e {}{}? + | a=e op=('+'|'-') b=e {}\{}?\ | INT {}{} | '(' x=e ')' {}{} ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPred.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPred.st index e568a8944..b95a58025 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPred.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPred.st @@ -1,6 +1,6 @@ grammar ; s @after {} : a ; -a : a {}? ID +a : a {}? ID | ID ; ID : 'a'..'z'+ ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPredFailOption.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPredFailOption.st index aac2fc7f1..b5eb5f7ec 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPredFailOption.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/LeftRecursion/SemPredFailOption.st @@ -1,6 +1,6 @@ grammar ; s @after {} : a ; -a : a ID {false}?\ +a : a ID {}?\ | ID ; ID : 'a'..'z'+ ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st index d7259fee4..c4ba9d33a 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpToken.st @@ -1,2 +1,2 @@ grammar ; -a : 'a' x='b' {} 'c' ; \ No newline at end of file +a : 'a' x='b' {} 'c' ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st index e8f27a064..5030a368d 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserErrors/ConjuringUpTokenFromSet.st @@ -1,2 +1,2 @@ grammar ; -a : 'a' x=('b'|'c') {} 'd' ; +a : 'a' x=('b'|'c') {} 'd' ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/LabelAliasingAcrossLabeledAlternatives.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/LabelAliasingAcrossLabeledAlternatives.st index 6074d12bf..8e823dd2a 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/LabelAliasingAcrossLabeledAlternatives.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/LabelAliasingAcrossLabeledAlternatives.st @@ -1,8 +1,8 @@ grammar ; start : a* EOF; a - : label=subrule { } #One - | label='y' { } #Two + : label=subrule {} #One + | label='y' {} #Two ; subrule : 'x'; WS : (' '|'\n') -> skip ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/ReferenceToATN.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/ReferenceToATN.st index 6b20ad9af..1099affbc 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/ReferenceToATN.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/ParserExec/ReferenceToATN.st @@ -1,5 +1,5 @@ grammar ; -a : (ID|ATN)* ATN? {} ; +a : (ID|ATN_)* ATN_? {} ; ID : 'a'..'z'+ ; -ATN : '0'..'9'+; +ATN_ : '0'..'9'+; WS : (' '|'\n') -> skip ; \ No newline at end of file diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/DisableRule.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/DisableRule.st index 90248db25..ec1263a71 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/DisableRule.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/DisableRule.st @@ -1,5 +1,5 @@ lexer grammar ; -E1 : 'enum' { }? ; -E2 : 'enum' { }? ; // winner not E1 or ID +E1 : 'enum' { }? ; +E2 : 'enum' { }? ; // winner not E1 or ID ID : 'a'..'z'+ ; WS : (' '|'\n') -> skip; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDnotEnum.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDnotEnum.st index cac3df8d1..c055aa9db 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDnotEnum.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDnotEnum.st @@ -1,4 +1,4 @@ lexer grammar ; -ENUM : [a-z]+ { }? ; +ENUM : [a-z]+ { }? ; ID : [a-z]+ ; WS : (' '|'\n') -> skip; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDvsEnum.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDvsEnum.st index fc0b0696e..c5180a1ed 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDvsEnum.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalLexer/IDvsEnum.st @@ -1,4 +1,4 @@ lexer grammar ; -ENUM : 'enum' { }? ; +ENUM : 'enum' { }? ; ID : 'a'..'z'+ ; WS : (' '|'\n') -> skip; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAlts.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAlts.st index 3219067ba..0982d1d67 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAlts.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAlts.st @@ -2,7 +2,7 @@ grammar ; s : {} a ';' a; // do 2x: once in ATN, next in DFA a : ID {} | ID {} - | {}? ID {} + | {}? ID {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAltsAndOneOrthogonalAlt.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAltsAndOneOrthogonalAlt.st index 47bc99281..4ab1601dc 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAltsAndOneOrthogonalAlt.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/2UnpredicatedAltsAndOneOrthogonalAlt.st @@ -3,7 +3,7 @@ s : {} a ';' a ';' a; a : INT {} | ID {} // must pick this one for ID since pred is false | ID {} - | {}? ID {} + | {}? ID {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ActionsHidePredsInGlobalFOLLOW.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ActionsHidePredsInGlobalFOLLOW.st index 8c4ced294..8316cf133 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ActionsHidePredsInGlobalFOLLOW.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ActionsHidePredsInGlobalFOLLOW.st @@ -2,8 +2,8 @@ grammar ; @members { } -s : e {} {}? {} '!' ; -t : e {} {}? ID ; +s : e {} {}? {} '!' ; +t : e {} {}? ID ; e : ID | ; // non-LL(1) so we use ATN ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/DisabledAlternative.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/DisabledAlternative.st index 869d94b27..2cfbbab6c 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/DisabledAlternative.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/DisabledAlternative.st @@ -1,5 +1,5 @@ grammar ; cppCompilationUnit : content+ EOF; -content: anything | {}? .; +content: anything | {}? .; anything: ANY_CHAR; ANY_CHAR: [_a-zA-Z0-9]; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/IndependentPredNotPassedOuterCtxToAvoidCastException.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/IndependentPredNotPassedOuterCtxToAvoidCastException.st index 1b5baf097..4143ec3b3 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/IndependentPredNotPassedOuterCtxToAvoidCastException.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/IndependentPredNotPassedOuterCtxToAvoidCastException.st @@ -2,8 +2,8 @@ grammar ; s : b ';' | b '.' ; b : a ; a - : {}? ID {} - | {}? ID {} + : {}? ID {} + | {}? ID {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/NoTruePredsThrowsNoViableAlt.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/NoTruePredsThrowsNoViableAlt.st index ae5714552..dd7b05895 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/NoTruePredsThrowsNoViableAlt.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/NoTruePredsThrowsNoViableAlt.st @@ -1,7 +1,7 @@ grammar ; s : a a; -a : {}? ID INT {} - | {}? ID INT {} +a : {}? ID INT {} + | {}? ID INT {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Order.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Order.st index 2b6d59d4f..1d83ac807 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Order.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Order.st @@ -3,7 +3,7 @@ s : a {} a; // do 2x: once in ATN, next in DFA; // action blocks lookahead from falling off of 'a' // and looking into 2nd 'a' ref. !ctx dependent pred a : ID {} - | {}? ID {} + | {}? ID {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredTestedEvenWhenUnAmbig.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredTestedEvenWhenUnAmbig.st index 8840f393b..7b724ad2f 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredTestedEvenWhenUnAmbig.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredTestedEvenWhenUnAmbig.st @@ -1,8 +1,8 @@ grammar ; -@members {} +@members {} primary : ID {} - | {!}? 'enum' {} + | {}? 'enum' {} ; ID : [a-z]+ ; WS : [ \t\n\r]+ -> skip ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredsInGlobalFOLLOW.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredsInGlobalFOLLOW.st index 3a63138a3..27c61d473 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredsInGlobalFOLLOW.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/PredsInGlobalFOLLOW.st @@ -2,8 +2,8 @@ grammar ; @members { } -s : e {}? {} '!' ; -t : e {}? ID ; +s : e {}? {} '!' ; +t : e {}? ID ; e : ID | ; // non-LL(1) so we use ATN ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Simple.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Simple.st index 8570ed205..5285fcf83 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Simple.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/Simple.st @@ -1,7 +1,7 @@ grammar ; s : a a a; // do 3x: once in ATN, next in DFA then INT in ATN -a : {}? ID {} - | {}? ID {} +a : {}? ID {} + | {}? ID {} | INT {} ; ID : 'a'..'z'+ ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate.st index 3b0577eeb..5169d43b6 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate.st @@ -1,7 +1,7 @@ grammar ; s : a ; -a : {}? ID {} - | {}? INT {} +a : {}? ID {} + | {}? INT {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate2.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate2.st index 6a84abcca..606c0083e 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate2.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/SimpleValidate2.st @@ -1,7 +1,7 @@ grammar ; s : a a a; -a : {}? ID {} - | {}? INT {} +a : {}? ID {} + | {}? INT {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeft.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeft.st index bf6e1f899..a69e500a8 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeft.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeft.st @@ -1,7 +1,7 @@ grammar ; s : a+ ; -a : {}? ID {} - | {}? ID {} +a : {}? ID {} + | {}? ID {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeftWithVaryingPredicate.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeftWithVaryingPredicate.st index be00d9913..f67afc57e 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeftWithVaryingPredicate.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ToLeftWithVaryingPredicate.st @@ -1,7 +1,7 @@ grammar ; @members {} s : ({ - } a)+ ; +} a)+ ; a : {}? ID {} | {}? ID {} ; diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/UnpredicatedPathsInAlt.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/UnpredicatedPathsInAlt.st index a53c09554..207df7b63 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/UnpredicatedPathsInAlt.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/UnpredicatedPathsInAlt.st @@ -2,7 +2,7 @@ grammar ; s : a {} | b {} ; -a : {}? ID INT +a : {}? ID INT | ID INT ; b : ID ID diff --git a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ValidateInDFA.st b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ValidateInDFA.st index 7b153b7c4..47b10e627 100644 --- a/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ValidateInDFA.st +++ b/tool/test/org/antlr/v4/test/rt/gen/grammars/SemPredEvalParser/ValidateInDFA.st @@ -3,8 +3,8 @@ s : a ';' a; // ';' helps us to resynchronize without consuming // 2nd 'a' reference. We our testing that the DFA also // throws an exception if the validating predicate fails -a : {}? ID {} - | {}? INT {} +a : {}? ID {} + | {}? INT {} ; ID : 'a'..'z'+ ; INT : '0'..'9'+; diff --git a/tool/test/org/antlr/v4/test/rt/java/Java.test.stg b/tool/test/org/antlr/v4/test/rt/java/Java.test.stg index 157e53636..d52e9fa49 100644 --- a/tool/test/org/antlr/v4/test/rt/java/Java.test.stg +++ b/tool/test/org/antlr/v4/test/rt/java/Java.test.stg @@ -99,10 +99,18 @@ writeln(s) ::= <);>> write(s) ::= <);>> +False() ::= "false" + +True() ::= "true" + +Not(v) ::= "!" + Assert(s) ::= <);>> Cast(t,v) ::= "(())" +Append(a,b) ::= " + " + Concat(a,b) ::= "" DeclareLocal(s,v) ::= "Object = ;" diff --git a/tool/test/org/antlr/v4/test/rt/java/TestCompositeParsers.java b/tool/test/org/antlr/v4/test/rt/java/TestCompositeParsers.java index 7c4c99f84..c5599b0ce 100644 --- a/tool/test/org/antlr/v4/test/rt/java/TestCompositeParsers.java +++ b/tool/test/org/antlr/v4/test/rt/java/TestCompositeParsers.java @@ -209,9 +209,7 @@ public class TestCompositeParsers extends BaseTest { String slave_S = "parser grammar S;\n" + "type_ : 'int' ;\n" + "decl : type_ ID ';'\n" + - " | type_ ID init ';' {\n" + - " System.out.print(\"Decl: \" + $text);\n" + - " };\n" + + " | type_ ID init ';' {System.out.print(\"Decl: \" + $text);};\n" + "init : '=' INT;"; mkdir(tmpdir); writeFile(tmpdir, "S.g4", slave_S); @@ -261,7 +259,7 @@ public class TestCompositeParsers extends BaseTest { String grammar = "grammar M;\n" + "import S;\n" + - "a : A {System.out.println(\"M.a: \"+$A);};\n" + + "a : A {System.out.println(\"M.a: \" + $A);};\n" + "A : 'abc' {System.out.println(\"M.A\");};\n" + "WS : (' '|'\\n') -> skip ;"; String found = execParser("M.g4", grammar, "MParser", "MLexer", "a", "abc", false); diff --git a/tool/test/org/antlr/v4/test/rt/java/TestLeftRecursion.java b/tool/test/org/antlr/v4/test/rt/java/TestLeftRecursion.java index 6bac42fa3..0709657db 100644 --- a/tool/test/org/antlr/v4/test/rt/java/TestLeftRecursion.java +++ b/tool/test/org/antlr/v4/test/rt/java/TestLeftRecursion.java @@ -236,14 +236,14 @@ public class TestLeftRecursion extends BaseTest { " | 'super'\n" + " | INT\n" + " | ID\n" + - " | type '.' 'class'\n" + + " | type_ '.' 'class'\n" + " | e '.' ID\n" + " | e '.' 'this'\n" + " | e '.' 'super' '(' expressionList? ')'\n" + " | e '.' 'new' ID '(' expressionList? ')'\n" + - " | 'new' type ( '(' expressionList? ')' | ('[' e ']')+)\n" + + " | 'new' type_ ( '(' expressionList? ')' | ('[' e ']')+)\n" + " | e '[' e ']'\n" + - " | '(' type ')' e\n" + + " | '(' type_ ')' e\n" + " | e ('++' | '--')\n" + " | e '(' expressionList? ')'\n" + " | ('+'|'-'|'++'|'--') e\n" + @@ -274,7 +274,7 @@ public class TestLeftRecursion extends BaseTest { " |'<<='\n" + " |'%=') e\n" + " ;\n" + - "type: ID \n" + + "type_: ID \n" + " | ID '[' ']'\n" + " | 'int'\n" + " | 'int' '[' ']' \n" + @@ -330,21 +330,21 @@ public class TestLeftRecursion extends BaseTest { @Test public void testJavaExpressions_7() throws Exception { String found = testJavaExpressions("(T)x"); - assertEquals("(s (e ( (type T) ) (e x)) )\n", found); + assertEquals("(s (e ( (type_ T) ) (e x)) )\n", found); assertNull(this.stderrDuringParse); } @Test public void testJavaExpressions_8() throws Exception { String found = testJavaExpressions("new A().b"); - assertEquals("(s (e (e new (type A) ( )) . b) )\n", found); + assertEquals("(s (e (e new (type_ A) ( )) . b) )\n", found); assertNull(this.stderrDuringParse); } @Test public void testJavaExpressions_9() throws Exception { String found = testJavaExpressions("(T)t.f()"); - assertEquals("(s (e (e ( (type T) ) (e (e t) . f)) ( )) )\n", found); + assertEquals("(s (e (e ( (type_ T) ) (e (e t) . f)) ( )) )\n", found); assertNull(this.stderrDuringParse); } @@ -365,7 +365,7 @@ public class TestLeftRecursion extends BaseTest { @Test public void testJavaExpressions_12() throws Exception { String found = testJavaExpressions("new T[((n-1) * x) + 1]"); - assertEquals("(s (e new (type T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) )\n", found); + assertEquals("(s (e new (type_ T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) )\n", found); assertNull(this.stderrDuringParse); } diff --git a/tool/test/org/antlr/v4/test/rt/java/TestParserErrors.java b/tool/test/org/antlr/v4/test/rt/java/TestParserErrors.java index f9c081c50..3c94359e7 100644 --- a/tool/test/org/antlr/v4/test/rt/java/TestParserErrors.java +++ b/tool/test/org/antlr/v4/test/rt/java/TestParserErrors.java @@ -44,7 +44,7 @@ public class TestParserErrors extends BaseTest { @Test public void testConjuringUpToken() throws Exception { String grammar = "grammar T;\n" + - "a : 'a' x='b' {System.out.println(\"conjured=\"+$x);} 'c' ;"; + "a : 'a' x='b' {System.out.println(\"conjured=\" + $x);} 'c' ;"; String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ac", false); assertEquals("conjured=[@-1,-1:-1='',<2>,1:1]\n", found); assertEquals("line 1:1 missing 'b' at 'c'\n", this.stderrDuringParse); @@ -62,7 +62,7 @@ public class TestParserErrors extends BaseTest { @Test public void testConjuringUpTokenFromSet() throws Exception { String grammar = "grammar T;\n" + - "a : 'a' x=('b'|'c') {System.out.println(\"conjured=\"+$x);} 'd' ;"; + "a : 'a' x=('b'|'c') {System.out.println(\"conjured=\" + $x);} 'd' ;"; String found = execParser("T.g4", grammar, "TParser", "TLexer", "a", "ad", false); assertEquals("conjured=[@-1,-1:-1='',<2>,1:1]\n", found); assertEquals("line 1:1 missing {'b', 'c'} at 'd'\n", this.stderrDuringParse); diff --git a/tool/test/org/antlr/v4/test/rt/java/TestParserExec.java b/tool/test/org/antlr/v4/test/rt/java/TestParserExec.java index a001a0b3b..325bff2cb 100644 --- a/tool/test/org/antlr/v4/test/rt/java/TestParserExec.java +++ b/tool/test/org/antlr/v4/test/rt/java/TestParserExec.java @@ -317,8 +317,8 @@ public class TestParserExec extends BaseTest { String grammar = "grammar T;\n" + "start : a* EOF;\n" + "a\n" + - " : label=subrule { System.out.println($label.text); } #One\n" + - " | label='y' { System.out.println($label.text); } #Two\n" + + " : label=subrule {System.out.println($label.text);} #One\n" + + " | label='y' {System.out.println($label.text);} #Two\n" + " ;\n" + "subrule : 'x';\n" + "WS : (' '|'\\n') -> skip ;"; @@ -395,9 +395,9 @@ public class TestParserExec extends BaseTest { String testReferenceToATN(String input) throws Exception { String grammar = "grammar T;\n" + - "a : (ID|ATN)* ATN? {System.out.println($text);} ;\n" + + "a : (ID|ATN_)* ATN_? {System.out.println($text);} ;\n" + "ID : 'a'..'z'+ ;\n" + - "ATN : '0'..'9'+;\n" + + "ATN_ : '0'..'9'+;\n" + "WS : (' '|'\\n') -> skip ;"; return execParser("T.g4", grammar, "TParser", "TLexer", "a", input, false); } diff --git a/tool/test/org/antlr/v4/test/rt/java/TestSemPredEvalParser.java b/tool/test/org/antlr/v4/test/rt/java/TestSemPredEvalParser.java index 6bbd98d4d..5f4442351 100644 --- a/tool/test/org/antlr/v4/test/rt/java/TestSemPredEvalParser.java +++ b/tool/test/org/antlr/v4/test/rt/java/TestSemPredEvalParser.java @@ -216,7 +216,7 @@ public class TestSemPredEvalParser extends BaseTest { String grammar = "grammar T;\n" + "@members {int i = 0;}\n" + "s : ({this.i += 1;\n" + - " System.out.println(\"i=\" + this.i);} a)+ ;\n" + + "System.out.println(\"i=\" + this.i);} a)+ ;\n" + "a : {this.i % 2 == 0}? ID {System.out.println(\"alt 1\");}\n" + " | {this.i % 2 != 0}? ID {System.out.println(\"alt 2\");}\n" + " ;\n" +