rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.92k stars 302 forks source link

Incorrect grammar of lineSpecialForm #4945

Closed luelista closed 5 years ago

luelista commented 5 years ago

Rubberduck version information The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:

Rubberduck version 2.4.1.4627
Operating System: Windows 10
Host Product: VB6 IDE

Description The following syntax causes a parse error from rubberduck, but is valid VB6 (optional Color is left off, but "B" option is given).

Form1.Line (xStart, yStart)-(xs, ys), , B

The MSDN spec of the Line Method is like this:

object.Line [Step] (x1, y1) [Step] - (x2,y2), [color], [B][F]

The grammar of the lineSpecialForm seems to be slightly off.

https://github.com/rubberduck-vba/Rubberduck/blob/master/Rubberduck.Parsing/Grammar/VBAParser.g4#L574

lineSpecialForm : expression whiteSpace ((STEP whiteSpace?)? tuple)? MINUS (STEP whiteSpace?)? tuple whiteSpace? (COMMA whiteSpace? expression)? whiteSpace? (COMMA whiteSpace? lineSpecialFormOption)?;

I think the correct grammer would be:

lineSpecialForm : expression whiteSpace ((STEP whiteSpace?)? tuple)? MINUS (STEP whiteSpace?)? tuple whiteSpace? (COMMA whiteSpace? expression? whiteSpace? (COMMA whiteSpace? lineSpecialFormOption)?)?;

Logfile

Excerpt from the log file when trying to parse above code:

2019-05-03 22:27:25.6284;WARN-2.4.1.4627;Rubberduck.Parsing.VBA.Parsing.TokenStreamParserBase;SLL mode failed while parsing the CodePaneCode version of module Form1 at symbol , at L134C45. Retrying using LL.; 2019-05-03 22:27:26.0391;ERROR-2.4.1.4627;Rubberduck.Parsing.VBA.Parsing.ModuleParser;Syntax error; offending token ';' at line 146, column 29 in the CodePaneCode version of module app_printer.; 2019-05-03 22:27:26.0391;INFO-2.4.1.4627;Rubberduck.Parsing.VBA.RubberduckParserState;RubberduckParserState (20) is invoking StateChanged (Error); 2019-05-03 22:27:26.3050;ERROR-2.4.1.4627;Rubberduck.Parsing.VBA.Parsing.ModuleParser;Syntax error; offending token ',' at line 134, column 45 in the CodePaneCode version of module Form1.;

retailcoder commented 5 years ago

Linking #4875; PR #4884 fixed this bug last month; please try the latest pre-release build & confirm. Thanks!

retailcoder commented 5 years ago

Confirmed successful parse with 2.4.1.4647; closing as fixed. Thanks for the report! We will be releasing 2.4.2 soon, just a few more wrinkles need ironing. :smiley:

luelista commented 5 years ago

Ah thanks, I should've searched the closed issues as well...