Advertisement
Guest User

Untitled

a guest
Jul 5th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BNF 15.11 KB | None | 0 0
  1. {
  2.   parserClass="com.alacsplugin.parser.AlacsParser"
  3.  
  4.   extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
  5.  
  6.   psiClassPrefix="Alacs"
  7.   psiImplClassSuffix="Impl"
  8.   psiPackage="com.alacsplugin.psi.api"
  9.   psiImplPackage="com.alacsplugin.psi.impl"
  10.  
  11.   elementTypeHolderClass="com.alacsplugin.psi.AlacsTypes"
  12.   elementTypeClass="com.alacsplugin.psi.AlacsElementType"
  13.   tokenTypeClass="com.alacsplugin.psi.AlacsTokenType"
  14.  
  15.   tokens=[
  16.     upper='regexp:[A-Z]'
  17.     lower='regexp:[a-z]'
  18.     L='regexp:[lL]'
  19.     floatType='regexp:[fFdD]'
  20.     EXP='regexp:[eE]'
  21.     HEX='regexp:[xX]'
  22.     crlf='regexp:\n|\r|\r\n'
  23.     zero='0'
  24.     nonZeroDigit='regexp:[1-9]'
  25.     hexDigit='regexp:[0-9a-fA-F]'
  26.     LEFT_BRACE="{"
  27.     RIGHT_BRACE="}"
  28.     LEFT_BRACKET="["
  29.     RIGHT_BRACKET="]"
  30.     LEFT_PAREN="("
  31.     RIGHT_PAREN=")"
  32.     SEMICOLON=";"
  33.     DOT="."
  34.     COMMA=","
  35.     Q_MARK='"'
  36.     Q_MARK_2="'"
  37.     COLON=":"
  38.     UNDERSCORE="_"
  39.     EQ='='
  40.     TO='=>'
  41.     LARROW='<-'
  42.     LL='<:'
  43.     RR='>:'
  44.     SHARP='#'
  45.     AT='@'
  46.     LLL='<%'
  47.     EPT='!'
  48.     TLD='~'
  49.     SLASH='\'
  50.     abstract="abstract"
  51.     case="case"
  52.     catch="catch"
  53.     class="class"
  54.     def="def"
  55.     do="do"
  56.     else="else"
  57.     extends="extends"
  58.     false="false"
  59.     final="final"
  60.     finally="finally"
  61.     for="for"
  62.     forSome="forSome"
  63.     if="if"
  64.     implicit="implicit"
  65.     import="import"
  66.     lazy="lazy"
  67.     macro="macro"
  68.     match="match"
  69.     new="new"
  70.     null="null"
  71.     object="object"
  72.     override="override"
  73.     package="package"
  74.     private="private"
  75.     protected="protected"
  76.     return="return"
  77.     sealed="sealed"
  78.     super="super"
  79.     this="this"
  80.     throw="throw"
  81.     trait="trait"
  82.     try="try"
  83.     true="true"
  84.     type="type"
  85.     val="val"
  86.     var="var"
  87.     while="while"
  88.     with="with"
  89.     yield="yield"
  90.     op_1='+'
  91.     op_2='-'
  92.     op_3='*'
  93.     op_4='/'
  94.     comment='regexp://.*'
  95.     any='regexp:.'
  96.   ]
  97.  
  98.   extends("StableId")=Path
  99.   extends("SimpleExpr1")=SimpleExpr
  100. }
  101. Program          ::= Def_                                              // Start Symbol - BlockExpr ???
  102.  
  103. digit            ::=  zero | nonZeroDigit
  104. letter           ::=  upper | lower // and Unicode categories Lo, Lt, Nl
  105. paren            ::=  '(' | ')' | '[' | ']' | '{' | '}'
  106. delim            ::=  "'" | '"' | '.' | ';' | ','
  107. opchar           ::=  letter                                           // !(space | upper | lower | digit | paren | delim) any -> letter
  108. printableChar    ::= // all characters in [\u0020, \u007F] inclusive
  109. charEscapeSeq    ::= '\' ('b' | 't' | 'n' | 'f' | 'r' | '"' | "'" | '\')
  110.  
  111. op               ::=  opchar {opchar} *
  112. varid            ::=  lower idrest
  113. plainid          ::=  upper idrest
  114.                  |  varid
  115.                  |  op
  116. id               ::=  plainid
  117.                  |  "'" stringLiteral "'"
  118. idrest           ::=  {letter | digit} * ['_' op]
  119.  
  120. integerLiteral   ::=  (decimalNumeral | hexNumeral) [L]
  121. hexNumeral       ::=  '0' HEX hexDigit {hexDigit} *
  122. decimalNumeral   ::=  '0' | nonZeroDigit {digit} *
  123.  
  124. floatingPointLiteral
  125.                  ::=  digit {digit} * '.' digit {digit} * [exponentPart] [floatType]
  126.                  |  '.' digit {digit} * [exponentPart] [floatType]
  127.                  |  digit {digit} * exponentPart [floatType]
  128.                  |  digit {digit} * [exponentPart] floatType
  129. exponentPart     ::=  EXP ['+' | '-'] digit {digit} *
  130.  
  131. booleanLiteral   ::=  'true' | 'false'
  132.  
  133. characterLiteral ::=  "'" letter "'"                        // (charNoQuoteOrNewline | UnicodeEscape | charEscapeSeq) -> letter
  134.  
  135. stringLiteral    ::=  '"' {stringElement} * '"'
  136.                  |  '"""' multiLineChars '"""'
  137. stringElement    ::=  letter                                // charNoDoubleQuoteOrNewline | UnicodeEscape | charEscapeSeq -> letter
  138. multiLineChars   ::=  {['"'] ['"'] letter} * {'"'} *        // charNoDoubleQuote -> letter
  139.  
  140. symbolLiteral    ::=  "'" plainid
  141.  
  142. nl               ::=  crlf
  143.  
  144.  
  145. semi             ::=  ';' |  nl {nl} *
  146.  
  147. Literal           ::=  ['-'] integerLiteral
  148.                   |  ['-'] floatingPointLiteral
  149.                   |  booleanLiteral
  150.                   |  characterLiteral
  151.                   |  stringLiteral
  152.                   |  symbolLiteral
  153.                   |  'null'
  154.  
  155. QualId            ::=  id {'.' id} *
  156. ids               ::=  id {',' id} *
  157.  
  158. Path              ::=  StableId
  159.                   |  [id '.'] 'this'
  160. StableId          ::=  id
  161.                   |  Path '.' id
  162.                   |  [id '.'] 'super' [ClassQualifier] '.' id
  163. ClassQualifier    ::=  '[' id ']'
  164.  
  165. Type_              ::=  FunctionArgTypes '=>' Type_
  166.                   |  InfixType [ExistentialClause]
  167. FunctionArgTypes  ::= InfixType
  168.                   | '(' [ ParamType {',' ParamType } * ] ')'
  169. ExistentialClause ::=  'forSome' '{' ExistentialDcl {semi ExistentialDcl} * '}'
  170. ExistentialDcl    ::=  'type' TypeDcl
  171.                   |  'val' ValDcl
  172. InfixType         ::=  CompoundType {id [nl] CompoundType} *
  173. CompoundType      ::=  AnnotType {'with' AnnotType} * [Refinement]
  174.                   |  Refinement
  175. AnnotType         ::=  SimpleType {Annotation} *
  176. //-----------------------------------------------------------------
  177. /*SimpleType        ::=  SimpleType TypeArgs
  178.                   |  SimpleType '#' id
  179.                   |  StableId
  180.                   |  Path '.' 'type'
  181.                   |  '(' Types ')'*/
  182. SimpleType        ::=  StableId SimpleType_
  183.                   |  Path '.' 'type' SimpleType_
  184.                   |  '(' Types ')' SimpleType_
  185.                   |  StableId
  186.                   |  Path '.' 'type'
  187.                   |  '(' Types ')'
  188. SimpleType_       ::= TypeArgs SimpleType_
  189.                   | '#' id SimpleType_
  190.                   | TypeArgs
  191.                   | '#' id
  192. //-----------------------------------------------------------------
  193. TypeArgs          ::=  '[' Types ']'
  194. Types             ::=  Type_ {',' Type_} *
  195. Refinement        ::=  [nl] '{' RefineStat {semi RefineStat} * '}'
  196. RefineStat        ::=  Dcl
  197.                   |  'type' TypeDef
  198.                   |
  199. TypePat           ::=  Type_
  200.  
  201. Ascription        ::=  ':' InfixType
  202.                   |  ':' Annotation {Annotation} *
  203.                   |  ':' '_' '*'
  204.  
  205. Expr              ::=  (Bindings | ['implicit'] id | '_') '=>' Expr
  206.                   |  Expr1
  207. Expr1             ::=  'if' '(' Expr ')' {nl} * Expr [[semi] 'else' Expr]
  208.                   |  'while' '(' Expr ')' {nl} * Expr
  209.                   |  'try' ('{' Block '}' | Expr) ['catch' '{' CaseClauses '}'] ['finally' Expr]
  210.                   |  'do' Expr [semi] 'while' '(' Expr ')'
  211.                   |  'for' ('(' Enumerators ')' | '{' Enumerators '}') {nl} * ['yield'] Expr
  212.                   |  'throw' Expr
  213.                   |  'return' [Expr]
  214.                   |  [SimpleExpr '.'] id '=' Expr
  215.                   |  SimpleExpr1 ArgumentExprs '=' Expr
  216.                   |  PostfixExpr
  217.                   |  PostfixExpr Ascription
  218.                   |  PostfixExpr 'match' '{' CaseClauses '}'
  219. PostfixExpr       ::=  InfixExpr [id [nl]]
  220. //-----------------------------------------------------------------
  221. /*InfixExpr         ::=  PrefixExpr
  222.                   |  InfixExpr id [nl] InfixExpr*/
  223. InfixExpr         ::= PrefixExpr InfixExpr_
  224.                   | PrefixExpr
  225. InfixExpr_        ::= id [nl] InfixExpr InfixExpr_
  226.                   | id [nl] InfixExpr
  227. //-----------------------------------------------------------------
  228.  
  229. PrefixExpr        ::=  ['-' | '+' | '~' | '!'] SimpleExpr
  230. SimpleExpr        ::=  'new' (ClassTemplate | TemplateBody)
  231.                   |  BlockExpr
  232.                   |  SimpleExpr1 ['_']
  233. //-----------------------------------------------------------------
  234. /*SimpleExpr1       ::=  Literal
  235.                   |  Path
  236.                   |  '_'
  237.                   |  '(' [Exprs] ')'
  238.                   |  SimpleExpr '.' id
  239.                   |  SimpleExpr TypeArgs
  240.                   |  SimpleExpr1 ArgumentExprs
  241.                   //|  XmlExpr  */                                                                                        //!!!
  242. SimpleExpr1       ::=  Literal SimpleExpr1_
  243.                   |  Path SimpleExpr1_
  244.                   |  '_' SimpleExpr1_
  245.                   |  '(' [Exprs] ')' SimpleExpr1_
  246.                   |  SimpleExpr '.' id SimpleExpr1_
  247.                   |  SimpleExpr TypeArgs SimpleExpr1_
  248.                   |  Literal
  249.                   |  Path
  250.                   |  '_'
  251.                   |  '(' [Exprs] ')'
  252.                   |  SimpleExpr '.' id
  253.                   |  SimpleExpr TypeArgs
  254. SimpleExpr1_      ::= ArgumentExprs SimpleExpr1_
  255.                   | ArgumentExprs
  256. //-----------------------------------------------------------------
  257. Exprs             ::=  Expr {',' Expr} *
  258. ArgumentExprs     ::=  '(' [Exprs] ')'
  259.                   |  '(' [Exprs ','] PostfixExpr ':' '_' '*' ')'
  260.                   |  [nl] BlockExpr
  261. BlockExpr         ::=  '{' CaseClauses '}'
  262.                   |  '{' Block '}'
  263. Block             ::=  BlockStat {semi BlockStat} * [ResultExpr]
  264. BlockStat         ::=  Import_
  265.                   |  {Annotation} * ['implicit' | 'lazy'] Def_
  266.                   |  {Annotation} * {LocalModifier} * TmplDef
  267.                   |  Expr1
  268.                   |
  269. ResultExpr        ::=  Expr1
  270.                   |  (Bindings | (['implicit'] id | '_') ':' CompoundType) '=>' Block
  271.  
  272. Enumerators       ::=  Generator {semi Generator} *
  273. Generator         ::=  Pattern1 '<-' Expr {[semi] Guard | semi Pattern1 '=' Expr} *
  274.  
  275. CaseClauses       ::=  CaseClause { CaseClause } *
  276. CaseClause        ::=  'case' Pattern [Guard] '=>' Block
  277. Guard             ::=  'if' PostfixExpr
  278.  
  279. Pattern           ::=  Pattern1 { '|' Pattern1 } *
  280. Pattern1          ::=  varid ':' TypePat
  281.                   |  '_' ':' TypePat
  282.                   |  Pattern2
  283. Pattern2          ::=  varid ['@' Pattern3]
  284.                   |  Pattern3
  285. Pattern3          ::=  SimplePattern
  286.                   |  SimplePattern { id [nl] SimplePattern } *
  287. SimplePattern     ::=  '_'
  288.                   |  varid
  289.                   |  Literal
  290.                   |  StableId
  291.                   |  StableId '(' [Patterns] ')'
  292.                   |  StableId '(' [Patterns ','] [varid '@'] '_' '*' ')'
  293.                   |  '(' [Patterns] ')'
  294.                   //|  XmlPattern                                                                                       !!!
  295. Patterns          ::=  Pattern [',' Patterns]
  296.                   |  '_' *
  297.  
  298. TypeParamClause   ::=  '[' VariantTypeParam {',' VariantTypeParam} * ']'
  299. FunTypeParamClause::=  '[' TypeParam {',' TypeParam} * ']'
  300. VariantTypeParam  ::=  {Annotation} * ['+' | '-'] TypeParam
  301. TypeParam         ::=  (id | '_') [TypeParamClause] ['>:' Type_] ['<:' Type_]
  302.                      {'<%' Type_} * {':' Type_} *
  303. ParamClauses      ::=  {ParamClause} * [[nl] '(' 'implicit' Params ')']
  304. ParamClause       ::=  [nl] '(' [Params] ')'
  305. Params            ::=  Param {',' Param} *
  306. Param             ::=  {Annotation} * id [':' ParamType] ['=' Expr]
  307. ParamType         ::=  Type_
  308.                   |  '=>' Type_
  309.                   |  Type_ '*'
  310. ClassParamClauses ::=  {ClassParamClause} *
  311.                      [[nl] '(' 'implicit' ClassParams ')']
  312. ClassParamClause  ::=  [nl] '(' [ClassParams] ')'
  313. ClassParams       ::=  ClassParam {',' ClassParam} *
  314. ClassParam        ::=  {Annotation} * {Modifier} * [('val' | 'var')]
  315.                      id ':' ParamType ['=' Expr]
  316. Bindings          ::=  '(' Binding {',' Binding} * ')'
  317. Binding           ::=  (id | '_') [':' Type_]
  318.  
  319. Modifier          ::=  LocalModifier
  320.                   |  AccessModifier
  321.                   |  'override'
  322. LocalModifier     ::=  'abstract'
  323.                   |  'final'
  324.                   |  'sealed'
  325.                   |  'implicit'
  326.                   |  'lazy'
  327. AccessModifier    ::=  ('private' | 'protected') [AccessQualifier]
  328. AccessQualifier   ::=  '[' (id | 'this') ']'
  329.  
  330. Annotation        ::=  '@' SimpleType {ArgumentExprs} *
  331. ConstrAnnotation  ::=  '@' SimpleType ArgumentExprs
  332.  
  333. TemplateBody      ::=  [nl] '{' [SelfType] TemplateStat {semi TemplateStat} * '}'
  334. TemplateStat      ::=  Import_
  335.                   |  {Annotation [nl]} * {Modifier} * Def_
  336.                   |  {Annotation [nl]} * {Modifier} * Dcl
  337.                   |  Expr
  338.                   |
  339. SelfType          ::=  id [':' Type_] '=>'
  340.                   |  'this' ':' Type_ '=>'
  341.  
  342. Import_            ::=  'import' ImportExpr {',' ImportExpr} *
  343. ImportExpr        ::=  StableId '.' (id | '_' | ImportSelectors)
  344. ImportSelectors   ::=  '{' {ImportSelector ','} * (ImportSelector | '_') '}'
  345. ImportSelector    ::=  id ['=>' id | '=>' '_']
  346.  
  347. Dcl               ::=  'val' ValDcl
  348.                   |  'var' VarDcl
  349.                   |  'def' FunDcl
  350.                   |  'type' {nl} * TypeDcl
  351.  
  352. ValDcl            ::=  ids ':' Type_
  353. VarDcl            ::=  ids ':' Type_
  354. FunDcl            ::=  FunSig [':' Type_]
  355. FunSig            ::=  id [FunTypeParamClause] ParamClauses
  356. TypeDcl           ::=  id [TypeParamClause] ['>:' Type_] ['<:' Type_]
  357.  
  358. PatVarDef         ::=  'val' PatDef
  359.                   |  'var' VarDef
  360. Def_               ::=  PatVarDef
  361.                   |  'def' FunDef
  362.                   |  'type' {nl} * TypeDef
  363.                   |  TmplDef
  364. PatDef            ::=  Pattern2 {',' Pattern2} * [':' Type_] '=' Expr
  365. VarDef            ::=  PatDef
  366.                   |  ids ':' Type_ '=' '_'
  367. FunDef            ::=  FunSig [':' Type_] '=' Expr
  368.                   |  FunSig [nl] '{' Block '}'
  369.                   |  'this' ParamClause ParamClauses
  370.                      ('=' ConstrExpr | [nl] ConstrBlock)
  371. TypeDef           ::=  id [TypeParamClause] '=' Type_
  372.  
  373. TmplDef           ::=  ['case'] 'class' ClassDef
  374.                   |  ['case'] 'object' ObjectDef
  375.                   |  'trait' TraitDef
  376. ClassDef          ::=  id [TypeParamClause] {ConstrAnnotation} * [AccessModifier]
  377.                      ClassParamClauses ClassTemplateOpt
  378. TraitDef          ::=  id [TypeParamClause] TraitTemplateOpt
  379. ObjectDef         ::=  id ClassTemplateOpt
  380. ClassTemplateOpt  ::=  'extends' ClassTemplate | [['extends'] TemplateBody]
  381. TraitTemplateOpt  ::=  'extends' TraitTemplate | [['extends'] TemplateBody]
  382. ClassTemplate     ::=  [EarlyDefs] ClassParents [TemplateBody]
  383. TraitTemplate     ::=  [EarlyDefs] TraitParents [TemplateBody]
  384. ClassParents      ::=  Constr {'with' AnnotType} *
  385. TraitParents      ::=  AnnotType {'with' AnnotType} *
  386. Constr            ::=  AnnotType {ArgumentExprs} *
  387. EarlyDefs         ::= '{' [EarlyDef {semi EarlyDef} * ] '}' 'with'
  388. EarlyDef          ::=  {Annotation [nl]} * {Modifier} * PatVarDef
  389.  
  390. ConstrExpr        ::=  SelfInvocation
  391.                   |  ConstrBlock
  392. ConstrBlock       ::=  '{' SelfInvocation {semi BlockStat} * '}'
  393. SelfInvocation    ::=  'this' ArgumentExprs {ArgumentExprs} *
  394.  
  395. TopStatSeq        ::=  TopStat {semi TopStat} *
  396. TopStat           ::=  {Annotation [nl]} * {Modifier} * TmplDef
  397.                   |  Import_
  398.                   |  Packaging
  399.                   |  PackageObject
  400.                   |
  401. Packaging         ::=  'package' QualId [nl] '{' TopStatSeq '}'
  402. PackageObject     ::=  'package' 'object' ObjectDef
  403.  
  404. CompilationUnit   ::=  {'package' QualId semi} * TopStatSeq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement