Skip to content

Commit

Permalink
Merge pull request #55 from danielsun1106:#53
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Oct 9, 2019
2 parents be01739 + 2bd3930 commit 269c382
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sudo: true
dist: trusty
language: java
branches:
only:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public FailedPredicateException(@NotNull Parser recognizer, @Nullable String pre
}

public FailedPredicateException(@NotNull Parser recognizer,
@Nullable String predicate,
@Nullable String message)
@Nullable String predicate,
@Nullable String message)
{
super(formatMessage(predicate, message), recognizer, recognizer.getInputStream(), recognizer._ctx);
ATNState s = recognizer.getInterpreter().atn.states.get(recognizer.getState());
Expand Down
17 changes: 16 additions & 1 deletion tool/resources/org/antlr/v4/tool/templates/codegen/Java/Java.stg
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,21 @@ public <if(parser.abstractRecognizer)>abstract <endif>class <parser.name> extend
@Override
public String getSerializedATN() { return _serializedATN; }

@NotNull
private FailedPredicateException createFailedPredicateException() {
return createFailedPredicateException(null);
}

@NotNull
private FailedPredicateException createFailedPredicateException(@Nullable String predicate) {
return createFailedPredicateException(predicate, null);
}

@NotNull
protected FailedPredicateException createFailedPredicateException(@Nullable String predicate, @Nullable String message) {
return new FailedPredicateException(this, predicate, message);
}

<namedActions.members>
<parser:(ctor)()>
<funcs; separator="\n">
Expand Down Expand Up @@ -715,7 +730,7 @@ ArgAction(a, chunks) ::= "<chunks>"

SemPred(p, chunks, failChunks) ::= <<
setState(<p.stateNumber>);
if (!(<chunks>)) throw new FailedPredicateException(this, <p.predicate><if(failChunks)>, <failChunks><elseif(p.msg)>, <p.msg><endif>);
if (!(<chunks>)) throw createFailedPredicateException(<p.predicate><if(failChunks)>, <failChunks><elseif(p.msg)>, <p.msg><endif>);
>>

ExceptionClause(e, catchArg, catchAction) ::= <<
Expand Down

0 comments on commit 269c382

Please sign in to comment.