Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext/src/org/eclipse/papyrus/infra/gmfdiag/css3/CSS.xtext')
-rw-r--r--plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext/src/org/eclipse/papyrus/infra/gmfdiag/css3/CSS.xtext685
1 files changed, 347 insertions, 338 deletions
diff --git a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext/src/org/eclipse/papyrus/infra/gmfdiag/css3/CSS.xtext b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext/src/org/eclipse/papyrus/infra/gmfdiag/css3/CSS.xtext
index 61a501b25e2..65abe57abc6 100644
--- a/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext/src/org/eclipse/papyrus/infra/gmfdiag/css3/CSS.xtext
+++ b/plugins/infra/gmfdiag/css/org.eclipse.papyrus.infra.gmfdiag.css3.xtext/src/org/eclipse/papyrus/infra/gmfdiag/css3/CSS.xtext
@@ -1,339 +1,348 @@
-/*
- * Copied from org.eclipse.fx.ide.css
- */
-grammar org.eclipse.papyrus.infra.gmfdiag.css3.CSS hidden(WS, ML_COMMENT)
-
-import "http://www.eclipse.org/emf/2002/Ecore" as ecore
-
-generate cSS "http://www.eclipse.org/papyrus/infra/gmfdiag/css3/CSS"
-
-
-/*
- * TODOS:
- * - add more CSS grammar like import
- */
-
-
-stylesheet:
- charset=charset?
- imports+=importExpression*
- (
- ruleset+=ruleset |
- media+=media |
- page+=page |
- font_face+=font_face |
- keyframes+=keyframes
- )*
-;
-
-charset:
- ('@charset'|'@CHARSET') charset=CSSSTRING ';'
-;
-
-importExpression:
- ('@import'|'@IMPORT') (value=CSSSTRING | URLType mediaList=media_list?) ';'
-;
-
-page:
- {page} ('@page'|'@PAGE') pseudoPage=pseudo_page?
- '{' declarations+=css_declaration? ( ';' declarations+=css_declaration? )* '}'
-;
-
-pseudo_page:
- COLON Identifier
-;
-
-media:
- ('@media'|'@MEDIA') medialist=media_list '{' rulesets+=ruleset* '}'
-;
-
-media_list:
- medium ( COMMA medium)*
-;
-
-medium:
- Identifier
-;
-
-font_face:
- {font_face} ('@font-face'|'@FONT-FACE')
- '{' declarations+=css_declaration? ( ';' declarations+=css_declaration? )* '}'
-;
-
-keyframes:
- {font_face} ('@keyframes'|'@KEYFRAMES') name=Identifier
- '{' keyframeselectors+=keyframe_selector? ( ';' keyframeselectors+=keyframe_selector? )* '}'
-;
-
-keyframe_selector:
- (type=Identifier | (percentage=Num PERCENT)) '{'
- declarations+=css_declaration? ( ';' declarations+=css_declaration? )*
- '}'
-;
-
-
-ruleset:
- selectors+=selector ( WS* COMMA selectors+=selector )* WS* '{'
- (declarations+=css_declaration (';' declarations+=css_declaration)* ';'?)?
- '}'
-;
-
-// check simple_selctor cardinality
-selector hidden(ML_COMMENT):
- simpleselectors+=simple_selector ( combinator=combinator WS* selector=selector | WS+ (combinator=combinator WS*)? selector=selector )?
-;
-
-SimpleSelectorForNegation:
- ((element=ElementSelector | universal=UniversalSelector) subSelectors+=SubSelectorForNegation*) |
- => subSelectors+=SubSelectorForNegation+
-;
-
-SubSelectorForNegation returns CssSelector:
- IdSelector |
- ClassSelector |
- AttributeSelector |
- PseudoClass
-;
-
-simple_selector hidden(ML_COMMENT):
- ((element=ElementSelector | universal=UniversalSelector) subSelectors+=SubSelector*) |
- subSelectors+=SubSelector+
-;
-
-SubSelector returns CssSelector:
- IdSelector |
- ClassSelector |
- AttributeSelector |
- PseudoClassOrFunc
-;
-
-AttributeSelector returns CssSelector:
- {AttributeSelector} '[' name=Identifier ( op=( '^=' | '$=' | '*=' | '=' | INCLUDES | DASHMATCH ) value=( Identifier | CSSSTRING ) )? ']'
-;
-
-ClassSelector:
- {ClassSelector} '.' name=Identifier
-;
-
-ElementSelector:
- {ElementSelector} name=Identifier
-;
-
-UniversalSelector:
- {UniversalSelector} ( namespace=css_namespace_prefix )? '*'
-;
-
-IdSelector:
- {IdSelector} HASHMARK name=Identifier
-;
-
-css_namespace_prefix
- : ( Identifier | '*' )? '|'
- ;
-
-css_declaration hidden(ML_COMMENT):
- WS* property=css_property WS* COLON valueTokens+=CssTok+ important?=IMPORTANT_SYM?
-;
-
-css_property:
- {css_property} name=ValidPropertyIdent
-;
-
-ValidPropertyIdent:
- Identifier
-;
-
-PseudoClassOrFunc:
- PseudoClass | PseudoClassFunction
-;
-
-PseudoClass:
- COLON COLON? PseudoClassName
-;
-
-PseudoClassName:
- name=Identifier
-;
-
-PseudoClassFunction:
- not?=NotFunctionCall paramSelector=SimpleSelectorForNegation ')' |
- COLON name=Identifier '(' params+=CssTok* ')'
-;
-
-NotFunctionCall hidden():
- COLON 'not('
-;
-
-combinator
- :
- (
- PLUS
- | '>'
- | '~'
- )
-;
-
-operator
- : '/' | COMMA
- ;
-
-unary_operator
- : DASH | PLUS
- ;
-
-SymbolTok returns CssTok:
- {SymbolTok} symbol=(COMMA|PERCENT)
-;
-
-WSTok returns CssTok:
- {WSTok} WS
-;
-
-StringTok returns CssTok:
- {StringTok} value=CSSSTRING
-;
-
-
-
-NumberTok returns CssTok hidden():
- {NumberTok} val=Num
-
-// {NumberTok} DASH? ( ONE_INT+ | ONE_INT* '.' => ONE_INT+)
-
-// {NumberTok} val=Integer | Real
- //sign=DASH? ( ival=Integer | dval=Real)
-;
-
-
-UrlTok returns CssTok:
- {UrlTok} url=URLType
-;
-
-ColorTok returns CssTok hidden():
- {ColorTok} value=Hex
-;
-
-IdentifierOrFuncTok returns CssTok hidden(ML_COMMENT):
- {IdentifierTok} name=Identifier ( {FuncTok.name=current} '(' params+=CssTok+ ')')?
-;
-
-CssTok hidden(ML_COMMENT):
- IdentifierOrFuncTok |
- SymbolTok |
- WSTok |
- StringTok |
- NumberTok |
- UrlTok |
- ColorTok
-;
-
-
-URLType hidden():
-// FULLURL
- 'url(' url=ValidURL ')'
-;
-
-ValidURLSymbol:
- DASH | '.' | UNDERSCORE | '~' | COLON |
- '/' |'?' | HASHMARK | '[' | ']' | '@' |
- '!' | '$' | '&' | /* "'" | '(' | ')' | need to be escaped*/
- '*' | PLUS | COMMA | ';' | '='
- KeywordHack
-;
-
-KeywordHack:
- 'not' |
- 'no' |
- 'url' |
- 'ur'
-;
-
-ValidURL returns ecore::EString hidden():
- CSSSTRING |
- ( ValidURLSymbol |
- KeywordHack |
- ONE_HEX_LETTER |
- ONE_NON_HEX_LETTER |
- ONE_INT |
- '\\ ' |
- '\\(' |
- '\\)' |
- '\\\'' |
- '\\"' |
- PERCENT (ONE_INT|ONE_HEX_LETTER) (ONE_INT|ONE_HEX_LETTER)
- )+
-;
-
-terminal IMPORTANT_SYM:
- '!important'
-;
-
-Identifier returns ecore::EString hidden():
- DASH? (UNDERSCORE | ONE_HEX_LETTER | ONE_NON_HEX_LETTER | KeywordHack) => (UNDERSCORE | DASH | ONE_HEX_LETTER | ONE_NON_HEX_LETTER | ONE_INT | KeywordHack)*
-;
-
-Num returns ecore::EDouble hidden():
- (PLUS|DASH)? (
- '.' => ONE_INT+ |
- => ONE_INT+ (=> '.' => ONE_INT+)?
- )
-;
-
-Hex returns ecore::EString:
- HASHMARK => (ONE_INT|ONE_HEX_LETTER)+
-;
-
-
-//terminal fragment URL_ESCAPES:
-// '\\' (' '|'('|')'|"'"|'"')
-//;
-//
-//terminal FULLURL:
-// 'url('
-// '"' ( URL_ESCAPES | !('\\'|'"'|')') )* '"' |
-// "'" ( URL_ESCAPES | !('\\'|"'"|')') )* "'" |
-// ( URL_ESCAPES | !('\\'|')') )*
-// ')'
-//;
-
-
-terminal ONE_INT: '0'..'9';
-terminal ONE_HEX_LETTER: ('a'..'f'|'A'..'F');
-terminal ONE_NON_HEX_LETTER: ('g'..'z'|'G'..'Z');
-
-
-terminal UNDERSCORE: '_';
-terminal DASH: '-';
-terminal PLUS: '+';
-
-//terminal INTEGER returns ecore::EInt: ('0'..'9')+;
-//terminal INTEGER:('0'..'9')+;
-
-//terminal REAL: (('0'..'9')*"."('0'..'9')+);
-//terminal HASH: '#' ('_' | '-' | 'a'..'z' | 'A'..'Z' | '0'..'9' )+;
-
-terminal HASHMARK: '#';
-
-//terminal COLORHASH: '#' ('a'..'z' | 'A'..'Z' | '0'..'9' )+;
-
-//terminal IDENT: ('_' | 'a'..'z' | 'A'..'Z' ) ('_' | '-' | 'a'..'z' | 'A'..'Z' | '0'..'9' )*;
-
-//terminal HEX: '###' ('a'..'z' | 'A'..'Z' | '0'..'9' )+;
-
-terminal COMMA: ',';
-terminal PERCENT: '%';
-
-terminal ML_COMMENT : '/*' -> '*/';
-terminal WS : (' '|'\t'|'\r'|'\n')+;
-
-
-
-terminal CSSSTRING :
- '"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'0'..'9'|'a'..'f'|'A'..'F'|'\\') | !('\\'|'"') )* '"' |
- "'" ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'0'..'9'|'a'..'f'|'A'..'F'|'\\') | !('\\'|"'") )* "'";
-
-
-terminal INCLUDES: "~=";
-terminal DASHMATCH: "|=";
-
+/*
+ * Copied from org.eclipse.fx.ide.css
+ */
+grammar org.eclipse.papyrus.infra.gmfdiag.css3.CSS hidden(WS, ML_COMMENT)
+
+import "http://www.eclipse.org/emf/2002/Ecore" as ecore
+
+generate cSS "http://www.eclipse.org/papyrus/infra/gmfdiag/css3/CSS"
+
+
+/*
+ * TODOS:
+ * - add more CSS grammar like import
+ */
+
+
+stylesheet:
+ charset=charset?
+ imports+=importExpression*
+ (
+ ruleset+=ruleset |
+ media+=media |
+ page+=page |
+ font_face+=font_face |
+ keyframes+=keyframes
+ )*
+;
+
+charset:
+ ('@charset'|'@CHARSET') charset=CSSSTRING ';'
+;
+
+importExpression:
+ ('@import'|'@IMPORT') (value=CSSSTRING | URLType mediaList=media_list?) ';'
+;
+
+page:
+ {page} ('@page'|'@PAGE') pseudoPage=pseudo_page?
+ '{' declarations+=css_declaration? ( ';' declarations+=css_declaration? )* '}'
+;
+
+pseudo_page:
+ COLON Identifier
+;
+
+media:
+ ('@media'|'@MEDIA') medialist=media_list '{' rulesets+=ruleset* '}'
+;
+
+media_list:
+ medium ( COMMA medium)*
+;
+
+medium:
+ Identifier
+;
+
+font_face:
+ {font_face} ('@font-face'|'@FONT-FACE')
+ '{' declarations+=css_declaration? ( ';' declarations+=css_declaration? )* '}'
+;
+
+keyframes:
+ {font_face} ('@keyframes'|'@KEYFRAMES') name=Identifier
+ '{' keyframeselectors+=keyframe_selector? ( ';' keyframeselectors+=keyframe_selector? )* '}'
+;
+
+keyframe_selector:
+ (type=Identifier | (percentage=Num PERCENT)) '{'
+ declarations+=css_declaration? ( ';' declarations+=css_declaration? )*
+ '}'
+;
+
+
+ruleset:
+ selectors+=selector ( WS* COMMA selectors+=selector )* WS* '{'
+ (declarations+=css_declaration (';' declarations+=css_declaration)* ';'?)?
+ '}'
+;
+
+// check simple_selctor cardinality
+selector hidden(ML_COMMENT):
+ simpleselectors+=simple_selector ( combinator=combinator WS* selector=selector | WS+ (combinator=combinator WS*)? selector=selector )?
+;
+
+SimpleSelectorForNegation:
+ ((element=ElementSelector | universal=UniversalSelector) subSelectors+=SubSelectorForNegation*) |
+ => subSelectors+=SubSelectorForNegation+
+;
+
+SubSelectorForNegation returns CssSelector:
+ IdSelector |
+ ClassSelector |
+ AttributeSelector |
+ PseudoClass
+;
+
+simple_selector hidden(ML_COMMENT):
+ ((element=ElementSelector | universal=UniversalSelector) subSelectors+=SubSelector*) |
+ subSelectors+=SubSelector+
+;
+
+SubSelector returns CssSelector:
+ IdSelector |
+ ClassSelector |
+ AttributeSelector |
+ PseudoClassOrFunc
+;
+
+AttributeSelector returns CssSelector:
+ {AttributeSelector} '[' name=Identifier ( op=( '^=' | '$=' | '*=' | '=' | INCLUDES | DASHMATCH ) value=( Identifier | CSSSTRING ) )? ']'
+;
+
+ClassSelector:
+ {ClassSelector} '.' name=Identifier
+;
+
+ElementSelector:
+ {ElementSelector} name=Identifier
+;
+
+UniversalSelector:
+ {UniversalSelector} ( namespace=css_namespace_prefix )? '*'
+;
+
+IdSelector:
+ {IdSelector} HASHMARK name=Identifier
+;
+
+css_namespace_prefix
+ : ( Identifier | '*' )? '|'
+ ;
+
+css_declaration hidden(ML_COMMENT):
+ WS* property=css_property WS* COLON valueTokens+=CssTok+ important?=IMPORTANT_SYM?
+;
+
+css_property:
+ {css_property} name=ValidPropertyIdent
+;
+
+ValidPropertyIdent:
+ Identifier
+;
+
+PseudoClassOrFunc:
+ PseudoClass | PseudoClassFunction
+;
+
+PseudoClass:
+ COLON COLON? PseudoClassName
+;
+
+PseudoClassName:
+ name=Identifier
+;
+
+PseudoClassFunction:
+ not?=NotFunctionCall paramSelector=SimpleSelectorForNegation ')' |
+ COLON name=Identifier '(' params+=CssTok* ')'
+;
+
+NotFunctionCall hidden():
+ COLON 'not('
+;
+
+combinator
+ :
+ (
+ PLUS
+ | '>'
+ | '~'
+ )
+;
+
+operator
+ : '/' | COMMA
+ ;
+
+unary_operator
+ : DASH | PLUS
+ ;
+
+SymbolTok returns CssTok:
+ {SymbolTok} symbol=(COMMA|PERCENT)
+;
+
+WSTok returns CssTok:
+ {WSTok} WS
+;
+
+StringTok returns CssTok:
+ {StringTok} value=CSSSTRING
+;
+
+
+
+NumberTok returns CssTok hidden():
+ {NumberTok} val=Num
+
+// {NumberTok} DASH? ( ONE_INT+ | ONE_INT* '.' => ONE_INT+)
+
+// {NumberTok} val=Integer | Real
+ //sign=DASH? ( ival=Integer | dval=Real)
+;
+
+
+UrlTok returns CssTok:
+ {UrlTok} url=URLType
+;
+
+ColorTok returns CssTok hidden():
+ {ColorTok} value=Hex
+;
+
+IdentifierOrFuncTok returns CssTok hidden(ML_COMMENT):
+ {IdentifierTok} name=Identifier ( {FuncTok.name=current} '(' params+=CssTok+ ')')?
+;
+
+IntegerTok returns CssTok hidden():
+ {IntegerTok} val=NumInt
+;
+
+CssTok hidden(ML_COMMENT):
+ IdentifierOrFuncTok |
+ SymbolTok |
+ WSTok |
+ StringTok |
+ NumberTok |
+ UrlTok |
+ ColorTok |
+ IntegerTok
+;
+
+
+URLType hidden():
+// FULLURL
+ 'url(' url=ValidURL ')'
+;
+
+ValidURLSymbol:
+ DASH | '.' | UNDERSCORE | '~' | COLON |
+ '/' |'?' | HASHMARK | '[' | ']' | '@' |
+ '!' | '$' | '&' | /* "'" | '(' | ')' | need to be escaped*/
+ '*' | PLUS | COMMA | ';' | '='
+ KeywordHack
+;
+
+KeywordHack:
+ 'not' |
+ 'no' |
+ 'url' |
+ 'ur'
+;
+
+ValidURL returns ecore::EString hidden():
+ CSSSTRING |
+ ( ValidURLSymbol |
+ KeywordHack |
+ ONE_HEX_LETTER |
+ ONE_NON_HEX_LETTER |
+ ONE_INT |
+ '\\ ' |
+ '\\(' |
+ '\\)' |
+ '\\\'' |
+ '\\"' |
+ PERCENT (ONE_INT|ONE_HEX_LETTER) (ONE_INT|ONE_HEX_LETTER)
+ )+
+;
+
+terminal IMPORTANT_SYM:
+ '!important'
+;
+
+Identifier returns ecore::EString hidden():
+ DASH? (UNDERSCORE | ONE_HEX_LETTER | ONE_NON_HEX_LETTER | KeywordHack) => (UNDERSCORE | DASH | ONE_HEX_LETTER | ONE_NON_HEX_LETTER | ONE_INT | KeywordHack)*
+;
+
+Num returns ecore::EDouble hidden():
+ (PLUS|DASH)? (
+ '.' => ONE_INT+ |
+ => ONE_INT+ (=> '.' => ONE_INT+)?
+ )
+;
+
+NumInt returns ecore::EInt hidden():
+ (PLUS|DASH)? ONE_INT+
+;
+
+Hex returns ecore::EString:
+ HASHMARK => (ONE_INT|ONE_HEX_LETTER)+
+;
+
+
+//terminal fragment URL_ESCAPES:
+// '\\' (' '|'('|')'|"'"|'"')
+//;
+//
+//terminal FULLURL:
+// 'url('
+// '"' ( URL_ESCAPES | !('\\'|'"'|')') )* '"' |
+// "'" ( URL_ESCAPES | !('\\'|"'"|')') )* "'" |
+// ( URL_ESCAPES | !('\\'|')') )*
+// ')'
+//;
+
+
+terminal ONE_INT: '0'..'9';
+terminal ONE_HEX_LETTER: ('a'..'f'|'A'..'F');
+terminal ONE_NON_HEX_LETTER: ('g'..'z'|'G'..'Z');
+
+
+terminal UNDERSCORE: '_';
+terminal DASH: '-';
+terminal PLUS: '+';
+
+//terminal INTEGER returns ecore::EInt: ('0'..'9')+;
+//terminal INTEGER:('0'..'9')+;
+
+//terminal REAL: (('0'..'9')*"."('0'..'9')+);
+//terminal HASH: '#' ('_' | '-' | 'a'..'z' | 'A'..'Z' | '0'..'9' )+;
+
+terminal HASHMARK: '#';
+
+//terminal COLORHASH: '#' ('a'..'z' | 'A'..'Z' | '0'..'9' )+;
+
+//terminal IDENT: ('_' | 'a'..'z' | 'A'..'Z' ) ('_' | '-' | 'a'..'z' | 'A'..'Z' | '0'..'9' )*;
+
+//terminal HEX: '###' ('a'..'z' | 'A'..'Z' | '0'..'9' )+;
+
+terminal COMMA: ',';
+terminal PERCENT: '%';
+
+terminal ML_COMMENT : '/*' -> '*/';
+terminal WS : (' '|'\t'|'\r'|'\n')+;
+
+
+
+terminal CSSSTRING :
+ '"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'0'..'9'|'a'..'f'|'A'..'F'|'\\') | !('\\'|'"') )* '"' |
+ "'" ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'0'..'9'|'a'..'f'|'A'..'F'|'\\') | !('\\'|"'") )* "'";
+
+
+terminal INCLUDES: "~=";
+terminal DASHMATCH: "|=";
+
terminal COLON: ':'; \ No newline at end of file

Back to the top