weixin_39727005
weixin_39727005
2020-12-30 05:46

Very very Long parsed error messages curses again! :)

Thought to test out on latest pre-release version. Turns out the nearly as dup of my #936, maybe #861. Location of code provided. As per my Logs.


2017-07-29 15:44:11.7046;TRACE-2.0.14.36183;Rubberduck.Common.LogLevelHelper;
    Rubberduck version 2.0.14.36183 loading:
    Operating System: Microsoft Windows NT 6.2.9200.0 x64
    Host Product: Microsoft Office 2010 x86
    Host Version: 14.0.7183.5000
    Host Executable: EXCEL.EXE;
2017-07-29 15:45:14.2140;WARN-2.0.14.36183;Rubberduck.Parsing.VBA.ComponentParseTask;Syntax error; offending token 'End Sub' at line 36, column 1 in module VBAProject.cRoadmapItemForm.;
2017-07-29 15:45:14.2210;ERROR-2.0.14.36183;Rubberduck.Parsing.VBA.ComponentParseTask;Exception thrown in thread 6, ParseTaskID 384ee96d-ee1a-4feb-97ad-8bcc30e0b76d.;Rubberduck.Parsing.Symbols.SyntaxErrorException: extraneous input 'End Sub' expecting {ABS, ANY, ARRAY, B_CHAR, BF, CBOOL, CBYTE, CCUR, CDATE, CDBL, CDEC, CINT, CIRCLE, CLNG, CLNGLNG, CLNGPTR, CSNG, CSTR, CURRENCY, CVAR, CVERR, DEBUG, DOEVENTS, EXIT, FIX, INPUTB, INT, LBOUND, LEN, LENB, LONGLONG, LONGPTR, MIDB, OPTION, PSET, SCALE, SGN, UBOUND, ':', '!', '.', '#', ACCESS, ADDRESSOF, ALIAS, AND, ATTRIBUTE, APPEND, AS, BEGIN, BINARY, BOOLEAN, BYVAL, BYREF, BYTE, CALL, CASE, CLASS, CLOSE, CONST, DATABASE, DATE, DECLARE, DEFBOOL, DEFBYTE, DEFDATE, DEFDBL, DEFCUR, DEFINT, DEFLNG, DEFLNGLNG, DEFLNGPTR, DEFOBJ, DEFSNG, DEFSTR, DEFVAR, DIM, DO, DOUBLE, ELSE, ELSEIF, EMPTY, END_PROPERTY, END_SELECT, END_WITH, END, ENUM, EQV, ERASE, ERROR, EVENT, EXIT_DO, EXIT_FOR, EXIT_FUNCTION, EXIT_PROPERTY, EXIT_SUB, FALSE, FRIEND, FOR, FUNCTION, GET, GLOBAL, GOSUB, GOTO, IF, IMP, IMPLEMENTS, IN, INPUT, IS, INTEGER, LOCK, LONG, LOOP, LET, LIB, LIKE, LINE_INPUT, LOCK_READ, LOCK_WRITE, LOCK_READ_WRITE, LSET, ME, MID, MOD, NAME, NEXT, NEW, NOT, NOTHING, NULL, OBJECT, ON, ON_ERROR, ON_LOCAL_ERROR, OPEN, OPTIONAL, OR, OUTPUT, PARAMARRAY, PRESERVE, PRINT, PRIVATE, PTRSAFE, PUBLIC, PUT, RANDOM, RAISEEVENT, READ, READ_WRITE, REDIM, REM, RESET, RESUME, RETURN, RSET, SEEK, SELECT, SET, SHARED, SINGLE, SPC, STATIC, STEP, STOP, STRING, SUB, TAB, TEXT, THEN, TO, TRUE, TYPE, TYPEOF, UNLOCK, UNTIL, VARIANT, VERSION, WEND, WHILE, WIDTH, WITH, WITHEVENTS, WRITE, XOR, '(', '-', '[', STRINGLITERAL, OCTLITERAL, HEXLITERAL, FLOATLITERAL, INTEGERLITERAL, DATELITERAL, NEWLINE, ''', WS, IDENTIFIER, LINE_CONTINUATION}
   at Rubberduck.Parsing.Symbols.ExceptionErrorListener.SyntaxError(IRecognizer recognizer, IToken offendingSymbol, Int32 line, Int32 charPositionInLine, String msg, RecognitionException e) in C:\projects\rubberduck\Rubberduck.Parsing\Symbols\ExceptionErrorListener.cs:line 10
   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.ReportUnwantedToken(Parser recognizer)
   at Antlr4.Runtime.DefaultErrorStrategy.Sync(Parser recognizer)

capture rd prerelease v2 1 2010

RubberduckLog - RD 2.1.2010 crash.txt

该提问来源于开源项目:rubberduck-vba/Rubberduck

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

10条回答

  • weixin_40007016 weixin_40007016 4月前

    hmm ... what about the code above:

    
    Public Property Get uForm()  As ItemDetail
        Set uForm = ItemDetail
    End Sub
    

    ??

    this seems more likely to be the cause of the error, since I'd expect the parser to correctly log the unexpected token...

    点赞 评论 复制链接分享
  • weixin_39538877 weixin_39538877 4月前

    File is availabe for download at http://ramblings.mcpher.com/Home/excelquirks/downlable-items/cDataSet.xlsm?attredirects=0&d=1

    Type ItemDetail is a UserForm.

    What is strange is if I change the return type of uForm

    vb
    Public Property Get uForm() As Object 'ItemDetail
        Set uForm = ItemDetail
    End Sub
    

    Then the Parse Error goes away (and there is then a Resolver Error, the cause of which I'm uncertain), but if I change the return type back to ItemDetail and reparse, I don't encounter the Parse Error again, but the Resolver Error remains.

    点赞 评论 复制链接分享
  • weixin_39538877 weixin_39538877 4月前

    hmm, could it because the ItemDetail UserForm doesn't have a code module?

    点赞 评论 复制链接分享
  • weixin_39518530 weixin_39518530 4月前

    Because we do not offset the errors from the attributes pass so far, the position of the error always refers to the exported module, which has 8 additional lines on top in this case.

    The parser error is actually very simple: our grammar expects a Property to end in End Property, not in End Sub. For some obscure reason, the VBE does not care.

    When you change the return type, the VBE auto-corrects End Sub to End Property.

    I still have to have a look at the resolver error.

    点赞 评论 复制链接分享
  • weixin_39538877 weixin_39538877 4月前

    Ah, I didn't even notice the End Sub

    点赞 评论 复制链接分享
  • weixin_39518530 weixin_39518530 4月前

    The number of possibilities listed in the parser error is so large, because we fail immediately on an error and do not let Antlr try to recover. So, it does not include any code beyond the point of error into its consideration what might be needed next. Since the error happens while being inside a property, any token you could start a statement with is legal; there are a lot of those.

    When I tried to get a parse tree using Antlr 4.6 in Eclipse, where I did not deactivate error recovery, I also got an error, but it was simply stating 'END_PROPERTY expected`.

    点赞 评论 复制链接分享
  • weixin_39518530 weixin_39518530 4月前

    I just wanted to look into the resolver error. However, after changing End Sub to End Property, I do not get any errors.

    点赞 评论 复制链接分享
  • weixin_39518530 weixin_39518530 4月前

    I do not think we can use the results of parsing a module with parser errors. However, letting Antlr try to recover might increase the usefulness of the error messages we produce: it considers the further input to narrow down the possibilities.

    点赞 评论 复制链接分享
  • weixin_39629093 weixin_39629093 4月前

    Closing as by-design, since Public Property / End Sub isn't intended to parse correctly (despite the VBE not caring much).

    点赞 评论 复制链接分享
  • weixin_39727005 weixin_39727005 4月前

    Just recording here that I was able to repro this problem with the latest version 2.1.0.02147 but once fixing the End Sub to become End Property at that point I got 517 inspections going which I can work on slowly. Nice! 👍

    点赞 评论 复制链接分享

相关推荐