From 787bef4a9648c3428a05d136ca6f893e547db1c5 Mon Sep 17 00:00:00 2001 From: A Pottinger Date: Sun, 30 Jan 2022 09:47:06 -0800 Subject: [PATCH] Clean up spacing on Processing.g4 --- .../mode/java/preproc/Processing.g4 | 100 +++++++++--------- 1 file changed, 51 insertions(+), 49 deletions(-) diff --git a/java/src/processing/mode/java/preproc/Processing.g4 b/java/src/processing/mode/java/preproc/Processing.g4 index d71ae324a..a2eb75a4e 100644 --- a/java/src/processing/mode/java/preproc/Processing.g4 +++ b/java/src/processing/mode/java/preproc/Processing.g4 @@ -1,18 +1,18 @@ /** - * Based on Java 1.7 grammar for ANTLR 4, see Java.g4 + * Based on Java 1.7 grammar for ANTLR 4, see Java.g4 * - * - changes main entry point to reflect sketch types 'static' | 'active' - * - adds support for type converter functions like "int()" - * - adds pseudo primitive type "color" - * - adds HTML hex notation with hash symbol: #ff5522 + * - changes main entry point to reflect sketch types 'static' | 'active' + * - adds support for type converter functions like "int()" + * - adds pseudo primitive type "color" + * - adds HTML hex notation with hash symbol: #ff5522 * - allow color to appear as part of qualified names (like in imports) */ grammar Processing; @lexer::members { - public static final int WHITESPACE = 1; - public static final int COMMENTS = 2; + public static final int WHITESPACE = 1; + public static final int COMMENTS = 2; } // import Java grammar @@ -20,45 +20,45 @@ import JavaParser; // main entry point, select sketch type processingSketch - : javaProcessingSketch - | staticProcessingSketch - | activeProcessingSketch - | warnMixedModes + : javaProcessingSketch + | staticProcessingSketch + | activeProcessingSketch + | warnMixedModes ; // java mode, is a compilation unit javaProcessingSketch - : packageDeclaration? importDeclaration* typeDeclaration+ EOF + : packageDeclaration? importDeclaration* typeDeclaration+ EOF ; // No method declarations, just statements staticProcessingSketch - : (importDeclaration | blockStatement)* EOF + : (importDeclaration | blockStatement)* EOF ; // active mode, has function definitions activeProcessingSketch - : (importDeclaration | classBodyDeclaration)* EOF - ; + : (importDeclaration | classBodyDeclaration)* EOF + ; // User incorrectly mixing modes. Included to allow for kind error message. warnMixedModes - : (importDeclaration | classBodyDeclaration | blockStatement)* blockStatement classBodyDeclaration (importDeclaration | classBodyDeclaration | blockStatement)* - | (importDeclaration | classBodyDeclaration | blockStatement)* classBodyDeclaration blockStatement (importDeclaration | classBodyDeclaration | blockStatement)* + : (importDeclaration | classBodyDeclaration | blockStatement)* blockStatement classBodyDeclaration (importDeclaration | classBodyDeclaration | blockStatement)* + | (importDeclaration | classBodyDeclaration | blockStatement)* classBodyDeclaration blockStatement (importDeclaration | classBodyDeclaration | blockStatement)* ; variableDeclaratorId - : warnTypeAsVariableName - | IDENTIFIER ('[' ']')* + : warnTypeAsVariableName + | IDENTIFIER ('[' ']')* ; // bug #93 // https://github.com/processing/processing/issues/93 // prevent from types being used as variable names warnTypeAsVariableName - : primitiveType ('[' ']')* { - notifyErrorListeners("Type names are not allowed as variable names: "+$primitiveType.text); - } + : primitiveType ('[' ']')* { + notifyErrorListeners("Type names are not allowed as variable names: "+$primitiveType.text); + } ; // catch special API function calls that we are interested in @@ -72,30 +72,30 @@ methodCall // these are primitive type names plus "()" // "color" is a special Processing primitive (== int) functionWithPrimitiveTypeName - : ( 'boolean' - | 'byte' - | 'char' - | 'float' - | 'int' - | 'color' - ) '(' expressionList? ')' - ; + : ( 'boolean' + | 'byte' + | 'char' + | 'float' + | 'int' + | 'color' + ) '(' expressionList? ')' + ; // adding support for "color" primitive primitiveType - : BOOLEAN - | CHAR - | BYTE - | SHORT - | INT - | LONG - | FLOAT - | DOUBLE - | colorPrimitiveType - ; + : BOOLEAN + | CHAR + | BYTE + | SHORT + | INT + | LONG + | FLOAT + | DOUBLE + | colorPrimitiveType + ; colorPrimitiveType - : 'color' + : 'color' ; qualifiedName @@ -116,27 +116,29 @@ literal // As parser rule so this produces a separate listener // for us to alter its value. hexColorLiteral - : HexColorLiteral - ; + : HexColorLiteral + ; // add color literal notations for // #ff5522 HexColorLiteral - : '#' (HexDigit HexDigit)? HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit - ; + : '#' (HexDigit HexDigit)? HexDigit HexDigit HexDigit HexDigit HexDigit HexDigit + ; // hide but do not remove whitespace and comments -WS : [ \t\r\n\u000C]+ -> channel(1) +WS : [ \t\r\n\u000C]+ -> channel(1) ; COMMENT - : '/*' .*? '*/' -> channel(2) + : '/*' .*? '*/' -> channel(2) ; LINE_COMMENT - : '//' ~[\r\n]* -> channel(2) + : '//' ~[\r\n]* -> channel(2) ; -CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence)* '\''; // A bit nasty but let JDT tackle invalid chars +CHAR_LITERAL + : '\'' (~['\\\r\n] | EscapeSequence)* '\'' // A bit nasty but let JDT tackle invalid chars + ;