1- import { ANTLRErrorListener , ANTLRInputStream , CommonTokenStream , ConsoleErrorListener , DefaultErrorStrategy , Parser , ParserRuleContext , RecognitionException , Recognizer } from 'antlr4ts' ;
1+ import { ANTLRInputStream , CommonTokenStream , ConsoleErrorListener , RecognitionException , Recognizer } from 'antlr4ts' ;
22import { TextDocument } from 'vscode-languageserver-textdocument' ;
33import { vbaListener } from '../antlr/out/vbaListener' ;
4- import { AttributeStmtContext , CommentContext , ConstStmtContext , EndOfLineContext , EnumerationStmtContext , EnumerationStmt_ConstantContext , ErrorStmtContext , ErrorWordsContext , FunctionStmtContext , ImplicitCallStmt_InBlockContext , ImplicitCallStmt_InStmtContext , LetStmtContext , ModuleContext , ModuleHeaderContext , SetStmtContext , StartRuleContext , SubStmtContext , VariableStmtContext , vbaParser } from '../antlr/out/vbaParser' ;
4+ import { AttributeStmtContext , ConstStmtContext , EnumerationStmtContext , EnumerationStmt_ConstantContext , FunctionStmtContext , ImplicitCallStmt_InBlockContext , ImplicitCallStmt_InStmtContext , LetStmtContext , ModuleContext , ModuleHeaderContext , SetStmtContext , StartRuleContext , SubStmtContext , UnknownLineContext , VariableStmtContext , vbaParser } from '../antlr/out/vbaParser' ;
55import { vbaLexer as VbaLexer } from '../antlr/out/vbaLexer' ;
66import { ParseTreeWalker } from 'antlr4ts/tree/ParseTreeWalker' ;
77import { ErrorNode } from 'antlr4ts/tree/ErrorNode' ;
88import { MethodElement , ModuleAttribute , ModuleElement , SyntaxElement , EnumElement , EnumConstant as EnumConstantElement , VariableStatementElement , IdentifierElement , VariableAssignElement , VariableDeclarationElement } from './vbaSyntaxElements' ;
99import { SymbolKind } from 'vscode-languageserver' ;
10- import { basename } from 'path' ;
1110
1211
1312export interface ResultsContainer {
@@ -25,8 +24,6 @@ export class SyntaxParser {
2524 const listener = new VbaTreeWalkListener ( doc , resultsContainer ) ;
2625 const parserEntry = this . getParseEntryPoint ( doc ) ;
2726
28- console . log ( listener . doc . uri ) ;
29- console . log ( parserEntry . toString ( ) ) ;
3027 ParseTreeWalker . DEFAULT . walk (
3128 listener ,
3229 parserEntry
@@ -39,8 +36,6 @@ export class SyntaxParser {
3936
4037 parser . removeErrorListeners ( ) ;
4138 parser . addErrorListener ( new VbaErrorListener ( ) ) ;
42-
43-
4439 return parser . startRule ( ) ;
4540 }
4641}
@@ -54,20 +49,14 @@ class VbaTreeWalkListener implements vbaListener {
5449 this . resultsContainer = resultsContainer ;
5550 }
5651
57- enterErrorWords ( ctx : ErrorWordsContext ) {
58- console . log ( `${ ctx . text } ` ) ;
59- }
60-
61- // TODO: Implement this.
6252 visitErrorNode ( node : ErrorNode ) {
63- console . log ( ` ${ node . symbol . toString ( ) } -- ${ node . text } ` ) ;
53+ console . log ( node . payload ) ;
6454 }
6555
66- enterComment = ( ctx : CommentContext ) => {
56+ enterUnknownLine = ( ctx : UnknownLineContext ) => {
6757 console . log ( ctx . text ) ;
6858 } ;
6959
70-
7160 enterModule = ( ctx : ModuleContext ) =>
7261 this . resultsContainer . addModule (
7362 new ModuleElement ( ctx , this . doc ) ) ;
0 commit comments