Skip to content
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

Scale keyword in UDT as a member name is a parser error #4328

Closed
comintern opened this issue Aug 30, 2018 · 2 comments · Fixed by #4332
Closed

Scale keyword in UDT as a member name is a parser error #4328

comintern opened this issue Aug 30, 2018 · 2 comments · Fixed by #4332
Labels
bug Identifies work items for known bugs critical Marks a bug as a must-fix, showstopper issue parse-tree-processing regression This used to work, but something broke it. Fixes should involve a regression test, if possible

Comments

@comintern
Copy link
Contributor

Stumbled upon this while I was playing with a tagDEC struct:

Option Explicit

' https://docs.microsoft.com/en-us/windows/desktop/api/wtypes/ns-wtypes-tagdec
Private Type tagDec
    wReserved As Integer
    scale As Byte
    sign As Byte
    Hi32 As Long
    Lo64Lo As Long
    Lo64Hi As Long
End Type

The parser is choking on the scale member because it's a keyword.

Relevant log bit:

2018-08-30 11:16:07.1279;ERROR-2.2.0.3624;Rubberduck.Parsing.VBA.Parsing.ModuleParser;Syntax error; offending token 'scale' at line 6, column 5 in the CodePaneCode version of module Module1.;
2018-08-30 11:16:07.1279;DEBUG-2.2.0.3624;Rubberduck.Parsing.VBA.Parsing.ModuleParser;SyntaxErrorException thrown in thread 31, ParseTaskID a1d3ada6-85ce-4f61-98a9-30829356b3bf.;Rubberduck.Parsing.Symbols.ParsingExceptions.MainParseSyntaxErrorException: mismatched input 'scale' expecting END_TYPE ---> Antlr4.Runtime.InputMismatchException: Exception of type 'Antlr4.Runtime.InputMismatchException' was thrown.
   at Antlr4.Runtime.DefaultErrorStrategy.RecoverInline(Parser recognizer)
   at Antlr4.Runtime.Parser.Match(Int32 ttype)
   at Rubberduck.Parsing.Grammar.VBAParser.udtDeclaration() in C:\projects\rubberduck\Rubberduck.Parsing\obj\Release\VBAParser.cs:line 13232
   --- End of inner exception stack trace ---
   at Rubberduck.Parsing.Symbols.ParsingExceptions.MainParseExceptionErrorListener.SyntaxError(IRecognizer recognizer, IToken offendingSymbol, Int32 line, Int32 charPositionInLine, String msg, RecognitionException e) in C:\projects\rubberduck\Rubberduck.Parsing\Symbols\ParsingExceptions\MainParseExceptionErrorListener.cs:line 17
   at Antlr4.Runtime.ProxyErrorListener`1.SyntaxError(IRecognizer recognizer, Symbol offendingSymbol, Int32 line, Int32 charPositionInLine, String msg, RecognitionException e)
   at Antlr4.Runtime.Parser.NotifyErrorListeners(IToken offendingToken, String msg, RecognitionException e)
   at Antlr4.Runtime.DefaultErrorStrategy.NotifyErrorListeners(Parser recognizer, String message, RecognitionException e)
   at Antlr4.Runtime.DefaultErrorStrategy.ReportInputMismatch(Parser recognizer, InputMismatchException e)
   at Antlr4.Runtime.DefaultErrorStrategy.ReportError(Parser recognizer, RecognitionException e)
   at Rubberduck.Parsing.Grammar.VBAParser.udtDeclaration() in C:\projects\rubberduck\Rubberduck.Parsing\obj\Release\VBAParser.cs:line 13237
   at Rubberduck.Parsing.Grammar.VBAParser.moduleDeclarationsElement() in C:\projects\rubberduck\Rubberduck.Parsing\obj\Release\VBAParser.cs:line 2257
   at Rubberduck.Parsing.Grammar.VBAParser.moduleDeclarations() in C:\projects\rubberduck\Rubberduck.Parsing\obj\Release\VBAParser.cs:line 1945
   at Rubberduck.Parsing.Grammar.VBAParser.module() in C:\projects\rubberduck\Rubberduck.Parsing\obj\Release\VBAParser.cs:line 442
   at Rubberduck.Parsing.Grammar.VBAParser.startRule() in C:\projects\rubberduck\Rubberduck.Parsing\obj\Release\VBAParser.cs:line 332
   at Rubberduck.Parsing.VBA.Parsing.VBATokenStreamParser.Parse(ITokenStream tokenStream, PredictionMode predictionMode, IParserErrorListener errorListener) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\VBATokenStreamParser.cs:line 21
   at Rubberduck.Parsing.VBA.Parsing.TokenStreamParserBase.ParseSll(String moduleName, ITokenStream tokenStream, CodeKind codeKind) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\TokenStreamParserBase.cs:line 84
   at Rubberduck.Parsing.VBA.Parsing.TokenStreamParserBase.ParseWithFallBack(String moduleName, CommonTokenStream tokenStream, CodeKind codeKind) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\TokenStreamParserBase.cs:line 52
   at Rubberduck.Parsing.VBA.Parsing.TokenStreamParserBase.Parse(String moduleName, CommonTokenStream tokenStream, CodeKind codeKind, ParserMode parserMode) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\TokenStreamParserBase.cs:line 32
   at Rubberduck.Parsing.VBA.Parsing.TokenStreamParserStringParserAdapterWithPreprocessing.Parse(String moduleName, String projectId, String code, CancellationToken token, CodeKind codeKind, ParserMode parserMode) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\TokenStreamParserStringParserAdapterWithPreprocessing.cs:line 29
   at Rubberduck.Parsing.VBA.Parsing.ModuleParser.CodePanePassResults(QualifiedModuleName module, CancellationToken token, TokenStreamRewriter rewriter) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\ModuleParser.cs:line 167
   at Rubberduck.Parsing.VBA.Parsing.ModuleParser.ParseInternal(QualifiedModuleName module, CancellationToken cancellationToken, TokenStreamRewriter rewriter, Guid taskId) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\ModuleParser.cs:line 87
   at Rubberduck.Parsing.VBA.Parsing.ModuleParser.Parse(QualifiedModuleName module, CancellationToken cancellationToken, TokenStreamRewriter rewriter) in C:\projects\rubberduck\Rubberduck.Parsing\VBA\Parsing\ModuleParser.cs:line 43
Token: scale at L6C5
Kind of parsed code: CodePaneCode
Component: Module1 (code pane version)
ParseType: Main parse
@comintern
Copy link
Contributor Author

It also doesn't like Circle.

Public Type RoundThing
    Circle As Boolean
End Type

@MDoerner
Copy link
Contributor

The problem is that tokens for these keywords have been added to the lexer but not the keyword rule for the parser. This is why they are not picked up by the unrestrictedIdentifier parser rule.

@Vogel612 Vogel612 added bug Identifies work items for known bugs parse-tree-processing critical Marks a bug as a must-fix, showstopper issue regression This used to work, but something broke it. Fixes should involve a regression test, if possible labels Aug 30, 2018
@Vogel612 Vogel612 modified the milestone: 2.4.1 Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies work items for known bugs critical Marks a bug as a must-fix, showstopper issue parse-tree-processing regression This used to work, but something broke it. Fixes should involve a regression test, if possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants