# Main region. lex token DEF / 'def' / token LEX / 'lex' / token END / 'end' / token TOKEN / 'token' / token RL / 'rl' / token IGNORE / 'ignore' / token PRINT / 'print' / token PRINTS / 'prints' / token PRINT_XML / 'print_xml' / token PRINT_XML_AC / 'print_xml_ac' / token PARSE / 'parse' / token PARSE_STOP / 'parse_stop' / token CONS / 'construct' | 'cons' / token MATCH / 'match' / token REQUIRE / 'require' / token SEND / 'send' / token NAMESPACE / 'namespace' / token FOR / 'for' / token IF / 'if' / token YIELD / 'yield' / token WHILE / 'while' / token ELSIF / 'elsif' / token ELSE / 'else' / token IN / 'in' / token PARSER / 'parser' | 'accum' / token LIST / 'list' / token VECTOR / 'vector' / token MAP / 'map' / token PTR / 'ptr' / token ITER / 'iter' / token REF / 'ref' / token EXPORT / 'export' / token RETURN / 'return' / token BREAK / 'break' / token REJECT / 'reject' / token REDUCEFIRST / 'reducefirst' / token ALIAS / 'alias' / token COMMIT / 'commit' / token NEW / 'new' / token PREEOF / 'preeof' / token GLOBAL / 'global' / token EOS / 'eos' / token MAKE_TOKEN / 'make_token' / token MAKE_TREE / 'make_tree' / token TYPEID / 'typeid' / token LITERAL /'literal'/ token CONTEXT /'context'/ token NI /'ni'/ token NIL / 'nil' / token TRUE / 'true' / token FALSE / 'false' / token LEFT /'left'/ token RIGHT /'right'/ token NONASSOC /'nonassoc'/ token INCLUDE /'include'/ token id / ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) . ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' ) * / token number / ( '0' .. '9' ) + / token lit / '\'' . ( ^( '\'' | '\\' ) | '\\' . any )* . '\'' / token DQ / '\"' / ni token TILDE / '~' / ni token SQOPEN /'['/ token SQCLOSE /']'/ token BAR /'|'/ token FSLASH /'/'/ token COLON /':'/ token DOUBLE_COLON /'::'/ token DOT /'.'/ token ARROW /'->'/ token POPEN /'('/ token PCLOSE /')'/ token COPEN /'{'/ token CCLOSE /'}'/ token STAR /'*'/ token QUESTION /'?'/ token EQUALS /'='/ token EQEQ /'=='/ token NEQ /'!='/ token COMMA /','/ token LT /'<'/ token GT /'>'/ token LTEQ /'<='/ token GTEQ /'>='/ token BANG /'!'/ token DOLLAR /'$'/ token CARET /'^'/ token PERCENT /'%'/ token PLUS /'+'/ token MINUS /'-'/ token AMPAMP /'&&'/ token BARBAR /'||'/ ignore / ( '\n' | '\t' | ' ' )+ / ignore / '#' . ( ^'\n' )* . '\n' / end lex token CONS_DQ / '\"' / token CONS_NL / '\n' / token CONS_SQOPEN / '[' / token CONS_SQCLOSE / ']' / token cons_data / ( ^( '\n' | '\"' | '[' | ']' | '\\' ) | '\\' . any )+ / end lex token TILDE_NL / '\n' / token tilde_data / ( ^'\n' )+ / end lex token lex_id / ( 'a' .. 'z' | 'A' .. 'Z' | '_' ) . ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '_' ) * / token lex_uint / ( '0' .. '9' )+ / token lex_hex / '0x' . ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ / token lex_lit / '\'' . ( ^( '\'' | '\\' ) | '\\' . any )* . ( '\'' | '\'i' ) | '\"' . ( ^( '\"' | '\\' ) | '\\' . any )* . ( '\"' | '\"i' ) / token LEX_DOT /'.'/ token LEX_BAR /'|'/ token LEX_AMP /'&'/ token LEX_DASH /'-'/ token LEX_POPEN /'('/ token LEX_PCLOSE /')'/ token LEX_STAR /'*'/ token LEX_STARSTAR /'**'/ token LEX_QUESTION /'?'/ token LEX_PLUS /'+'/ token LEX_CARET /'^'/ token LEX_DOTDOT /'..'/ token LEX_SQOPEN_POS /'['/ ni token LEX_SQOPEN_NEG /'[^'/ ni token LEX_FSLASH /'/'/ token LEX_DASHDASH /'--'/ token LEX_COLON_GT /':>'/ token LEX_COLON_GTGT /':>>'/ token LEX_LT_COLON /'<:'/ ignore / ( '\n' | '\t' | ' ' ) . ( '\n' | '\t' | ' ' )* / ignore / '#' . ( ^'\n' )* . '\n' / end lex token RE_DASH / '-' / token RE_CHAR / ^( '\\' | '-' | ']' ) | '\\' . any / token RE_SQCLOSE / ']' / end def start [RootItemList: root_item*] def root_item [RlDef: rl_def] :Rl commit | [LiteralDef: literal_def] :Literal commit | [TokenDef: token_def] :Token commit | [IgnoreDef: ignore_def] :Ignore commit | [CflDef: cfl_def] :Cfl commit | [RegionDef: region_def] :Region commit | [ContextDef: context_def] :Context commit | [NamespaceDef: namespace_def] :Namespace commit | [FunctionDef: function_def] :Function commit | [IterDef: iter_def] :Iter commit | [Statement: statement] :Statement commit | [GlobalDef: global_def] :Global commit | [ExportDef: export_def] :Export commit | [PreEofDef: pre_eof_def] :PreEof commit | [PrecedenceDef: precedence_def] :Precedence commit | [AliasDef: alias_def] :Alias commit | [Include: include] :Include commit def include [INCLUDE File: lit] def precedence_def [PredType: pred_type PredTokenList: pred_token_list] def pred_type [Left: LEFT] | [Right: RIGHT] | [NonAssoc: NONASSOC] def pred_token_list [PredTokenList: pred_token_list COMMA PredToken: pred_token] | [PredToken: pred_token] def pred_token [RegionQual: region_qual Id: id] | [RegionQual: region_qual Lit: lit] def pre_eof_def [PreEof: PREEOF COPEN LangStmtList: lang_stmt_list CCLOSE] def alias_def [ALIAS Id: id TypeRef: type_ref] def context_item [ContextVarDef: context_var_def] :ContextVar commit | [LiteralDef: literal_def] :Literal commit | [RlDef: rl_def] :Rl commit | [TokenDef: token_def] :Token commit | [IgnoreDef: ignore_def] :Ignore commit | [CflDef: cfl_def] :Cfl commit | [RegionDef: region_def] :Region commit | [ContextDef: context_def] :Context commit | [FunctionDef: function_def] :Function commit | [IterDef: iter_def] :Iter commit | [ExportDef: export_def] :Export commit | [PreEofDef: pre_eof_def] :PreEof commit | [PrecedenceDef: precedence_def] :Precedence commit def export_def [EXPORT VarDef: var_def OptDefInit: opt_def_init] def global_def [GLOBAL VarDef: var_def OptDefInit: opt_def_init] def iter_def [ITER Id: id POPEN ParamVarDefList: param_var_def* PCLOSE COPEN LangStmtList: lang_stmt_list CCLOSE] def reference_type_ref [R: REF LT TypeRef: type_ref GT] def param_var_def [Id: id COLON TypeRef: type_ref] | [Id: id COLON RefTypeRef: reference_type_ref] def opt_export [Export: EXPORT] | [] def function_def [OptExport: opt_export TypeRef: type_ref Id: id POPEN ParamVarDefList: param_var_def* PCLOSE COPEN LangStmtList: lang_stmt_list CCLOSE] def context_var_def [VarDef: var_def] def context_def [CONTEXT Name: id ContextItemList: context_item* END] def literal_def [LITERAL LiteralList: literal_list] def literal_list [LiteralList: literal_list COMMA LiteralItem: literal_item] | [LiteralItem: literal_item] def literal_item [NiLeft: opt_no_ignore Lit: lit NiRight: opt_no_ignore] def opt_no_ignore [Ni: NI] | [] def namespace_def [NAMESPACE Name: id RootItemList: root_item* END] def obj_var_list [] def opt_reduce_first [ReduceFirst: REDUCEFIRST] | [] def cfl_def [DEF DefId: id VarDefList: var_def* OptReduceFirst: opt_reduce_first ProdList: prod_list] def region_def [LEX RootItemList: root_item* END] def rl_def [RL Id: id LEX_FSLASH Expr: lex_expr LEX_FSLASH] def opt_lex_expr [Expr: lex_expr] | [] def token_def [TOKEN Id: id VarDefList: var_def* NiLeft: opt_no_ignore LEX_FSLASH OptExpr: opt_lex_expr LEX_FSLASH NiRight: opt_no_ignore OptTranslate: opt_translate] def opt_translate [COPEN LangStmtList: lang_stmt_list CCLOSE] | [] def opt_id [Id: id] | [] def ignore_def [I: IGNORE OptId: opt_id LEX_FSLASH OptExpr: opt_lex_expr LEX_FSLASH] def prod_el [OptName: opt_prod_el_name RegionQual: region_qual Id: id OptRepeat: opt_repeat] | [OptName: opt_prod_el_name RegionQual: region_qual Lit: lit OptRepeat: opt_repeat] def opt_prod_el_name [Name: id COLON] | [] def prod_el_list [ProdElList: prod_el_list ProdEl: prod_el] | [] def opt_commit [Commit: COMMIT] | [] def opt_prod_name [COLON Name: id] | [] def prod [Open: SQOPEN ProdElList: prod_el_list SQCLOSE OptName: opt_prod_name OptCommit: opt_commit OptReduce: opt_reduce] def opt_reduce [COPEN LangStmtList: lang_stmt_list CCLOSE] | [] def prod_list [ProdList: prod_list BAR Prod: prod] | [Prod: prod] def statement [Print: print_stmt] | [Expr: expr_stmt] | [VarDef: var_def OptDefInit: opt_def_init] | [FOR ForDecl: id COLON TypeRef: type_ref IN IterCall: iter_call BlockOrSingle: block_or_single] | [IF IfExpr: code_expr BlockOrSingle: block_or_single ElsifList: elsif_list] | [WHILE WhileExpr: code_expr BlockOrSingle: block_or_single] | [LhsVarRef: var_ref EQUALS CodeExpr: code_expr] | [YIELD YieldVarRef: var_ref] | [RETURN ReturnExpr: code_expr] | [Break: BREAK] | [Reject: REJECT] def elsif_list [ElsifClause: elsif_clause ElsifList: elsif_list] | [OptionalElse: optional_else] def elsif_clause [ELSIF ElsifExpr: code_expr BlockOrSingle: block_or_single] def optional_else [ELSE BlockOrSingle: block_or_single] | [] def iter_call [E1 VarRef: var_ref POPEN CodeExprList: code_expr* PCLOSE] | [E2 Id: id] | [E3 Expr: code_expr] def block_or_single [COPEN LangStmtList: lang_stmt_list CCLOSE] | [Statement: statement] def require_pattern [R: REQUIRE VarRef: var_ref Pattern: pattern] def opt_require_stmt [Require: require_pattern LangStmtList: lang_stmt_list] | [] def lang_stmt_list [StmtList: statement* OptRequire: opt_require_stmt] def opt_def_init [EQUALS CodeExpr: code_expr] | [] def var_def [Id: id COLON TypeRef: type_ref] def print_stmt [Tree: PRINT O: POPEN CodeExprList: code_expr* PCLOSE] | [PrintStream: PRINTS O: POPEN CodeExprList: code_expr* PCLOSE] | [Xml: PRINT_XML O: POPEN CodeExprList: code_expr* PCLOSE] | [XmlAc: PRINT_XML_AC O: POPEN CodeExprList: code_expr* PCLOSE] def expr_stmt [CodeExpr: code_expr] def code_expr [Expr: code_expr AmpAmp: AMPAMP Relational: code_relational] | [Expr: code_expr BarBar: BARBAR Relational: code_relational] | [Relational: code_relational] def code_relational [Relational: code_relational EqEq: EQEQ Additive: code_additive] | [Relational: code_relational Neq: NEQ Additive: code_additive] | [Relational: code_relational Lt: LT Additive: code_additive] | [Relational: code_relational Gt: GT Additive: code_additive] | [Relational: code_relational LtEq: LTEQ Additive: code_additive] | [Relational: code_relational GtEq: GTEQ Additive: code_additive] | [Additive: code_additive] def code_additive [Additive: code_additive Plus: PLUS Multiplicitive: code_multiplicitive] | [Additive: code_additive Minus: MINUS Multiplicitive: code_multiplicitive] | [Multiplicitive: code_multiplicitive] def code_multiplicitive [Multiplicitive: code_multiplicitive Star: STAR Unary: code_unary] | [Multiplicitive: code_multiplicitive Fslash: FSLASH Unary: code_unary] | [Unary: code_unary] def code_unary [Bang: BANG Factor: code_factor] | [Dollar: DOLLAR Factor: code_factor] | [Caret: CARET Factor: code_factor] | [Percent: PERCENT Factor: code_factor] | [Factor: code_factor] def opt_eos [Eos: DOT] | [Eos: EOS] | [] def code_factor [Number: number] | [Lit: lit] | [VarRef: var_ref POPEN CodeExprList: code_expr* PCLOSE] | [VarRef: var_ref] | [Nil: NIL] | [True: TRUE] | [False: FALSE] | [POPEN ParenCodeExpr: code_expr PCLOSE] | [Send: SEND ToVarRef: var_ref Accumulate: accumulate OptEos: opt_eos] | [Parse: PARSE OptCapture: opt_capture TypeRef: type_ref OptFieldInit: opt_field_init Accumulate: accumulate] | [ParseStop: PARSE_STOP OptCapture: opt_capture TypeRef: type_ref OptFieldInit: opt_field_init Accumulate: accumulate] | [Cons: CONS OptCapture: opt_capture TypeRef: type_ref OptFieldInit: opt_field_init Constructor: constructor] | [MATCH MatchVarRef: var_ref Pattern: pattern] | [String: cstring] | [TypeRef: type_ref IN InVarRef: var_ref] | [MAKE_TREE POPEN MakeTreeExprList: code_expr* PCLOSE] | [MAKE_TOKEN POPEN MakeTokenExprList: code_expr* PCLOSE] | [TYPEID LT TypeIdTypeRef: type_ref GT] | [NEW NewCodeFactor: code_factor] def type_ref [RegionQual: region_qual DirectId: id OptRepeat: opt_repeat] | [PTR LT RegionQual: region_qual PtrId: id OptRepeat: opt_repeat GT] | [MAP LT MapKeyType: type_ref MapValueType: type_ref GT] | [LIST LT ListType: type_ref GT] | [VECTOR LT VectorType: type_ref GT] | [PARSER LT ParserType: type_ref GT] def region_qual [RegionQual: region_qual Id: id DOUBLE_COLON] | [] def opt_repeat [Star: STAR] | [Plus: PLUS] | [Question: QUESTION] | [] def opt_capture [Id: id COLON] | [] def opt_field_init [POPEN FieldInitList: field_init* PCLOSE] | [] def field_init [CodeExpr: code_expr] # # Pattern # def opt_label [Id: id COLON] | [] def dq_lit_term [CONS_DQ] | [Nl: CONS_NL] def opt_tilde_data [tilde_data] | [] def pattern_el_lel [RegionQual: region_qual Id: id OptRepeat: opt_repeat] | [RegionQual: region_qual Lit: lit OptRepeat: opt_repeat] def pattern_el [OptLabel: opt_label TypeOrLit: pattern_el_lel] | [DQ LitpatElList: litpat_el* Term: dq_lit_term] | [TILDE TildeData: opt_tilde_data Nl: TILDE_NL] def litpat_el [ConsData: cons_data] | [CONS_SQOPEN PatternElList: pattern_el* CONS_SQCLOSE] def pattern_top_el [DQ LitpatElList: litpat_el* Term: dq_lit_term] | [TILDE TildeData: opt_tilde_data Nl: TILDE_NL] | [SQOPEN PatternElList: pattern_el* SQCLOSE] def pattern_list [PatternList: pattern_list PatternTopEl: pattern_top_el] | [PatternTopEl: pattern_top_el] def pattern [PatternList: pattern_list] # # Constructor List # def E1 [] def E2 [] def E3 [] def cons_el [E1 RegionQual: region_qual Lit: lit] | [E1 DQ LitConsElList: lit_cons_el* Term: dq_lit_term] | [E1 TILDE TildeData: opt_tilde_data Nl: TILDE_NL] | [E2 CodeExpr: code_expr] def lit_cons_el [ConsData: cons_data] | [CONS_SQOPEN ConsElList: cons_el* CONS_SQCLOSE] def cons_top_el [DQ LitConsElList: lit_cons_el* Term: dq_lit_term] | [TILDE TildeData: opt_tilde_data Nl: TILDE_NL] | [SQOPEN ConsElList: cons_el* SQCLOSE] def cons_list [ConsTopEl: cons_top_el ConsList: cons_list] | [ConsTopEl: cons_top_el] def constructor [ConsList: cons_list] # # Accumulate # def accum_el [E1 DQ LitAccumElList: lit_accum_el* Term: dq_lit_term] | [E1 TILDE TildeData: opt_tilde_data Nl: TILDE_NL] | [E2 CodeExpr: code_expr] def lit_accum_el [ConsData: cons_data] | [CONS_SQOPEN AccumElList: accum_el* CONS_SQCLOSE] def accum_top_el [DQ LitAccumElList: lit_accum_el* Term: dq_lit_term] | [TILDE TildeData: opt_tilde_data Nl: TILDE_NL] | [SQOPEN AccumElList: accum_el* SQCLOSE] def accum_list [AccumTopEl: accum_top_el AccumList: accum_list] | [AccumTopEl: accum_top_el] def accumulate [AccumList: accum_list] # # String List # def string_el [E1 DQ LitStringElList: lit_string_el* Term: dq_lit_term] | [E1 TILDE TildeData: opt_tilde_data Nl: TILDE_NL] | [E2 CodeExpr: code_expr] def lit_string_el [ConsData: cons_data] | [CONS_SQOPEN StringElList: string_el* CONS_SQCLOSE] def string_top_el [DQ LitStringElList: lit_string_el* Term: dq_lit_term] | [TILDE TildeData: opt_tilde_data Nl: TILDE_NL] | [SQOPEN StringElList: string_el* SQCLOSE] def string_list [StringTopEl: string_top_el StringList: string_list] | [StringTopEl: string_top_el] def cstring [StringList: string_list] # # Variable References # def var_ref [Qual: qual Id: id] def qual [Qual: qual Id: id Dot: DOT] | [Qual: qual Id: id Arrow: ARROW] | [] # # Lexical analysis. # def lex_expr [Expr: lex_expr LEX_BAR Term: lex_term] :Bar | [Expr: lex_expr LEX_AMP Term: lex_term] :Amp | [Expr: lex_expr LEX_DASH Term: lex_term] :Dash | [Expr: lex_expr LEX_DASHDASH Term: lex_term] :DashDash | [Term: lex_term] :Base def opt_lex_dot [LEX_DOT] | [] def lex_term [Term: lex_term opt_lex_dot FactorRep: lex_factor_rep] :Dot | [Term: lex_term LEX_COLON_GT FactorRep: lex_factor_rep] :ColonGt | [Term: lex_term LEX_COLON_GTGT FactorRep: lex_factor_rep] :ColonGtGt | [Term: lex_term LEX_LT_COLON FactorRep: lex_factor_rep] :LtColon | [FactorRep: lex_factor_rep] :Base def lex_factor_rep [FactorRep: lex_factor_rep Star: LEX_STAR] :Star | [FactorRep: lex_factor_rep StarStar: LEX_STARSTAR] :StarStar | [FactorRep: lex_factor_rep Plus: LEX_PLUS] :Plus | [FactorRep: lex_factor_rep Question: LEX_QUESTION] :Question | [FactorRep: lex_factor_rep COPEN Exact: lex_uint CCLOSE ] :Exact | [FactorRep: lex_factor_rep COPEN COMMA Max: lex_uint CCLOSE ] :Max | [FactorRep: lex_factor_rep COPEN Min: lex_uint COMMA CCLOSE ] :Min | [FactorRep: lex_factor_rep COPEN Low: lex_uint COMMA High: lex_uint CCLOSE ] :Range | [FactorNeg: lex_factor_neg] :Base def lex_factor_neg [LEX_CARET FactorNeg: lex_factor_neg] :Caret | [Factor: lex_factor] :Base def lex_range_lit [Lit: lex_lit] :Lit | [Number: lex_num] :Number def lex_num [lex_uint] | [lex_hex] #| [LEX_DASH num] def lex_factor [Literal: lex_lit] :Literal | [Id: lex_id] :Id | [Number: lex_uint] :Number | [Hex: lex_hex] :Hex | [Low: lex_range_lit LEX_DOTDOT High: lex_range_lit] :Range | [LEX_SQOPEN_POS PosData: reg_or_data RE_SQCLOSE] :PosOrBlock | [LEX_SQOPEN_NEG NegData: reg_or_data RE_SQCLOSE] :NegOrBlock | [LEX_POPEN Expr: lex_expr LEX_PCLOSE] :Paren def reg_or_data [Data: reg_or_data Char: reg_or_char] :Data | [] :Base def reg_or_char [Char: RE_CHAR] :Char | [Low: RE_CHAR RE_DASH High: RE_CHAR] :Range