-
Notifications
You must be signed in to change notification settings - Fork 35
Improve Syntax Errors #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
d019952
6ba2124
48a5de5
c365e74
e895d71
0f5e5d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,16 +35,12 @@ public static GhostDTO getGhostDeclaration(String s) throws LJError { | |
| ParseTree rc = compile(s); | ||
| GhostDTO g = GhostVisitor.getGhostDecl(rc); | ||
| if (g == null) | ||
| throw new SyntaxError("Ghost declarations should be in format <type> <name> (<parameters>)", s); | ||
| throw new SyntaxError("Invalid ghost declaration, e.g. \"int size\"", s); | ||
| return g; | ||
| } | ||
|
|
||
| public static AliasDTO getAliasDeclaration(String s) throws LJError { | ||
| Optional<String> os = getErrors(s); | ||
| if (os.isPresent()) | ||
| throw new SyntaxError(os.get(), s); | ||
| CodePointCharStream input; | ||
| input = CharStreams.fromString(s); | ||
| CodePointCharStream input = CharStreams.fromString(s); | ||
| RJErrorListener err = new RJErrorListener(); | ||
| RJLexer lexer = new RJLexer(input); | ||
| lexer.removeErrorListeners(); | ||
|
|
@@ -60,14 +56,14 @@ public static AliasDTO getAliasDeclaration(String s) throws LJError { | |
| AliasVisitor av = new AliasVisitor(input); | ||
| AliasDTO alias = av.getAlias(rc); | ||
| if (alias == null) | ||
| throw new SyntaxError("Alias definitions should be in format <name>(<parameters>) { <definition> }", s); | ||
| throw new SyntaxError("Invalid alias definition, e.g. \"Positive(int v) { v >= 0 }\"", s); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets include the whole alias reference like |
||
| return alias; | ||
| } | ||
|
|
||
| private static ParseTree compile(String toParse) throws LJError { | ||
| Optional<String> s = getErrors(toParse); | ||
| if (s.isPresent()) | ||
| throw new SyntaxError(s.get(), toParse); | ||
| throw new SyntaxError("Invalid refinement expression, e.g. \"v > 0\"", toParse); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The example in the PR confused me, I was thinking "why would i need to write v instead of x"? We have to be careful, so it isn't more confusing than helpful. |
||
|
|
||
| CodePointCharStream input = CharStreams.fromString(toParse); | ||
| RJErrorListener err = new RJErrorListener(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets include the whole alias reference like
@Ghost("int size")to ensure that it is perceptible