Merge pull request #906 from parrt/mv-python3-to-new-test-gen

got all but 4 tests passing for py3!
This commit is contained in:
Terence Parr 2015-06-16 13:34:49 -07:00
commit 7d36891c82
12 changed files with 36 additions and 22 deletions

10
bild.py
View File

@ -67,7 +67,7 @@ RUNTIME_TEST_TEMPLATES = {
"Java" : uniformpath(JAVA_TARGET)+"/tool/test/org/antlr/v4/test/runtime/java/Java.test.stg", "Java" : uniformpath(JAVA_TARGET)+"/tool/test/org/antlr/v4/test/runtime/java/Java.test.stg",
"CSharp" : uniformpath(CSHARP_TARGET)+"/tool/test/org/antlr/v4/test/runtime/csharp/CSharp.test.stg", "CSharp" : uniformpath(CSHARP_TARGET)+"/tool/test/org/antlr/v4/test/runtime/csharp/CSharp.test.stg",
# "Python2" : uniformpath(PYTHON2_TARGET)+"/tool/test/org/antlr/v4/test/rt/py2/Python2.test.stg", # "Python2" : uniformpath(PYTHON2_TARGET)+"/tool/test/org/antlr/v4/test/rt/py2/Python2.test.stg",
# "Python3" : uniformpath(PYTHON3_TARGET)+"/tool/test/org/antlr/v4/test/rt/py3/Python3.test.stg", "Python3" : uniformpath(PYTHON3_TARGET)+"/tool/test/org/antlr/v4/test/runtime/python3/Python3.test.stg",
# "NodeJS" : uniformpath(JAVASCRIPT_TARGET)+"/tool/test/org/antlr/v4/test/rt/js/node/NodeJS.test.stg", # "NodeJS" : uniformpath(JAVASCRIPT_TARGET)+"/tool/test/org/antlr/v4/test/rt/js/node/NodeJS.test.stg",
# "Safari" : uniformpath(JAVASCRIPT_TARGET)+"/tool/test/org/antlr/v4/test/rt/js/safari/Safari.test.stg", # "Safari" : uniformpath(JAVASCRIPT_TARGET)+"/tool/test/org/antlr/v4/test/rt/js/safari/Safari.test.stg",
# "Firefox" : uniformpath(JAVASCRIPT_TARGET)+"/tool/test/org/antlr/v4/test/rt/js/firefox/Firefox.test.stg", # "Firefox" : uniformpath(JAVASCRIPT_TARGET)+"/tool/test/org/antlr/v4/test/rt/js/firefox/Firefox.test.stg",
@ -106,7 +106,7 @@ def compile():
javac(TARGETS[t] + "/tool/src", "out", version="1.6", cp=cp, args=args) javac(TARGETS[t] + "/tool/src", "out", version="1.6", cp=cp, args=args)
# pull in generated runtime tests and runtime test support code # pull in generated runtime tests and runtime test support code
for t in RUNTIME_TEST_TEMPLATES: for t in RUNTIME_TEST_TEMPLATES:
javac(TARGETS[t] + "/tool/test", "out", version="1.6", cp=cp, args=args) javac(TARGETS[t] + "/tool/test", "out", version="1.6", cp=cp, args=args, skip=['org/antlr/v4/test/rt'])
javac('gen/test/'+t, "out", version="1.6", cp=cp, args=args) javac('gen/test/'+t, "out", version="1.6", cp=cp, args=args)
@ -333,11 +333,11 @@ def test(target, juprops, args):
skip = [] skip = []
if target=='Java': if target=='Java':
# don't test generator # don't test generator
skip = [ "/org/antlr/v4/test/rt/gen/", "TestPerformance.java", "TestGenerator.java" ] skip = [ "TestPerformance.java", "TestGenerator.java" ]
elif target=='Python2': elif target=='Python2':
# need BaseTest located in Py3 target # need BaseTest located in python3 target
base = uniformpath(TARGETS['Python3'] + "/tool/test") base = uniformpath(TARGETS['Python3'] + "/tool/test")
skip = [ "/org/antlr/v4/test/rt/py3/" ] skip = [ "/org/antlr/v4/test/runtime/python3/" ]
javac(base, "out/test/"+target, version="1.6", cp=thisjarwithjunit, args=args, skip=skip) javac(base, "out/test/"+target, version="1.6", cp=thisjarwithjunit, args=args, skip=skip)
skip = [] skip = []
elif target=='JavaScript': elif target=='JavaScript':

View File

@ -28,5 +28,5 @@ WS : (' '|'\n') -> skip ;
// wasn't terminating. @after was injected into M as if it were @members // wasn't terminating. @after was injected into M as if it were @members
slaveGrammar(grammarName) ::= << slaveGrammar(grammarName) ::= <<
parser grammar S; parser grammar S;
a @after {int x;} : B; a @after {<InitIntMember("x","0")>} : B;
>> >>

View File

@ -17,18 +17,18 @@ expressionList
: e (',' e)* : e (',' e)*
; ;
e : '(' e ')' e : '(' e ')'
| 'this' | 'this'
| 'super' | 'super'
| INT | INT
| ID | ID
| type '.' 'class' | typespec '.' 'class'
| e '.' ID | e '.' ID
| e '.' 'this' | e '.' 'this'
| e '.' 'super' '(' expressionList? ')' | e '.' 'super' '(' expressionList? ')'
| e '.' 'new' ID '(' expressionList? ')' | e '.' 'new' ID '(' expressionList? ')'
| 'new' type ( '(' expressionList? ')' | ('[' e ']')+) | 'new' typespec ( '(' expressionList? ')' | ('[' e ']')+)
| e '[' e ']' | e '[' e ']'
| '(' type ')' e | '(' typespec ')' e
| e ('++' | '--') | e ('++' | '--')
| e '(' expressionList? ')' | e '(' expressionList? ')'
| ('+'|'-'|'++'|'--') e | ('+'|'-'|'++'|'--') e
@ -59,10 +59,11 @@ e : '(' e ')'
|'\<\<=' |'\<\<='
|'%=') e |'%=') e
; ;
type: ID typespec
: ID
| ID '[' ']' | ID '[' ']'
| 'int' | 'int'
| 'int' '[' ']' | 'int' '[' ']'
; ;
ID : ('a'..'z'|'A'..'Z'|'_'|'$')+; ID : ('a'..'z'|'A'..'Z'|'_'|'$')+;
INT : '0'..'9'+ ; INT : '0'..'9'+ ;

View File

@ -3,7 +3,7 @@ import "JavaExpressions.stg"
Input() ::= "new T[((n-1) * x) + 1]" Input() ::= "new T[((n-1) * x) + 1]"
Output() ::= << Output() ::= <<
(s (e new (type T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) \<EOF>)<\n> (s (e new (typespec T) [ (e (e ( (e (e ( (e (e n) - (e 1)) )) * (e x)) )) + (e 1)) ]) \<EOF>)<\n>
>> >>
Errors() ::= "" Errors() ::= ""

View File

@ -3,7 +3,7 @@ import "JavaExpressions.stg"
Input() ::= "(T)x" Input() ::= "(T)x"
Output() ::= << Output() ::= <<
(s (e ( (type T) ) (e x)) \<EOF>)<\n> (s (e ( (typespec T) ) (e x)) \<EOF>)<\n>
>> >>
Errors() ::= "" Errors() ::= ""

View File

@ -3,7 +3,7 @@ import "JavaExpressions.stg"
Input() ::= "new A().b" Input() ::= "new A().b"
Output() ::= << Output() ::= <<
(s (e (e new (type A) ( )) . b) \<EOF>)<\n> (s (e (e new (typespec A) ( )) . b) \<EOF>)<\n>
>> >>
Errors() ::= "" Errors() ::= ""

View File

@ -3,7 +3,7 @@ import "JavaExpressions.stg"
Input() ::= "(T)t.f()" Input() ::= "(T)t.f()"
Output() ::= << Output() ::= <<
(s (e (e ( (type T) ) (e (e t) . f)) ( )) \<EOF>)<\n> (s (e (e ( (typespec T) ) (e (e t) . f)) ( )) \<EOF>)<\n>
>> >>
Errors() ::= "" Errors() ::= ""

View File

@ -19,16 +19,16 @@ Rule() ::= "s"
grammar(grammarName) ::= << grammar(grammarName) ::= <<
grammar <grammarName>; grammar <grammarName>;
s : e {<writeln("$e.v")>}; s : e {<writeln("$e.v")>};
e returns [int v] e returns [int v]
: e '*' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v * <Cast("BinaryContext","$ctx")>.e(1).v;} # binary : e '*' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v * <Cast("BinaryContext","$ctx")>.e(1).v;} # binary
| e '+' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v + <Cast("BinaryContext","$ctx")>.e(1).v;} # binary | e '+' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v + <Cast("BinaryContext","$ctx")>.e(1).v;} # binary
| INT {$v = $INT.int;} # anInt | INT {$v = $INT.int;} # anInt
| '(' e ')' {$v = $e.v;} # parens | '(' e ')' {$v = $e.v;} # parens
| left=e INC {<Cast("UnaryContext","$ctx"):Concat(".INC() != null"):Assert()> $v = $left.v + 1;} # unary | left=e INC {<Cast("UnaryContext","$ctx"):Concat(".INC() != null"):Assert()>$v = $left.v + 1;} # unary
| left=e DEC {<Cast("UnaryContext","$ctx"):Concat(".DEC() != null"):Assert()> $v = $left.v - 1;} # unary | left=e DEC {<Cast("UnaryContext","$ctx"):Concat(".DEC() != null"):Assert()>$v = $left.v - 1;} # unary
| ID {<AssignLocal("$v","3")>} # anID | ID {<AssignLocal("$v","3")>} # anID
; ;
ID : 'a'..'z'+ ; ID : 'a'..'z'+ ;
INT : '0'..'9'+ ; INT : '0'..'9'+ ;
INC : '++' ; INC : '++' ;

View File

@ -25,7 +25,7 @@ grammar(grammarName) ::= <<
grammar <grammarName>; grammar <grammarName>;
s : stmt EOF ; s : stmt EOF ;
stmt : ifStmt | ID; stmt : ifStmt | ID;
ifStmt : 'if' ID stmt ('else' stmt | { <LANotEquals("1", "ELSE")> }?); ifStmt : 'if' ID stmt ('else' stmt | { <LANotEquals("1", {<grammarName>Parser.ELSE})> }?);
ELSE : 'else'; ELSE : 'else';
ID : [a-zA-Z]+; ID : [a-zA-Z]+;
WS : [ \\n\\t]+ -> skip; WS : [ \\n\\t]+ -> skip;

View File

@ -18,7 +18,7 @@ file_
@after {<ToStringTree("$ctx"):writeln()>} @after {<ToStringTree("$ctx"):writeln()>}
: para para EOF ; : para para EOF ;
para: paraContent NL NL ; para: paraContent NL NL ;
paraContent : ('s'|'x'|{<LANotEquals("2","TParser.NL")>}? NL)+ ; paraContent : ('s'|'x'|{<LANotEquals("2",{<grammarName>Parser.NL})>}? NL)+ ;
NL : '\n' ; NL : '\n' ;
s : 's' ; s : 's' ;
X : 'x' ; X : 'x' ;

View File

@ -228,6 +228,14 @@ RuleInvocationStack() ::= "getRuleInvocationStack()"
LL_EXACT_AMBIG_DETECTION() ::= <<_interp.setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);>> LL_EXACT_AMBIG_DETECTION() ::= <<_interp.setPredictionMode(PredictionMode.LL_EXACT_AMBIG_DETECTION);>>
ParserPropertyMember() ::= <<
@members {
boolean Property() {
return true;
}
}
>>
PositionAdjustingLexer() ::= << PositionAdjustingLexer() ::= <<
@Override @Override

View File

@ -19,6 +19,7 @@
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../gen/test/CSharp" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/../gen/test/CSharp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../gen/test/Java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/../gen/test/Java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../gen/test/Python3" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/../.idea" /> <excludeFolder url="file://$MODULE_DIR$/../.idea" />
<excludeFolder url="file://$MODULE_DIR$/../antlr4-maven-plugin" /> <excludeFolder url="file://$MODULE_DIR$/../antlr4-maven-plugin" />
<excludeFolder url="file://$MODULE_DIR$/../runtime" /> <excludeFolder url="file://$MODULE_DIR$/../runtime" />
@ -32,6 +33,10 @@
<content url="file://$MODULE_DIR$/../../antlr4-csharp/tool/test"> <content url="file://$MODULE_DIR$/../../antlr4-csharp/tool/test">
<sourceFolder url="file://$MODULE_DIR$/../../antlr4-csharp/tool/test" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/../../antlr4-csharp/tool/test" isTestSource="false" />
</content> </content>
<content url="file://$MODULE_DIR$/../../antlr4-python3">
<sourceFolder url="file://$MODULE_DIR$/../../antlr4-python3/tool/test" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../antlr4-python3/tool/src" isTestSource="false" />
</content>
<orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" /> <orderEntry type="jdk" jdkName="1.7" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="runtime" /> <orderEntry type="module" module-name="runtime" />