Skip to content

Commit 9e88a71

Browse files
committed
Merge pull request #1170 from autoboosh/interpreter
Preprocessor for Rubberduck (#1132)
2 parents c06ef2e + e7a055e commit 9e88a71

File tree

134 files changed

+44086
-27651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+44086
-27651
lines changed

Rubberduck.Parsing/Grammar/VBA.g4

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,16 @@ moduleOption :
5858
;
5959

6060
moduleDeclarationsElement :
61-
comment
62-
| declareStmt
61+
declareStmt
6362
| enumerationStmt
6463
| eventStmt
6564
| constStmt
6665
| implementsStmt
6766
| variableStmt
6867
| moduleOption
6968
| typeStmt
70-
| macroStmt
7169
;
7270

73-
macroStmt :
74-
macroConstStmt
75-
| macroIfThenElseStmt;
76-
7771
moduleBody :
7872
moduleBodyElement (endOfStatement moduleBodyElement)* endOfStatement;
7973

@@ -83,7 +77,6 @@ moduleBodyElement :
8377
| propertySetStmt
8478
| propertyLetStmt
8579
| subStmt
86-
| macroStmt
8780
;
8881

8982

@@ -126,7 +119,6 @@ blockStmt :
126119
| loadStmt
127120
| lockStmt
128121
| lsetStmt
129-
| macroStmt
130122
| midStmt
131123
| mkdirStmt
132124
| nameStmt
@@ -291,25 +283,6 @@ lockStmt : LOCK WS valueStmt (WS? ',' WS? valueStmt (WS TO WS valueStmt)?)?;
291283

292284
lsetStmt : LSET WS implicitCallStmt_InStmt WS? EQ WS? valueStmt;
293285

294-
macroConstStmt : MACRO_CONST WS? ambiguousIdentifier WS? EQ WS? valueStmt;
295-
296-
macroIfThenElseStmt : macroIfBlockStmt macroElseIfBlockStmt* macroElseBlockStmt? MACRO_END_IF;
297-
298-
macroIfBlockStmt :
299-
MACRO_IF WS? ifConditionStmt WS THEN endOfStatement
300-
(moduleDeclarations | moduleBody | block)*
301-
;
302-
303-
macroElseIfBlockStmt :
304-
MACRO_ELSEIF WS? ifConditionStmt WS THEN endOfStatement
305-
(moduleDeclarations | moduleBody | block)*
306-
;
307-
308-
macroElseBlockStmt :
309-
MACRO_ELSE endOfStatement
310-
(moduleDeclarations | moduleBody | block)*
311-
;
312-
313286
midStmt : MID WS? LPAREN WS? argsCall WS? RPAREN;
314287

315288
mkdirStmt : MKDIR WS valueStmt;
@@ -585,7 +558,7 @@ letterrange : certainIdentifier (WS? MINUS WS? certainIdentifier)?;
585558

586559
lineLabel : ambiguousIdentifier ':';
587560

588-
literal : HEXLITERAL | OCTLITERAL | DATELITERAL | DOUBLELITERAL | INTEGERLITERAL | SHORTLITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL;
561+
literal : HEXLITERAL | OCTLITERAL | DATELITERAL | DOUBLELITERAL | INTEGERLITERAL | SHORTLITERAL | STRINGLITERAL | TRUE | FALSE | NOTHING | NULL | EMPTY;
589562

590563
type : (baseType | complexType) (WS? LPAREN WS? RPAREN)?;
591564

@@ -676,6 +649,7 @@ DOUBLE : D O U B L E;
676649
EACH : E A C H;
677650
ELSE : E L S E;
678651
ELSEIF : E L S E I F;
652+
EMPTY : E M P T Y;
679653
END_ENUM : E N D WS E N U M;
680654
END_FUNCTION : E N D WS F U N C T I O N;
681655
END_IF : E N D WS I F;
@@ -725,11 +699,6 @@ LOCK_READ : L O C K WS R E A D;
725699
LOCK_WRITE : L O C K WS W R I T E;
726700
LOCK_READ_WRITE : L O C K WS R E A D WS W R I T E;
727701
LSET : L S E T;
728-
MACRO_CONST : '#' C O N S T;
729-
MACRO_IF : '#' I F;
730-
MACRO_ELSEIF : '#' E L S E I F;
731-
MACRO_ELSE : '#' E L S E;
732-
MACRO_END_IF : '#' E N D WS? I F;
733702
ME : M E;
734703
MID : M I D;
735704
MKDIR : M K D I R;
@@ -845,12 +814,36 @@ fragment DATEVALUE : DATEVALUEPART DATESEPARATOR DATEVALUEPART (DATESEPARATOR DA
845814
fragment DATEVALUEPART : DIGIT+ | MONTHNAME;
846815
fragment DATESEPARATOR : WS? [/,-]? WS?;
847816
fragment MONTHNAME : ENGLISHMONTHNAME | ENGLISHMONTHABBREVIATION;
848-
fragment ENGLISHMONTHNAME : J A N U A R Y | F E B R U A R Y | M A R C H | A P R I L | M A Y | J U N E | A U G U S T | S E P T E M B E R | O C T O B E R | N O V E M B E R | D E C E M B E R;
849-
fragment ENGLISHMONTHABBREVIATION : J A N | F E B | M A R | A P R | J U N | J U L | A U G | S E P | O C T | N O V | D E C;
817+
fragment ENGLISHMONTHNAME : JANUARY | FEBRUARY | MARCH | APRIL | MAY | JUNE | JULY | AUGUST | SEPTEMBER | OCTOBER | NOVEMBER | DECEMBER;
818+
fragment ENGLISHMONTHABBREVIATION : JAN | FEB | MAR | APR | JUN | JUL | AUG | SEP | OCT | NOV | DEC;
850819
fragment TIMEVALUE : DIGIT+ AMPM | DIGIT+ TIMESEPARATOR DIGIT+ (TIMESEPARATOR DIGIT+)? AMPM?;
851820
fragment TIMESEPARATOR : WS? (':' | '.') WS?;
852821
fragment AMPM : WS? (A M | P M | A | P);
853822
823+
JANUARY : J A N U A R Y;
824+
FEBRUARY : F E B R U A R Y;
825+
MARCH : M A R C H;
826+
APRIL : A P R I L;
827+
MAY : M A Y;
828+
JUNE : J U N E;
829+
JULY : J U L Y;
830+
AUGUST : A U G U S T;
831+
SEPTEMBER : S E P T E M B E R;
832+
OCTOBER : O C T O B E R;
833+
NOVEMBER : N O V E M B E R;
834+
DECEMBER : D E C E M B E R;
835+
JAN : J A N;
836+
FEB : F E B;
837+
MAR: M A R;
838+
APR : A P R;
839+
JUN : J U N;
840+
JUL: J U L;
841+
AUG : A U G;
842+
SEP : S E P;
843+
OCT : O C T;
844+
NOV : N O V;
845+
DEC : D E C;
846+
854847
// whitespace, line breaks, comments, ...
855848
LINE_CONTINUATION : [ \t]+ UNDERSCORE '\r'? '\n' -> skip;
856849
NEWLINE : [\r\n\u2028\u2029]+;

0 commit comments

Comments
 (0)