File tree Expand file tree Collapse file tree 4 files changed +55
-4
lines changed
src/processing/mode/java/preproc Expand file tree Collapse file tree 4 files changed +55
-4
lines changed Original file line number Diff line number Diff line change 44 * - changes main entry point to reflect sketch types 'static' | 'active'
55 * - adds support for type converter functions like "int()"
66 * - adds pseudo primitive type "color"
7- * - adds HTML hex notation with hash symbol: #ff5522
7+ * - adds HTML hex notation with hash symbol: #ff5522
8+ * - allow color to appear as part of qualified names (like in imports)
89 */
910
1011grammar Processing;
@@ -47,8 +48,8 @@ variableDeclaratorId
4748// https://github.com/processing/processing/issues/93
4849// prevent from types being used as variable names
4950warnTypeAsVariableName
50- : primitiveType (' [' ' ]' )* {
51- notifyErrorListeners(" Type names are not allowed as variable names: " +$primitiveType.text);
51+ : primitiveType (' [' ' ]' )* {
52+ notifyErrorListeners(" Type names are not allowed as variable names: " +$primitiveType.text);
5253 }
5354 ;
5455
@@ -89,6 +90,10 @@ colorPrimitiveType
8990 : ' color'
9091 ;
9192
93+ qualifiedName
94+ : (IDENTIFIER | colorPrimitiveType) (' .' (IDENTIFIER | colorPrimitiveType))*
95+ ;
96+
9297// added HexColorLiteral
9398literal
9499 : integerLiteral
@@ -127,4 +132,3 @@ LINE_COMMENT
127132 ;
128133
129134CHAR_LITERAL : ' \' ' (~[' \\\r\n ] | EscapeSequence)* ' \' ' ; // A bit nasty but let JDT tackle invalid chars
130-
Original file line number Diff line number Diff line change @@ -385,4 +385,9 @@ public void testSmoothWithParamStatic() {
385385 expectGood ("smoothparamstatic" );
386386 }
387387
388+ @ Test
389+ public void testColorInImport () {
390+ expectGood ("colorimport" );
391+ }
392+
388393}
Original file line number Diff line number Diff line change 1+ import processing.core.*;
2+ import processing.data.*;
3+ import processing.event.*;
4+ import processing.opengl.*;
5+
6+ import test.color;
7+
8+ import java.util.HashMap;
9+ import java.util.ArrayList;
10+ import java.io.File;
11+ import java.io.BufferedReader;
12+ import java.io.PrintWriter;
13+ import java.io.InputStream;
14+ import java.io.OutputStream;
15+ import java.io.IOException;
16+
17+ public class colorimport extends PApplet {
18+
19+ public void setup() {
20+
21+
22+ boolean test = true;
23+ int c1 = color(255, 255, 255);
24+ int c2 = test ? 0xFFA011CD : 0xC0C0C0C0;
25+
26+ noLoop();
27+ }
28+
29+ static public void main(String[] passedArgs) {
30+ String[] appletArgs = new String[] { "colorimport" };
31+ if (passedArgs != null) {
32+ PApplet.main(concat(appletArgs, passedArgs));
33+ } else {
34+ PApplet.main(appletArgs);
35+ }
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ import test.color ;
2+
3+ boolean test = true ;
4+ color c1 = color (255 , 255 , 255 );
5+ color c2 = test ? #A011CD : #C0C0C0C0 ;
You can’t perform that action at this time.
0 commit comments