Skip to content

Commit c534f26

Browse files
authored
Merge pull request #1799 from autoboosh/debugprintfix
Debug.Print fix
2 parents cf18f05 + 398a52b commit c534f26

13 files changed

+3757
-3199
lines changed

Rubberduck.Parsing/Grammar/VBAParser.cs

Lines changed: 3331 additions & 3092 deletions
Large diffs are not rendered by default.

Rubberduck.Parsing/Grammar/VBAParser.g4

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ fileStmt :
141141
| unlockStmt
142142
| lineInputStmt
143143
| widthStmt
144+
| debugPrintStmt
144145
| printStmt
145146
| writeStmt
146147
| inputStmt
@@ -211,7 +212,15 @@ widthStmt : WIDTH whiteSpace markedFileNumber whiteSpace? COMMA whiteSpace? line
211212
lineWidth : expression;
212213

213214

214-
// 5.4.5.8 Print Statement
215+
// 5.4.5.8 Print Statement
216+
// Debug.Print is special because it seems to take an output list as argument.
217+
// To shield the rest of the parsing/binding from this peculiarity, we treat it as a statement
218+
// and let the resolver handle it.
219+
debugPrintStmt : debugPrint (whiteSpace outputList)?;
220+
// We split it up into separate rules so that we have context classes generated that can be used in declarations/references.
221+
debugPrint : debugModule whiteSpace? DOT whiteSpace? debugPrintSub;
222+
debugModule : DEBUG;
223+
debugPrintSub : PRINT;
215224
printStmt : PRINT whiteSpace markedFileNumber whiteSpace? COMMA (whiteSpace? outputList)?;
216225

217226
// 5.4.5.8.1 Output Lists

Rubberduck.Parsing/Grammar/VBAParserBaseListener.cs

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162
@@ -176,6 +176,19 @@ public virtual void EnterFieldLength([NotNull] VBAParser.FieldLengthContext cont
176176
/// <param name="context">The parse tree.</param>
177177
public virtual void ExitFieldLength([NotNull] VBAParser.FieldLengthContext context) { }
178178

179+
/// <summary>
180+
/// Enter a parse tree produced by <see cref="VBAParser.debugModule"/>.
181+
/// <para>The default implementation does nothing.</para>
182+
/// </summary>
183+
/// <param name="context">The parse tree.</param>
184+
public virtual void EnterDebugModule([NotNull] VBAParser.DebugModuleContext context) { }
185+
/// <summary>
186+
/// Exit a parse tree produced by <see cref="VBAParser.debugModule"/>.
187+
/// <para>The default implementation does nothing.</para>
188+
/// </summary>
189+
/// <param name="context">The parse tree.</param>
190+
public virtual void ExitDebugModule([NotNull] VBAParser.DebugModuleContext context) { }
191+
179192
/// <summary>
180193
/// Enter a parse tree produced by <see cref="VBAParser.goSubStmt"/>.
181194
/// <para>The default implementation does nothing.</para>
@@ -1541,6 +1554,19 @@ public virtual void EnterCallStmt([NotNull] VBAParser.CallStmtContext context) {
15411554
/// <param name="context">The parse tree.</param>
15421555
public virtual void ExitCallStmt([NotNull] VBAParser.CallStmtContext context) { }
15431556

1557+
/// <summary>
1558+
/// Enter a parse tree produced by <see cref="VBAParser.debugPrintSub"/>.
1559+
/// <para>The default implementation does nothing.</para>
1560+
/// </summary>
1561+
/// <param name="context">The parse tree.</param>
1562+
public virtual void EnterDebugPrintSub([NotNull] VBAParser.DebugPrintSubContext context) { }
1563+
/// <summary>
1564+
/// Exit a parse tree produced by <see cref="VBAParser.debugPrintSub"/>.
1565+
/// <para>The default implementation does nothing.</para>
1566+
/// </summary>
1567+
/// <param name="context">The parse tree.</param>
1568+
public virtual void ExitDebugPrintSub([NotNull] VBAParser.DebugPrintSubContext context) { }
1569+
15441570
/// <summary>
15451571
/// Enter a parse tree produced by <see cref="VBAParser.enumerationStmt"/>.
15461572
/// <para>The default implementation does nothing.</para>
@@ -2152,6 +2178,19 @@ public virtual void EnterResumeStmt([NotNull] VBAParser.ResumeStmtContext contex
21522178
/// <param name="context">The parse tree.</param>
21532179
public virtual void ExitResumeStmt([NotNull] VBAParser.ResumeStmtContext context) { }
21542180

2181+
/// <summary>
2182+
/// Enter a parse tree produced by <see cref="VBAParser.debugPrint"/>.
2183+
/// <para>The default implementation does nothing.</para>
2184+
/// </summary>
2185+
/// <param name="context">The parse tree.</param>
2186+
public virtual void EnterDebugPrint([NotNull] VBAParser.DebugPrintContext context) { }
2187+
/// <summary>
2188+
/// Exit a parse tree produced by <see cref="VBAParser.debugPrint"/>.
2189+
/// <para>The default implementation does nothing.</para>
2190+
/// </summary>
2191+
/// <param name="context">The parse tree.</param>
2192+
public virtual void ExitDebugPrint([NotNull] VBAParser.DebugPrintContext context) { }
2193+
21552194
/// <summary>
21562195
/// Enter a parse tree produced by <see cref="VBAParser.endOfLine"/>.
21572196
/// <para>The default implementation does nothing.</para>
@@ -2659,6 +2698,19 @@ public virtual void EnterRaiseEventStmt([NotNull] VBAParser.RaiseEventStmtContex
26592698
/// <param name="context">The parse tree.</param>
26602699
public virtual void ExitRaiseEventStmt([NotNull] VBAParser.RaiseEventStmtContext context) { }
26612700

2701+
/// <summary>
2702+
/// Enter a parse tree produced by <see cref="VBAParser.debugPrintStmt"/>.
2703+
/// <para>The default implementation does nothing.</para>
2704+
/// </summary>
2705+
/// <param name="context">The parse tree.</param>
2706+
public virtual void EnterDebugPrintStmt([NotNull] VBAParser.DebugPrintStmtContext context) { }
2707+
/// <summary>
2708+
/// Exit a parse tree produced by <see cref="VBAParser.debugPrintStmt"/>.
2709+
/// <para>The default implementation does nothing.</para>
2710+
/// </summary>
2711+
/// <param name="context">The parse tree.</param>
2712+
public virtual void ExitDebugPrintStmt([NotNull] VBAParser.DebugPrintStmtContext context) { }
2713+
26622714
/// <summary>
26632715
/// Enter a parse tree produced by <see cref="VBAParser.sameLineStatement"/>.
26642716
/// <para>The default implementation does nothing.</para>

Rubberduck.Parsing/Grammar/VBAParserBaseVisitor.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162
@@ -153,6 +153,17 @@ public partial class VBAParserBaseVisitor<Result> : AbstractParseTreeVisitor<Res
153153
/// <return>The visitor result.</return>
154154
public virtual Result VisitFieldLength([NotNull] VBAParser.FieldLengthContext context) { return VisitChildren(context); }
155155

156+
/// <summary>
157+
/// Visit a parse tree produced by <see cref="VBAParser.debugModule"/>.
158+
/// <para>
159+
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
160+
/// on <paramref name="context"/>.
161+
/// </para>
162+
/// </summary>
163+
/// <param name="context">The parse tree.</param>
164+
/// <return>The visitor result.</return>
165+
public virtual Result VisitDebugModule([NotNull] VBAParser.DebugModuleContext context) { return VisitChildren(context); }
166+
156167
/// <summary>
157168
/// Visit a parse tree produced by <see cref="VBAParser.goSubStmt"/>.
158169
/// <para>
@@ -1308,6 +1319,17 @@ public partial class VBAParserBaseVisitor<Result> : AbstractParseTreeVisitor<Res
13081319
/// <return>The visitor result.</return>
13091320
public virtual Result VisitCallStmt([NotNull] VBAParser.CallStmtContext context) { return VisitChildren(context); }
13101321

1322+
/// <summary>
1323+
/// Visit a parse tree produced by <see cref="VBAParser.debugPrintSub"/>.
1324+
/// <para>
1325+
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
1326+
/// on <paramref name="context"/>.
1327+
/// </para>
1328+
/// </summary>
1329+
/// <param name="context">The parse tree.</param>
1330+
/// <return>The visitor result.</return>
1331+
public virtual Result VisitDebugPrintSub([NotNull] VBAParser.DebugPrintSubContext context) { return VisitChildren(context); }
1332+
13111333
/// <summary>
13121334
/// Visit a parse tree produced by <see cref="VBAParser.enumerationStmt"/>.
13131335
/// <para>
@@ -1825,6 +1847,17 @@ public partial class VBAParserBaseVisitor<Result> : AbstractParseTreeVisitor<Res
18251847
/// <return>The visitor result.</return>
18261848
public virtual Result VisitResumeStmt([NotNull] VBAParser.ResumeStmtContext context) { return VisitChildren(context); }
18271849

1850+
/// <summary>
1851+
/// Visit a parse tree produced by <see cref="VBAParser.debugPrint"/>.
1852+
/// <para>
1853+
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
1854+
/// on <paramref name="context"/>.
1855+
/// </para>
1856+
/// </summary>
1857+
/// <param name="context">The parse tree.</param>
1858+
/// <return>The visitor result.</return>
1859+
public virtual Result VisitDebugPrint([NotNull] VBAParser.DebugPrintContext context) { return VisitChildren(context); }
1860+
18281861
/// <summary>
18291862
/// Visit a parse tree produced by <see cref="VBAParser.endOfLine"/>.
18301863
/// <para>
@@ -2254,6 +2287,17 @@ public partial class VBAParserBaseVisitor<Result> : AbstractParseTreeVisitor<Res
22542287
/// <return>The visitor result.</return>
22552288
public virtual Result VisitRaiseEventStmt([NotNull] VBAParser.RaiseEventStmtContext context) { return VisitChildren(context); }
22562289

2290+
/// <summary>
2291+
/// Visit a parse tree produced by <see cref="VBAParser.debugPrintStmt"/>.
2292+
/// <para>
2293+
/// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
2294+
/// on <paramref name="context"/>.
2295+
/// </para>
2296+
/// </summary>
2297+
/// <param name="context">The parse tree.</param>
2298+
/// <return>The visitor result.</return>
2299+
public virtual Result VisitDebugPrintStmt([NotNull] VBAParser.DebugPrintStmtContext context) { return VisitChildren(context); }
2300+
22572301
/// <summary>
22582302
/// Visit a parse tree produced by <see cref="VBAParser.sameLineStatement"/>.
22592303
/// <para>

Rubberduck.Parsing/Grammar/VBAParserListener.cs

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162
@@ -152,6 +152,17 @@ public interface IVBAParserListener : IParseTreeListener {
152152
/// <param name="context">The parse tree.</param>
153153
void ExitFieldLength([NotNull] VBAParser.FieldLengthContext context);
154154

155+
/// <summary>
156+
/// Enter a parse tree produced by <see cref="VBAParser.debugModule"/>.
157+
/// </summary>
158+
/// <param name="context">The parse tree.</param>
159+
void EnterDebugModule([NotNull] VBAParser.DebugModuleContext context);
160+
/// <summary>
161+
/// Exit a parse tree produced by <see cref="VBAParser.debugModule"/>.
162+
/// </summary>
163+
/// <param name="context">The parse tree.</param>
164+
void ExitDebugModule([NotNull] VBAParser.DebugModuleContext context);
165+
155166
/// <summary>
156167
/// Enter a parse tree produced by <see cref="VBAParser.goSubStmt"/>.
157168
/// </summary>
@@ -1347,6 +1358,17 @@ public interface IVBAParserListener : IParseTreeListener {
13471358
/// <param name="context">The parse tree.</param>
13481359
void ExitCallStmt([NotNull] VBAParser.CallStmtContext context);
13491360

1361+
/// <summary>
1362+
/// Enter a parse tree produced by <see cref="VBAParser.debugPrintSub"/>.
1363+
/// </summary>
1364+
/// <param name="context">The parse tree.</param>
1365+
void EnterDebugPrintSub([NotNull] VBAParser.DebugPrintSubContext context);
1366+
/// <summary>
1367+
/// Exit a parse tree produced by <see cref="VBAParser.debugPrintSub"/>.
1368+
/// </summary>
1369+
/// <param name="context">The parse tree.</param>
1370+
void ExitDebugPrintSub([NotNull] VBAParser.DebugPrintSubContext context);
1371+
13501372
/// <summary>
13511373
/// Enter a parse tree produced by <see cref="VBAParser.enumerationStmt"/>.
13521374
/// </summary>
@@ -1874,6 +1896,17 @@ public interface IVBAParserListener : IParseTreeListener {
18741896
/// <param name="context">The parse tree.</param>
18751897
void ExitResumeStmt([NotNull] VBAParser.ResumeStmtContext context);
18761898

1899+
/// <summary>
1900+
/// Enter a parse tree produced by <see cref="VBAParser.debugPrint"/>.
1901+
/// </summary>
1902+
/// <param name="context">The parse tree.</param>
1903+
void EnterDebugPrint([NotNull] VBAParser.DebugPrintContext context);
1904+
/// <summary>
1905+
/// Exit a parse tree produced by <see cref="VBAParser.debugPrint"/>.
1906+
/// </summary>
1907+
/// <param name="context">The parse tree.</param>
1908+
void ExitDebugPrint([NotNull] VBAParser.DebugPrintContext context);
1909+
18771910
/// <summary>
18781911
/// Enter a parse tree produced by <see cref="VBAParser.endOfLine"/>.
18791912
/// </summary>
@@ -2313,6 +2346,17 @@ public interface IVBAParserListener : IParseTreeListener {
23132346
/// <param name="context">The parse tree.</param>
23142347
void ExitRaiseEventStmt([NotNull] VBAParser.RaiseEventStmtContext context);
23152348

2349+
/// <summary>
2350+
/// Enter a parse tree produced by <see cref="VBAParser.debugPrintStmt"/>.
2351+
/// </summary>
2352+
/// <param name="context">The parse tree.</param>
2353+
void EnterDebugPrintStmt([NotNull] VBAParser.DebugPrintStmtContext context);
2354+
/// <summary>
2355+
/// Exit a parse tree produced by <see cref="VBAParser.debugPrintStmt"/>.
2356+
/// </summary>
2357+
/// <param name="context">The parse tree.</param>
2358+
void ExitDebugPrintStmt([NotNull] VBAParser.DebugPrintStmtContext context);
2359+
23162360
/// <summary>
23172361
/// Enter a parse tree produced by <see cref="VBAParser.sameLineStatement"/>.
23182362
/// </summary>

Rubberduck.Parsing/Grammar/VBAParserVisitor.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// </auto-generated>
99
//------------------------------------------------------------------------------
1010

11-
// Generated from C:\Users\hosch\Documents\Visual Studio 2015\Projects\Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+
// Generated from C:\Users\Splinter\Documents\Visual Studio 2015\Projects\RubberduckParserTest\RubberduckParserTest\VBAParser.g4 by ANTLR 4.3
1212

1313
// Unreachable code detected
1414
#pragma warning disable 0162
@@ -108,6 +108,13 @@ public interface IVBAParserVisitor<Result> : IParseTreeVisitor<Result> {
108108
/// <return>The visitor result.</return>
109109
Result VisitFieldLength([NotNull] VBAParser.FieldLengthContext context);
110110

111+
/// <summary>
112+
/// Visit a parse tree produced by <see cref="VBAParser.debugModule"/>.
113+
/// </summary>
114+
/// <param name="context">The parse tree.</param>
115+
/// <return>The visitor result.</return>
116+
Result VisitDebugModule([NotNull] VBAParser.DebugModuleContext context);
117+
111118
/// <summary>
112119
/// Visit a parse tree produced by <see cref="VBAParser.goSubStmt"/>.
113120
/// </summary>
@@ -863,6 +870,13 @@ public interface IVBAParserVisitor<Result> : IParseTreeVisitor<Result> {
863870
/// <return>The visitor result.</return>
864871
Result VisitCallStmt([NotNull] VBAParser.CallStmtContext context);
865872

873+
/// <summary>
874+
/// Visit a parse tree produced by <see cref="VBAParser.debugPrintSub"/>.
875+
/// </summary>
876+
/// <param name="context">The parse tree.</param>
877+
/// <return>The visitor result.</return>
878+
Result VisitDebugPrintSub([NotNull] VBAParser.DebugPrintSubContext context);
879+
866880
/// <summary>
867881
/// Visit a parse tree produced by <see cref="VBAParser.enumerationStmt"/>.
868882
/// </summary>
@@ -1197,6 +1211,13 @@ public interface IVBAParserVisitor<Result> : IParseTreeVisitor<Result> {
11971211
/// <return>The visitor result.</return>
11981212
Result VisitResumeStmt([NotNull] VBAParser.ResumeStmtContext context);
11991213

1214+
/// <summary>
1215+
/// Visit a parse tree produced by <see cref="VBAParser.debugPrint"/>.
1216+
/// </summary>
1217+
/// <param name="context">The parse tree.</param>
1218+
/// <return>The visitor result.</return>
1219+
Result VisitDebugPrint([NotNull] VBAParser.DebugPrintContext context);
1220+
12001221
/// <summary>
12011222
/// Visit a parse tree produced by <see cref="VBAParser.endOfLine"/>.
12021223
/// </summary>
@@ -1475,6 +1496,13 @@ public interface IVBAParserVisitor<Result> : IParseTreeVisitor<Result> {
14751496
/// <return>The visitor result.</return>
14761497
Result VisitRaiseEventStmt([NotNull] VBAParser.RaiseEventStmtContext context);
14771498

1499+
/// <summary>
1500+
/// Visit a parse tree produced by <see cref="VBAParser.debugPrintStmt"/>.
1501+
/// </summary>
1502+
/// <param name="context">The parse tree.</param>
1503+
/// <return>The visitor result.</return>
1504+
Result VisitDebugPrintStmt([NotNull] VBAParser.DebugPrintStmtContext context);
1505+
14781506
/// <summary>
14791507
/// Visit a parse tree produced by <see cref="VBAParser.sameLineStatement"/>.
14801508
/// </summary>

Rubberduck.Parsing/Rubberduck.Parsing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
<Compile Include="Symbols\ComInformation.cs" />
133133
<Compile Include="Symbols\CommentNode.cs" />
134134
<Compile Include="Symbols\ComParameter.cs" />
135+
<Compile Include="Symbols\CustomDeclarations.cs" />
135136
<Compile Include="Symbols\Identifier.cs" />
136137
<Compile Include="Binding\IBindingContext.cs" />
137138
<Compile Include="Binding\IBoundExpression.cs" />

0 commit comments

Comments
 (0)