Skip to content

Commit 787bef4

Browse files
committed
Clean up spacing on Processing.g4
1 parent 8ff88f7 commit 787bef4

1 file changed

Lines changed: 51 additions & 49 deletions

File tree

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
/**
2-
* Based on Java 1.7 grammar for ANTLR 4, see Java.g4
2+
* Based on Java 1.7 grammar for ANTLR 4, see Java.g4
33
*
4-
* - changes main entry point to reflect sketch types 'static' | 'active'
5-
* - adds support for type converter functions like "int()"
6-
* - adds pseudo primitive type "color"
7-
* - adds HTML hex notation with hash symbol: #ff5522
4+
* - changes main entry point to reflect sketch types 'static' | 'active'
5+
* - adds support for type converter functions like "int()"
6+
* - adds pseudo primitive type "color"
7+
* - adds HTML hex notation with hash symbol: #ff5522
88
* - allow color to appear as part of qualified names (like in imports)
99
*/
1010

1111
grammar Processing;
1212

1313
@lexer::members {
14-
public static final int WHITESPACE = 1;
15-
public static final int COMMENTS = 2;
14+
public static final int WHITESPACE = 1;
15+
public static final int COMMENTS = 2;
1616
}
1717

1818
// import Java grammar
1919
import JavaParser;
2020

2121
// main entry point, select sketch type
2222
processingSketch
23-
: javaProcessingSketch
24-
| staticProcessingSketch
25-
| activeProcessingSketch
26-
| warnMixedModes
23+
: javaProcessingSketch
24+
| staticProcessingSketch
25+
| activeProcessingSketch
26+
| warnMixedModes
2727
;
2828

2929
// java mode, is a compilation unit
3030
javaProcessingSketch
31-
: packageDeclaration? importDeclaration* typeDeclaration+ EOF
31+
: packageDeclaration? importDeclaration* typeDeclaration+ EOF
3232
;
3333

3434
// No method declarations, just statements
3535
staticProcessingSketch
36-
: (importDeclaration | blockStatement)* EOF
36+
: (importDeclaration | blockStatement)* EOF
3737
;
3838

3939
// active mode, has function definitions
4040
activeProcessingSketch
41-
: (importDeclaration | classBodyDeclaration)* EOF
42-
;
41+
: (importDeclaration | classBodyDeclaration)* EOF
42+
;
4343

4444
// User incorrectly mixing modes. Included to allow for kind error message.
4545
warnMixedModes
46-
: (importDeclaration | classBodyDeclaration | blockStatement)* blockStatement classBodyDeclaration (importDeclaration | classBodyDeclaration | blockStatement)*
47-
| (importDeclaration | classBodyDeclaration | blockStatement)* classBodyDeclaration blockStatement (importDeclaration | classBodyDeclaration | blockStatement)*
46+
: (importDeclaration | classBodyDeclaration | blockStatement)* blockStatement classBodyDeclaration (importDeclaration | classBodyDeclaration | blockStatement)*
47+
| (importDeclaration | classBodyDeclaration | blockStatement)* classBodyDeclaration blockStatement (importDeclaration | classBodyDeclaration | blockStatement)*
4848
;
4949

5050
variableDeclaratorId
51-
: warnTypeAsVariableName
52-
| IDENTIFIER ('[' ']')*
51+
: warnTypeAsVariableName
52+
| IDENTIFIER ('[' ']')*
5353
;
5454

5555
// bug #93
5656
// https://github.com/processing/processing/issues/93
5757
// prevent from types being used as variable names
5858
warnTypeAsVariableName
59-
: primitiveType ('[' ']')* {
60-
notifyErrorListeners("Type names are not allowed as variable names: "+$primitiveType.text);
61-
}
59+
: primitiveType ('[' ']')* {
60+
notifyErrorListeners("Type names are not allowed as variable names: "+$primitiveType.text);
61+
}
6262
;
6363

6464
// catch special API function calls that we are interested in
@@ -72,30 +72,30 @@ methodCall
7272
// these are primitive type names plus "()"
7373
// "color" is a special Processing primitive (== int)
7474
functionWithPrimitiveTypeName
75-
: ( 'boolean'
76-
| 'byte'
77-
| 'char'
78-
| 'float'
79-
| 'int'
80-
| 'color'
81-
) '(' expressionList? ')'
82-
;
75+
: ( 'boolean'
76+
| 'byte'
77+
| 'char'
78+
| 'float'
79+
| 'int'
80+
| 'color'
81+
) '(' expressionList? ')'
82+
;
8383

8484
// adding support for "color" primitive
8585
primitiveType
86-
: BOOLEAN
87-
| CHAR
88-
| BYTE
89-
| SHORT
90-
| INT
91-
| LONG
92-
| FLOAT
93-
| DOUBLE
94-
| colorPrimitiveType
95-
;
86+
: BOOLEAN
87+
| CHAR
88+
| BYTE
89+
| SHORT
90+
| INT
91+
| LONG
92+
| FLOAT
93+
| DOUBLE
94+
| colorPrimitiveType
95+
;
9696

9797
colorPrimitiveType
98-
: 'color'
98+
: 'color'
9999
;
100100

101101
qualifiedName
@@ -116,27 +116,29 @@ literal
116116
// As parser rule so this produces a separate listener
117117
// for us to alter its value.
118118
hexColorLiteral
119-
: HexColorLiteral
120-
;
119+
: HexColorLiteral
120+
;
121121

122122
// add color literal notations for
123123
// #ff5522
124124
HexColorLiteral
125-
: '#' (HexDigit HexDigit)? HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit
126-
;
125+
: '#' (HexDigit HexDigit)? HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit
126+
;
127127

128128

129129
// hide but do not remove whitespace and comments
130130

131-
WS : [ \t\r\n\u000C]+ -> channel(1)
131+
WS : [ \t\r\n\u000C]+ -> channel(1)
132132
;
133133

134134
COMMENT
135-
: '/*' .*? '*/' -> channel(2)
135+
: '/*' .*? '*/' -> channel(2)
136136
;
137137

138138
LINE_COMMENT
139-
: '//' ~[\r\n]* -> channel(2)
139+
: '//' ~[\r\n]* -> channel(2)
140140
;
141141

142-
CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence)* '\''; // A bit nasty but let JDT tackle invalid chars
142+
CHAR_LITERAL
143+
: '\'' (~['\\\r\n] | EscapeSequence)* '\'' // A bit nasty but let JDT tackle invalid chars
144+
;

0 commit comments

Comments
 (0)