Resolves #240 through grammar.

It's not the cleanest solution but I don't see too many alternatives. Modify grammar to explicitly allow the color literal to appear in fully qualified name.
This commit is contained in:
A Pottinger
2021-08-11 08:45:19 -07:00
parent ba43e4d41d
commit 809d460f44
3 changed files with 15 additions and 12 deletions

View File

@@ -4,7 +4,8 @@
* - 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
* - adds HTML hex notation with hash symbol: #ff5522
* - allow color to appear as part of qualified names (like in imports)
*/
grammar Processing;
@@ -47,8 +48,8 @@ variableDeclaratorId
// 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);
}
;
@@ -89,6 +90,10 @@ colorPrimitiveType
: 'color'
;
qualifiedName
: (IDENTIFIER | colorPrimitiveType) ('.' (IDENTIFIER | colorPrimitiveType))*
;
// added HexColorLiteral
literal
: integerLiteral
@@ -127,4 +132,3 @@ LINE_COMMENT
;
CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence)* '\''; // A bit nasty but let JDT tackle invalid chars