-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major progress towards auto-completion & intelliSense #34
- Loading branch information
Showing
12 changed files
with
1,602 additions
and
1,229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,48 @@ | ||
import { DefaultErrorStrategy, Parser, ParserRuleContext, RecognitionException } from 'antlr4ts'; | ||
import { DefaultErrorStrategy, Parser, RecognitionException } from 'antlr4ts'; | ||
|
||
import { UCParser } from '../antlr/generated/UCParser'; | ||
|
||
export class UCMissingSemicolonException extends Error { | ||
constructor(private context: ParserRuleContext) { | ||
super(); | ||
} | ||
} | ||
|
||
export class UCErrorStrategy extends DefaultErrorStrategy { | ||
reportError(recognizer: Parser, e: RecognitionException) { | ||
if (e.expectedTokens && e.expectedTokens.contains(UCParser.SEMICOLON)) { | ||
const token = this.constructToken( | ||
recognizer.inputStream.tokenSource, | ||
UCParser.SEMICOLON, ';', | ||
recognizer.currentToken | ||
); | ||
reportError(recognizer: Parser, e: RecognitionException) { | ||
if (typeof e.expectedTokens === 'undefined') { | ||
super.reportError(recognizer, e); | ||
return; | ||
} | ||
|
||
if (e.expectedTokens.contains(UCParser.SEMICOLON)) { | ||
const token = this.constructToken( | ||
recognizer.inputStream.tokenSource, | ||
UCParser.SEMICOLON, ';', | ||
recognizer.currentToken | ||
); | ||
|
||
const errorNode = recognizer.createErrorNode(recognizer.context, token); | ||
recognizer.context.addErrorNode(errorNode); | ||
// } else if (e.expectedTokens.contains(UCParser.OPEN_PARENS)) { | ||
// const openToken = this.constructToken( | ||
// recognizer.inputStream.tokenSource, | ||
// UCParser.OPEN_PARENS, '(', | ||
// recognizer.currentToken | ||
// ); | ||
// recognizer.context.addErrorNode(recognizer.createErrorNode(recognizer.context, openToken)); | ||
|
||
const errorNode = recognizer.createErrorNode(recognizer.context, token); | ||
recognizer.context.addErrorNode(errorNode); | ||
} | ||
// const closeToken = this.constructToken( | ||
// recognizer.inputStream.tokenSource, | ||
// UCParser.CLOSE_PARENS, ')', | ||
// recognizer.currentToken | ||
// ); | ||
// recognizer.context.addErrorNode(recognizer.createErrorNode(recognizer.context, closeToken)); | ||
// } else if (e.expectedTokens.contains(UCParser.CLOSE_PARENS)) { | ||
// const closeToken = this.constructToken( | ||
// recognizer.inputStream.tokenSource, | ||
// UCParser.CLOSE_PARENS, ')', | ||
// recognizer.currentToken | ||
// ); | ||
// recognizer.context.addErrorNode(recognizer.createErrorNode(recognizer.context, closeToken)); | ||
} | ||
|
||
super.reportError(recognizer, e); | ||
} | ||
super.reportError(recognizer, e); | ||
} | ||
} | ||
|
||
export const ERROR_STRATEGY = new UCErrorStrategy(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.