Advertisement
Guest User

Untitled

a guest
Jul 5th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BNF 13.63 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.       digit='regexp:[0-9]'
  17.       crlf='regexp:\n|\r|\r\n'
  18.       upper='regexp:[A-Z]'
  19.       lower='regexp:[a-z]'
  20.       nonZeroDigit='regexp:[1-9]'
  21.       hexDigit='regexp:[0-9a-fA-F]'
  22.       zero='0'
  23.       HEX='regexp:[xX]'
  24.       LEFT_BRACE="{"
  25.       RIGHT_BRACE="}"
  26.       LEFT_BRACKET="["
  27.       RIGHT_BRACKET="]"
  28.       LEFT_PAREN="("
  29.       RIGHT_PAREN=")"
  30.       SEMICOLON=";"
  31.       DOT="."
  32.       COMMA=","
  33.       Q_MARK='"'
  34.       Q_MARK_2="'"
  35.       COLON=":"
  36.       UNDERSCORE="_"
  37.       EQ='='
  38.       TO='=>'
  39.       LARROW='<-'
  40.       LL='<:'
  41.       RR='>:'
  42.       SHARP='#'
  43.       AT='@'
  44.       LLL='<%'
  45.       EPT='!'
  46.       TLD='~'
  47.       space='regexp:\s'
  48.       SLASH='\'
  49.       L='regexp:[lL]'
  50.       floatType='regexp:[fFdD]'
  51.       EXP='regexp:[eE]'
  52.       abstract="abstract"
  53.       case="case"
  54.       catch="catch"
  55.       class="class"
  56.       def="def"
  57.       do="do"
  58.       else="else"
  59.       extends="extends"
  60.       false="false"
  61.       final="final"
  62.       finally="finally"
  63.       for="for"
  64.       forSome="forSome"
  65.       if="if"
  66.       implicit="implicit"
  67.       import="import"
  68.       lazy="lazy"
  69.       macro="macro"
  70.       match="match"
  71.       new="new"
  72.       null="null"
  73.       object="object"
  74.       override="override"
  75.       package="package"
  76.       private="private"
  77.       protected="protected"
  78.       return="return"
  79.       sealed="sealed"
  80.       super="super"
  81.       this="this"
  82.       throw="throw"
  83.       trait="trait"
  84.       try="try"
  85.       true="true"
  86.       type="type"
  87.       val="val"
  88.       var="var"
  89.       while="while"
  90.       with="with"
  91.       yield="yield"
  92.       op_1='+'
  93.       op_2='-'
  94.       op_3='*'
  95.       op_4='/'
  96.       comment='regexp://.*'
  97.       any='regexp:.'
  98.   ]
  99.  
  100. }
  101.  
  102. Program          ::= Def_                                              // Start Symbol - BlockExpr ???
  103.  
  104. letter           ::=  upper | lower // and Unicode categories Lo, Lt, Nl
  105. paren            ::=  '(' | ')' | '[' | ']' | '{' | '}'
  106. delim            ::=  "'" | '"' | '.' | ';' | ','
  107. opchar           ::=  !(space | upper | lower | digit | paren | delim) any
  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. decimalNumeral   ::=  '0' | nonZeroDigit {digit} *
  122. hexNumeral       ::=  '0' HEX hexDigit {hexDigit} *
  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. SimpleType        ::=  SimpleType TypeArgs
  177.                   |  SimpleType '#' id
  178.                   |  StableId
  179.                   |  Path '.' 'type'
  180.                   |  '(' Types ')'
  181. TypeArgs          ::=  '[' Types ']'
  182. Types             ::=  Type_ {',' Type_} *
  183. Refinement        ::=  [nl] '{' RefineStat {semi RefineStat} * '}'
  184. RefineStat        ::=  Dcl
  185.                   |  'type' TypeDef
  186.                   |
  187. TypePat           ::=  Type_
  188.  
  189. Ascription        ::=  ':' InfixType
  190.                   |  ':' Annotation {Annotation} *
  191.                   |  ':' '_' '*'
  192.  
  193. Expr              ::=  (Bindings | ['implicit'] id | '_') '=>' Expr
  194.                   |  Expr1
  195. Expr1             ::=  'if' '(' Expr ')' {nl} * Expr [[semi] 'else' Expr]
  196.                   |  'while' '(' Expr ')' {nl} * Expr
  197.                   |  'try' ('{' Block '}' | Expr) ['catch' '{' CaseClauses '}'] ['finally' Expr]
  198.                   |  'do' Expr [semi] 'while' '(' Expr ')'
  199.                   |  'for' ('(' Enumerators ')' | '{' Enumerators '}') {nl} * ['yield'] Expr
  200.                   |  'throw' Expr
  201.                   |  'return' [Expr]
  202.                   |  [SimpleExpr '.'] id '=' Expr
  203.                   |  SimpleExpr1 ArgumentExprs '=' Expr
  204.                   |  PostfixExpr
  205.                   |  PostfixExpr Ascription
  206.                   |  PostfixExpr 'match' '{' CaseClauses '}'
  207. PostfixExpr       ::=  InfixExpr [id [nl]]
  208. InfixExpr         ::=  PrefixExpr
  209.                   |  InfixExpr id [nl] InfixExpr
  210. PrefixExpr        ::=  ['-' | '+' | '~' | '!'] SimpleExpr
  211. SimpleExpr        ::=  'new' (ClassTemplate | TemplateBody)
  212.                   |  BlockExpr
  213.                   |  SimpleExpr1 ['_']
  214. SimpleExpr1       ::=  Literal
  215.                   |  Path
  216.                   |  '_'
  217.                   |  '(' [Exprs] ')'
  218.                   |  SimpleExpr '.' id
  219.                   |  SimpleExpr TypeArgs
  220.                   |  SimpleExpr1 ArgumentExprs
  221.                   //|  XmlExpr                                                                                          !!!
  222. Exprs             ::=  Expr {',' Expr} *
  223. ArgumentExprs     ::=  '(' [Exprs] ')'
  224.                   |  '(' [Exprs ','] PostfixExpr ':' '_' '*' ')'
  225.                   |  [nl] BlockExpr
  226. BlockExpr         ::=  '{' CaseClauses '}'
  227.                   |  '{' Block '}'
  228. Block             ::=  BlockStat {semi BlockStat} * [ResultExpr]
  229. BlockStat         ::=  Import_
  230.                   |  {Annotation} * ['implicit' | 'lazy'] Def_
  231.                   |  {Annotation} * {LocalModifier} * TmplDef
  232.                   |  Expr1
  233.                   |
  234. ResultExpr        ::=  Expr1
  235.                   |  (Bindings | (['implicit'] id | '_') ':' CompoundType) '=>' Block
  236.  
  237. Enumerators       ::=  Generator {semi Generator} *
  238. Generator         ::=  Pattern1 '<-' Expr {[semi] Guard | semi Pattern1 '=' Expr} *
  239.  
  240. CaseClauses       ::=  CaseClause { CaseClause } *
  241. CaseClause        ::=  'case' Pattern [Guard] '=>' Block
  242. Guard             ::=  'if' PostfixExpr
  243.  
  244. Pattern           ::=  Pattern1 { '|' Pattern1 } *
  245. Pattern1          ::=  varid ':' TypePat
  246.                   |  '_' ':' TypePat
  247.                   |  Pattern2
  248. Pattern2          ::=  varid ['@' Pattern3]
  249.                   |  Pattern3
  250. Pattern3          ::=  SimplePattern
  251.                   |  SimplePattern { id [nl] SimplePattern } *
  252. SimplePattern     ::=  '_'
  253.                   |  varid
  254.                   |  Literal
  255.                   |  StableId
  256.                   |  StableId '(' [Patterns] ')'
  257.                   |  StableId '(' [Patterns ','] [varid '@'] '_' '*' ')'
  258.                   |  '(' [Patterns] ')'
  259.                   //|  XmlPattern                                                                                       !!!
  260. Patterns          ::=  Pattern [',' Patterns]
  261.                   |  '_' *
  262.  
  263. TypeParamClause   ::=  '[' VariantTypeParam {',' VariantTypeParam} * ']'
  264. FunTypeParamClause::=  '[' TypeParam {',' TypeParam} * ']'
  265. VariantTypeParam  ::=  {Annotation} * ['+' | '-'] TypeParam
  266. TypeParam         ::=  (id | '_') [TypeParamClause] ['>:' Type_] ['<:' Type_]
  267.                      {'<%' Type_} * {':' Type_} *
  268. ParamClauses      ::=  {ParamClause} * [[nl] '(' 'implicit' Params ')']
  269. ParamClause       ::=  [nl] '(' [Params] ')'
  270. Params            ::=  Param {',' Param} *
  271. Param             ::=  {Annotation} * id [':' ParamType] ['=' Expr]
  272. ParamType         ::=  Type_
  273.                   |  '=>' Type_
  274.                   |  Type_ '*'
  275. ClassParamClauses ::=  {ClassParamClause} *
  276.                      [[nl] '(' 'implicit' ClassParams ')']
  277. ClassParamClause  ::=  [nl] '(' [ClassParams] ')'
  278. ClassParams       ::=  ClassParam {',' ClassParam} *
  279. ClassParam        ::=  {Annotation} * {Modifier} * [('val' | 'var')]
  280.                      id ':' ParamType ['=' Expr]
  281. Bindings          ::=  '(' Binding {',' Binding} * ')'
  282. Binding           ::=  (id | '_') [':' Type_]
  283.  
  284. Modifier          ::=  LocalModifier
  285.                   |  AccessModifier
  286.                   |  'override'
  287. LocalModifier     ::=  'abstract'
  288.                   |  'final'
  289.                   |  'sealed'
  290.                   |  'implicit'
  291.                   |  'lazy'
  292. AccessModifier    ::=  ('private' | 'protected') [AccessQualifier]
  293. AccessQualifier   ::=  '[' (id | 'this') ']'
  294.  
  295. Annotation        ::=  '@' SimpleType {ArgumentExprs} *
  296. ConstrAnnotation  ::=  '@' SimpleType ArgumentExprs
  297.  
  298. TemplateBody      ::=  [nl] '{' [SelfType] TemplateStat {semi TemplateStat} * '}'
  299. TemplateStat      ::=  Import_
  300.                   |  {Annotation [nl]} * {Modifier} * Def_
  301.                   |  {Annotation [nl]} * {Modifier} * Dcl
  302.                   |  Expr
  303.                   |
  304. SelfType          ::=  id [':' Type_] '=>'
  305.                   |  'this' ':' Type_ '=>'
  306.  
  307. Import_            ::=  'import' ImportExpr {',' ImportExpr} *
  308. ImportExpr        ::=  StableId '.' (id | '_' | ImportSelectors)
  309. ImportSelectors   ::=  '{' {ImportSelector ','} * (ImportSelector | '_') '}'
  310. ImportSelector    ::=  id ['=>' id | '=>' '_']
  311.  
  312. Dcl               ::=  'val' ValDcl
  313.                   |  'var' VarDcl
  314.                   |  'def' FunDcl
  315.                   |  'type' {nl} * TypeDcl
  316.  
  317. ValDcl            ::=  ids ':' Type_
  318. VarDcl            ::=  ids ':' Type_
  319. FunDcl            ::=  FunSig [':' Type_]
  320. FunSig            ::=  id [FunTypeParamClause] ParamClauses
  321. TypeDcl           ::=  id [TypeParamClause] ['>:' Type_] ['<:' Type_]
  322.  
  323. PatVarDef         ::=  'val' PatDef
  324.                   |  'var' VarDef
  325. Def_               ::=  PatVarDef
  326.                   |  'def' FunDef
  327.                   |  'type' {nl} * TypeDef
  328.                   |  TmplDef
  329. PatDef            ::=  Pattern2 {',' Pattern2} * [':' Type_] '=' Expr
  330. VarDef            ::=  PatDef
  331.                   |  ids ':' Type_ '=' '_'
  332. FunDef            ::=  FunSig [':' Type_] '=' Expr
  333.                   |  FunSig [nl] '{' Block '}'
  334.                   |  'this' ParamClause ParamClauses
  335.                      ('=' ConstrExpr | [nl] ConstrBlock)
  336. TypeDef           ::=  id [TypeParamClause] '=' Type_
  337.  
  338. TmplDef           ::=  ['case'] 'class' ClassDef
  339.                   |  ['case'] 'object' ObjectDef
  340.                   |  'trait' TraitDef
  341. ClassDef          ::=  id [TypeParamClause] {ConstrAnnotation} * [AccessModifier]
  342.                      ClassParamClauses ClassTemplateOpt
  343. TraitDef          ::=  id [TypeParamClause] TraitTemplateOpt
  344. ObjectDef         ::=  id ClassTemplateOpt
  345. ClassTemplateOpt  ::=  'extends' ClassTemplate | [['extends'] TemplateBody]
  346. TraitTemplateOpt  ::=  'extends' TraitTemplate | [['extends'] TemplateBody]
  347. ClassTemplate     ::=  [EarlyDefs] ClassParents [TemplateBody]
  348. TraitTemplate     ::=  [EarlyDefs] TraitParents [TemplateBody]
  349. ClassParents      ::=  Constr {'with' AnnotType} *
  350. TraitParents      ::=  AnnotType {'with' AnnotType} *
  351. Constr            ::=  AnnotType {ArgumentExprs} *
  352. EarlyDefs         ::= '{' [EarlyDef {semi EarlyDef} * ] '}' 'with'
  353. EarlyDef          ::=  {Annotation [nl]} * {Modifier} * PatVarDef
  354.  
  355. ConstrExpr        ::=  SelfInvocation
  356.                   |  ConstrBlock
  357. ConstrBlock       ::=  '{' SelfInvocation {semi BlockStat} * '}'
  358. SelfInvocation    ::=  'this' ArgumentExprs {ArgumentExprs} *
  359.  
  360. TopStatSeq        ::=  TopStat {semi TopStat} *
  361. TopStat           ::=  {Annotation [nl]} * {Modifier} * TmplDef
  362.                   |  Import_
  363.                   |  Packaging
  364.                   |  PackageObject
  365.                   |
  366. Packaging         ::=  'package' QualId [nl] '{' TopStatSeq '}'
  367. PackageObject     ::=  'package' 'object' ObjectDef
  368.  
  369. CompilationUnit   ::=  {'package' QualId semi} * TopStatSeq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement