Skip to content

Commit ae8723f

Browse files
committed
Merge branch 'next' of https://github.com/rubberduck-vba/Rubberduck into BugBlipper
2 parents 29ca75c + 789cecb commit ae8723f

File tree

8 files changed

+26291
-28667
lines changed

8 files changed

+26291
-28667
lines changed

RetailCoder.VBE/AutoSave/AutoSave.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ public AutoSave(VBE vbe, IGeneralConfigService configService)
2424

2525
_configService.SettingsChanged += ConfigServiceSettingsChanged;
2626

27-
_timer.Enabled = _config.UserSettings.GeneralSettings.AutoSaveEnabled;
28-
_timer.Interval = _config.UserSettings.GeneralSettings.AutoSavePeriod * 1000;
27+
_timer.Enabled = _config.UserSettings.GeneralSettings.AutoSaveEnabled
28+
&& _config.UserSettings.GeneralSettings.AutoSavePeriod != 0;
2929

30-
_timer.Elapsed += _timer_Elapsed;
30+
if (_config.UserSettings.GeneralSettings.AutoSavePeriod != 0)
31+
{
32+
_timer.Interval = _config.UserSettings.GeneralSettings.AutoSavePeriod * 1000;
33+
_timer.Elapsed += _timer_Elapsed;
34+
}
3135
}
3236

3337
void ConfigServiceSettingsChanged(object sender, EventArgs e)

Rubberduck.Parsing/Grammar/VBA.g4

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
* 1. Preprocessor statements (#if, #else, ...) must not interfere with regular
4040
* statements.
4141
*
42-
* 2. Comments are skipped.
43-
*
44-
*
4542
* Change log:
4643
*
4744
* v1.4 Rubberduck
@@ -75,6 +72,8 @@
7572
* - optional parameters can be a valueStmt.
7673
* - added support for Octal and Currency literals.
7774
* - implemented proper specs for DATELITERAL.
75+
* - added comments to parse tree (removes known limitation #2).
76+
* - macroConstStmt now allowed in blockStmt.
7877
*
7978
*======================================================================================
8079
*
@@ -98,13 +97,14 @@ grammar VBA;
9897
startRule : module EOF;
9998

10099
module :
100+
WS?
101101
endOfLine*
102102
(moduleHeader endOfLine*)?
103103
moduleConfig? endOfLine*
104104
moduleAttributes? endOfLine*
105105
moduleDeclarations? endOfLine*
106106
moduleBody? endOfLine*
107-
endOfLine*
107+
WS?
108108
;
109109

110110
moduleHeader : VERSION WS DOUBLELITERAL WS CLASS;
@@ -121,13 +121,13 @@ moduleConfigElement :
121121

122122
moduleAttributes : (attributeStmt endOfLine+)+;
123123

124-
moduleDeclarations : moduleDeclarationsElement (endOfLine+ moduleDeclarationsElement)*;
124+
moduleDeclarations : moduleDeclarationsElement (endOfLine+ moduleDeclarationsElement)* endOfLine*;
125125

126126
moduleOption :
127-
OPTION_BASE WS? SHORTLITERAL # optionBaseStmt
128-
| OPTION_COMPARE WS? (BINARY | TEXT | DATABASE) # optionCompareStmt
129-
| OPTION_EXPLICIT # optionExplicitStmt
130-
| OPTION_PRIVATE_MODULE # optionPrivateModuleStmt
127+
OPTION_BASE WS SHORTLITERAL # optionBaseStmt
128+
| OPTION_COMPARE WS (BINARY | TEXT | DATABASE) # optionCompareStmt
129+
| OPTION_EXPLICIT # optionExplicitStmt
130+
| OPTION_PRIVATE_MODULE # optionPrivateModuleStmt
131131
;
132132

133133
moduleDeclarationsElement :
@@ -138,23 +138,25 @@ moduleDeclarationsElement :
138138
| constStmt
139139
| implementsStmt
140140
| variableStmt
141-
| macroConstStmt
142-
| macroIfThenElseStmt
143141
| moduleOption
144142
| typeStmt
143+
| macroStmt
145144
;
146145

146+
macroStmt :
147+
macroConstStmt
148+
| macroIfThenElseStmt;
149+
147150
moduleBody :
148-
moduleBodyElement (endOfStatement moduleBodyElement)* endOfStatement;
151+
moduleBodyElement (endOfLine+ moduleBodyElement)* endOfLine*;
149152

150153
moduleBodyElement :
151154
functionStmt
152-
| macroIfThenElseStmt
153-
| macroConstStmt
154155
| propertyGetStmt
155156
| propertySetStmt
156157
| propertyLetStmt
157158
| subStmt
159+
| macroStmt
158160
;
159161

160162

@@ -197,7 +199,7 @@ blockStmt :
197199
| loadStmt
198200
| lockStmt
199201
| lsetStmt
200-
| macroIfThenElseStmt
202+
| macroStmt
201203
| midStmt
202204
| mkdirStmt
203205
| nameStmt
@@ -368,17 +370,17 @@ macroIfThenElseStmt : macroIfBlockStmt macroElseIfBlockStmt* macroElseBlockStmt?
368370

369371
macroIfBlockStmt :
370372
MACRO_IF WS? ifConditionStmt WS THEN endOfStatement
371-
((moduleDeclarationsElement | moduleBody | block) endOfStatement)*
373+
(moduleDeclarations | moduleBody | block)*
372374
;
373375

374376
macroElseIfBlockStmt :
375377
MACRO_ELSEIF WS? ifConditionStmt WS THEN endOfStatement
376-
((moduleDeclarationsElement | moduleBody | block) endOfStatement)*
378+
(moduleDeclarations | moduleBody | block)*
377379
;
378380

379381
macroElseBlockStmt :
380382
MACRO_ELSE endOfStatement
381-
((moduleDeclarationsElement | moduleBody | block) endOfStatement)*
383+
(moduleDeclarations | moduleBody | block)*
382384
;
383385

384386
midStmt : MID WS? LPAREN WS? argsCall WS? RPAREN;
@@ -809,11 +811,11 @@ LOCK_READ : L O C K WS R E A D;
809811
LOCK_WRITE : L O C K WS W R I T E;
810812
LOCK_READ_WRITE : L O C K WS R E A D WS W R I T E;
811813
LSET : L S E T;
812-
MACRO_CONST : '#' C O N S T WS;
813-
MACRO_IF : '#' I F WS;
814-
MACRO_ELSEIF : '#' E L S E I F WS;
815-
MACRO_ELSE : '#' E L S E NEWLINE;
816-
MACRO_END_IF : '#' E N D WS I F NEWLINE;
814+
MACRO_CONST : '#' C O N S T;
815+
MACRO_IF : '#' I F;
816+
MACRO_ELSEIF : '#' E L S E I F;
817+
MACRO_ELSE : '#' E L S E;
818+
MACRO_END_IF : '#' E N D WS? I F;
817819
ME : M E;
818820
MID : M I D;
819821
MKDIR : M K D I R;
@@ -829,9 +831,9 @@ ON_ERROR : O N WS E R R O R;
829831
ON_LOCAL_ERROR : O N WS L O C A L WS E R R O R;
830832
OPEN : O P E N;
831833
OPTIONAL : O P T I O N A L;
832-
OPTION_BASE : O P T I O N WS B A S E WS;
834+
OPTION_BASE : O P T I O N WS B A S E;
833835
OPTION_EXPLICIT : O P T I O N WS E X P L I C I T;
834-
OPTION_COMPARE : O P T I O N WS C O M P A R E WS;
836+
OPTION_COMPARE : O P T I O N WS C O M P A R E;
835837
OPTION_PRIVATE_MODULE : O P T I O N WS P R I V A T E WS M O D U L E;
836838
OR : O R;
837839
OUTPUT : O U T P U T;
@@ -981,4 +983,4 @@ fragment V:('v'|'V');
981983
fragment W:('w'|'W');
982984
fragment X:('x'|'X');
983985
fragment Y:('y'|'Y');
984-
fragment Z:('z'|'Z');
986+
fragment Z:('z'|'Z');

0 commit comments

Comments
 (0)