Skip to content

Commit

Permalink
Fixes #2301
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvergnaud committed Jun 3, 2018
1 parent 61acb35 commit d134b6a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -854,4 +854,39 @@ public static class OpenDeviceStatement_Case3 extends BaseParserTestDescriptor {
@CommentHasStringValue
public String grammar;
}

/**
* This is a regression test for antlr/antlr4#2301.
*/
public static class OrderingPredicates extends BaseParserTestDescriptor {
public String input = "POINT AT X";
public String output = null;
public String errors = null;
public String startRule = "expr";
public String grammarName = "Issue2301";

/**
grammar Issue2301;
SPACES: [ \t\r\n]+ -> skip;
AT: 'AT';
X : 'X';
Y : 'Y';
ID: [A-Z]+;
constant
: 'DUMMY'
;
expr
: ID constant?
| expr AT X
| expr AT Y
;
*/
@CommentHasStringValue
public String grammar;
}
}
4 changes: 2 additions & 2 deletions runtime/Python3/src/antlr4/atn/SemanticContext.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def evalPrecedence(self, parser:Recognizer, outerContext:RuleContext):
else:
return None

def __cmp__(self, other):
return self.precedence - other.precedence
def __lt__(self, other):
return self.precedence < other.precedence

def __hash__(self):
return 31
Expand Down

0 comments on commit d134b6a

Please sign in to comment.