Verify behavior of LeftRecursion tests, and correct discrepancies

This commit is contained in:
Sam Harwell 2015-06-06 15:37:36 -05:00
parent 2f99ca7453
commit 990fd9d811
13 changed files with 28 additions and 28 deletions

View File

@ -1,7 +1,7 @@
TestType() ::= "Parser"
Options ::= [
"Debug": false
"Debug": true
]
Grammar ::= [

View File

@ -1,4 +1,4 @@
/**
/*
* This is a regression test for "Support direct calls to left-recursive
* rules".
* https://github.com/antlr/antlr4/issues/161

View File

@ -21,14 +21,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
@ -59,7 +59,7 @@ e : '(' e ')'
|'\<\<='
|'%=') e
;
type_: ID
type: ID
| ID '[' ']'
| 'int'
| 'int' '[' ']'

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
/**
/*
* This is a regression test for antlr/antlr4#625 "Duplicate action breaks
* operator precedence"
* https://github.com/antlr/antlr4/issues/625

View File

@ -1,4 +1,4 @@
/**
/*
* This is a regression test for antlr/antlr4#625 "Duplicate action breaks
* operator precedence"
* https://github.com/antlr/antlr4/issues/625

View File

@ -1,4 +1,4 @@
/**
/*
* This is a regression test for antlr/antlr4#433 "Not all context accessor
* methods are generated when an alternative rule label is used for multiple
* alternatives".
@ -25,8 +25,8 @@ e returns [int v]
| e '+' e {$v = <Cast("BinaryContext","$ctx")>.e(0).v + <Cast("BinaryContext","$ctx")>.e(1).v;} # binary
| INT {$v = $INT.int;} # anInt
| '(' e ')' {$v = $e.v;} # parens
| 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 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
| ID {<AssignLocal("$v","3")>} # anID
;
ID : 'a'..'z'+ ;

View File

@ -1,10 +1,10 @@
/**
* This is a regression test for antlr/antlr4#677 "labels not working in
* grammar file".
/*
* This is a regression test for antlr/antlr4#677 "labels not working in grammar
* file".
* https://github.com/antlr/antlr4/issues/677
*
* <p>This test treats {@code ,} and {@code >>} as part of a single compound
* operator (similar to a ternary operator).</p>
* This test treats `,` and `>>` as part of a single compound operator (similar
* to a ternary operator).
*/
TestType() ::= "Parser"

View File

@ -1,9 +1,9 @@
/**
* This is a regression test for antlr/antlr4#677 "labels not working in
* grammar file".
/*
* This is a regression test for antlr/antlr4#677 "labels not working in grammar
* file".
* https://github.com/antlr/antlr4/issues/677
*
* <p>This test treats the {@code ,} and {@code >>} operators separately.</p>
* This test treats the `,` and `>>` operators separately.
*/
TestType() ::= "Parser"

View File

@ -1,6 +1,6 @@
/**
* This is a regression test for #239 "recoursive parser using implicit
* tokens ignore white space lexer rule".
/*
* This is a regression test for #239 "recoursive parser using implicit tokens
* ignore white space lexer rule".
* https://github.com/antlr/antlr4/issues/239
*/
@ -63,7 +63,7 @@ ID : LETTER ALPHANUM*;
NUMBER : DIGIT+ ('.' DIGIT+)? (('e'|'E')('+'|'-')? DIGIT+)?;
DATE : '\'' DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT (' ' DIGIT DIGIT ':' DIGIT DIGIT ':' DIGIT DIGIT ('.' DIGIT+)?)? '\'';
SQ_STRING : '\'' ('\'\'' | ~'\'')* '\'';
DQ_STRING : '\"' ('\\\"' | ~'\"')* '\"';
DQ_STRING : '"' ('\\\\"' | ~'"')* '"';
WS : [ \t\n\r]+ -> skip ;
COMMENTS : ('/*' .*? '*/' | '//' ~'\n'* '\n' ) -> skip;
>>