Advertisement
Guest User

xtext-grammer

a guest
Jul 6th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. grammar at.bestsolution.efxclipse.tooling.css.Definition with org.eclipse.xtext.xbase.Xbase // hidden(WS, SL_COMMENT)
  2.  
  3. generate definition "http://www.bestsolution.at/efxclipse/tooling/css/Definition"
  4.  
  5. CSSDefs:
  6. imports+=Import*
  7. packageDef=PackageDeclaration
  8. ;
  9.  
  10. Import:
  11. 'import' importedNamespace=QualifiedNameWithWildCard;
  12.  
  13. PackageDeclaration:
  14. 'package' name=QualifiedName '{'
  15. typDefs+=TypeDef? (',' typDefs+=TypeDef)*
  16. elementDefs+=ElementDef? (',' elementDefs+=ElementDef)*
  17. subpackages+=PackageDeclaration*
  18. '}';
  19.  
  20. enum PrimTypes:
  21. STRING | INT | DOUBLE | BOOL
  22. ;
  23.  
  24. TypeDef:
  25. GenericTypeDef | EnumTypeDef
  26. ;
  27.  
  28. GenericTypeDef:
  29. doc=DOCU?
  30. 'type' name=ValidID '{'
  31. typeDef=TypeValue
  32. '}'
  33. ;
  34.  
  35. EnumTypeDef:
  36. doc=DOCU?
  37. 'enumtype' name=ValidID '{'
  38. values+=EnumValue (',' values+=EnumValue)+
  39. '}'
  40. ;
  41.  
  42.  
  43. TypeValue:
  44. TypeDefValue | PrimValue
  45. ;
  46.  
  47. TypeDefValue:
  48. typeRule=TypeRule
  49. ;
  50.  
  51. PrimValue:
  52. v=PrimTypes
  53. ;
  54.  
  55. ElementDef:
  56. doc=DOCU?
  57. name=ValidID ('extends' superElements+=[ElementDef|QualifiedName] (',' superElements+=[ElementDef|QualifiedName])*)? '{'
  58. properties+=Property? (',' properties+=Property)*
  59. pseudoClasses+=PseudoClass? (',' pseudoClasses+=PseudoClass)*
  60. subelements+=SubElement? (',' subelements+=SubElement)*
  61. '}'
  62. ;
  63.  
  64. SubElement:
  65. doc=DOCU?
  66. 'substructure' type=[ElementDef|QualifiedName] name=STRING ('{'
  67. subelements+=SubElement? (',' subelements+=SubElement)*
  68. '}')?
  69.  
  70. ;
  71.  
  72. Property:
  73. GenericProperty | EnumProperty | NumberProperty | BooleanProperty | StringProperty | IntegerProperty
  74. ;
  75.  
  76. PseudoClass:
  77. doc=DOCU?
  78. 'pseudoclass' name=STRING
  79. ;
  80.  
  81. GenericProperty:
  82. doc=DOCU?
  83. name=STRING 'default' defaultValue=STRING '{'
  84. typeRule=TypeRule
  85. '}'
  86. ;
  87.  
  88. TypeRule:
  89. segment=Segment typeSegment+=SubRule*
  90. ;
  91.  
  92. SubRule:
  93. TypeRuleSegment | TypeGroupSegment | TypeKeySegment
  94. ;
  95.  
  96. TypeRuleSegment:
  97. op=('||'|'|') segment=Segment
  98. ;
  99.  
  100. Segment:
  101. TypeSegment | TypeFunctionSegment | TypeGroupSegment
  102. ;
  103.  
  104. TypeSegment:
  105. ('<' type+=[TypeDef|ValidID]'>')+
  106. ;
  107.  
  108. TypeKeySegment:
  109. keyword=STRING ('?')?
  110. ;
  111.  
  112. TypeFunctionSegment:
  113. function=ValidID '(' type=[TypeDef|ValidID] ')'
  114. ;
  115.  
  116. TypeGroupSegment:
  117. '[' sep=STRING? rule=TypeRule ']' ('*'|'+'|'?'|('{' min=INT (','max=INT)?'}'))?
  118. ;
  119.  
  120. EnumProperty:
  121. doc=DOCU?
  122. 'enum' name=STRING 'default' defaultValue=STRING '{'
  123. values+=EnumValue (',' values+=EnumValue)+
  124. '}'
  125. ;
  126.  
  127. EnumValue:
  128. doc=DOCU?
  129. value=STRING
  130. ;
  131.  
  132. NumberProperty:
  133. doc=DOCU?
  134. unsigned?='unsigned'? 'number' name=STRING 'default' defaultValue=DECIMAL ('range' min=DECIMAL 'to' max=DECIMAL)?
  135. ;
  136.  
  137. IntegerProperty:
  138. doc=DOCU?
  139. unsigned?='unsigned'? 'integer' name=STRING 'default' defaultValue=INT ('range' min=INT 'to' max=INT)?
  140. ;
  141.  
  142.  
  143. BooleanProperty:
  144. doc=DOCU?
  145. 'boolean' name=STRING 'default' defaultValue=('true'|'false')
  146. ;
  147.  
  148. StringProperty:
  149. doc=DOCU?
  150. 'string' name=STRING 'default' defaultValue=STRING
  151. ;
  152.  
  153. QualifiedNameWithWildCard :
  154. QualifiedName ('.' '*')?;
  155.  
  156. terminal DOCU: '/#' -> '#/';
  157.  
  158. /*Operation:
  159. 'op' name=ValidID '(' (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)? ')' ':' type=JvmTypeReference
  160. body=XBlockExpression;*/
  161.  
  162. terminal ID:
  163. '^'? ('a'..'z'|'A'..'Z'|'$'|'_') ('a'..'z'|'A'..'Z'|'$'|'_'|'0'..'9')*;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement