Changeset 3786 for applications/trunk/LFC/lfc.grammar
 Timestamp:
 May 26, 2008, 2:03:27 AM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

applications/trunk/LFC/lfc.grammar
 Property svn:keywords set to Author Date Id Revision
r3785 r3786 1 /* $Id$ */ 1 /* $Id$ 2 * 3 * This is LL(1) grammar for LFC based on the "Introduction to LFC Programming 4 * Language" (January 25, 2008) by Zhen Lixiao 5 */ 2 6 3 %token SC COMMA 7 %token SC COLON COMMA 8 %token DEC VAR DEF 9 %token ASTERISK TO EQ 4 10 %token LPAR RPAR 5 11 %token IDENTIFIER STRING UNDEFINED … … 10 16 %% 11 17 12 program : exp;18 program : function_dec var_dec_and_func_def ; 13 19 20 function_dec : DEC funname COLON function_type ; 21 22 var_dec_and_func_def : variable_dec definition 23  definition 24 ; 25 26 variable_dec : VAR vars_decl variable_dec_rest ; 27 28 vars_decl : variable_list COLON concept_name SC ; 29 30 variable_dec_rest : /*empty*/ 31  vars_decl variable_dec_rest 32 ; 33 34 variable_list : variable variable_list_rest ; 35 36 variable_list_rest : /*empty*/ 37  COMMA variable variable_list_rest 38 ; 39 40 definition : DEF equation equation_rest ; 41 42 equation : funname LPAR pattern_list RPAR EQ exp_with_where SC ; 43 44 equation_rest : /*empty*/ 45  equation equation_rest 46 ; 47 48 pattern_list : pattern pattern_list_rest ; 49 50 pattern : STRING pat_concat 51  variable pat_concat 52 ; 53 54 pat_concat : /*empty*/ 55  CONCAT pattern 56 ; 57 58 pattern_list_rest : /*empty*/ 59  COMMA pattern pattern_list_rest 60 ; 61 62 function_type : concept_name concept_list_rest TO concept_name ; 63 64 concept_list_rest : /*empty*/ 65  ASTERISK concept_name concept_list_rest 66 ; 67 68 concept_name : IDENTIFIER ; 69 funname : IDENTIFIER ; 14 70 variable : IDENTIFIER ; 15 /*16 funname : IDENTIFIER ;17 */18 71 19 exp : STRING exp_concat _or_where20  UNDEFINED exp_concat _or_where21  IDENTIFIER exp_var_or_func exp_concat _or_where22  LPAR exp RPAR exp_concat_or_where23  IF exp THEN exp ELSE exp exp_where72 exp : STRING exp_concat 73  UNDEFINED exp_concat 74  IDENTIFIER exp_var_or_func exp_concat 75  LPAR exp_with_where RPAR exp_concat 76  IF exp THEN exp ELSE exp 24 77 ; 25 78 79 exp_with_where : STRING exp_concat_or_where 80  UNDEFINED exp_concat_or_where 81  IDENTIFIER exp_var_or_func exp_concat_or_where 82  LPAR exp_with_where RPAR exp_concat_or_where 83  IF exp_with_where THEN exp_with_where ELSE exp_with_where 84 ; 85 26 86 exp_var_or_func : /*empty*/ 27  LPAR exp_list RPAR87  LPAR arg_list RPAR 28 88 ; 29 89 30 exp_list : /*empty*/31  exp exp_list_rest90 arg_list : /*empty*/ 91  exp arg_list_rest 32 92 ; 33 93 34 exp_list_rest : /*empty*/35  COMMA exp exp_list_rest94 arg_list_rest : /*empty*/ 95  COMMA exp arg_list_rest 36 96 ; 37 97 38 exp_concat_or_where : exp_where 39  CONCAT exp 98 exp_concat : /*empty*/ 99  CONCAT exp 100 ; 101 102 exp_concat_or_where : /*empty*/ 103  CONCAT exp_with_where 104  WHERE varassign_list 40 105 ; 41 42 43 exp_where : /*empty*/44  WHERE varassign_list45 ;46 106 47 107 varassign_list : variable ASSIGN exp varassign_rest ;
Note: See TracChangeset
for help on using the changeset viewer.