/* rfpllgr.g */ /* This file contains the LL(1) grammar that is actually used in */ /* the Refal Plus compiler written by R.F.Gurin & S.A.Romanenko. */ /* The annotated version of this grammar (contained in the file */ /* "rfpllgr.f") was produced by executing the command: */ /* gr.exe rfpllgr.g >rfpllgr.f */ %token SC COMMA %token LPAR RPAR %token LANGU RANGU %token LCURL RCURL %token MODULE %token USE %token PUBLIC %token OBJ_DECL FUNC_DECL MATCH_DIR %token NATIVE %token CONST FAIL ITER %token TRAP WITH %token COL COL_CURL LET NOT EQL REF %token FENCE CUT ERROR %token TRACE_ALL %token CHAR WORD NUMB %token VAR %token INTERFACE IMPLEMENTATION %% program : IMPLEMENTATION implem | INTERFACE interf ; implem : module_name imports directives ; interf : module_name decls ; module_name : /* empty */ | MODULE name SC ; imports : USE names SC imports | /* empty */ ; directives : directive SC directives | /* empty */ ; directive : decl | func_def | native | trace_all ; decls : decl SC decls | /* empty */ ; decl : PUBLIC private_decl | private_decl ; private_decl : obj_decl | const_decl | func_decl ; obj_decl : OBJ_DECL names ; const_decl : CONST const_bindings ; const_bindings : const_binding const_bindings_tail | /* empty */ ; const_bindings_tail : COMMA const_binding const_bindings_tail | /* empty */ ; const_binding : name EQL exp ; func_decl : FUNC_DECL name exp EQL exp ; native : NATIVE native_block ; native_block : LCURL native_sentences RCURL | native_sentence ; native_sentences : native_sentence SC native_sentences | /* empty */ ; native_sentence : name EQL name ; trace_all : TRACE_ALL ; func_def : name sentence ; sentence : pattern_alt pattern_alts path_tail | pattern rest ; path : source path_tail ; path_tail : COL sentence | iter let rest /* if nothing then no empty let and rest */ ; iter : ITER source | /* empty */ ; let : LET exp | /* empty == LET 'empty exp' */ ; rest : COMMA path | FENCE path | CUT path | ERROR path | EQL path | NOT source rest | FAIL | TRAP path WITH sentence | /* empty == COMMA 'empty exp' */ ; source : alt pattern_alts | exp pattern_alts ; pattern_alts : COL_CURL pattern_alt pattern_alts | /* empty */ ; pattern : MATCH_DIR exp | exp ; pattern_alt : LCURL sentences RCURL ; sentences : sentence SC sentences | /* empty */ ; alt : LCURL paths RCURL ; paths : path SC paths | /* empty */ ; exp : exp_head exp | /* empty */ ; exp_head : REF name | static_symbol | LPAR exp RPAR | VAR | LANGU name exp RANGU ; static_symbol : CHAR | WORD | NUMB ; names : name names | /* empty */ ; name : WORD ;