2 char rcsid_gram[] = "$Id$";
15 PatternAST y_patternAST;
35 %type <y_binding> binding
36 %type <y_intlist> cost costtail
37 %type <y_ruleAST> rule
38 %type <y_patternAST> pattern
39 %type <y_list> decls rules bindinglist grammarlist
48 spec : decls K_PPERCENT rules
52 decls : /* lambda */ { $$ = 0; }
53 | decls decl { $$ = newList($2, $1); }
56 decl : K_TERM bindinglist { $$ = newArity(-1, $2); }
57 | K_GRAM grammarlist { $$ = 0; doGram($2); }
58 | K_START ID { $$ = 0; doStart($2); } /* kludge */
61 grammarlist : /* lambda */ { $$ = 0; }
62 | grammarlist ID { $$ = newList($2, $1); }
65 bindinglist : /* lambda */ { $$ = 0; }
66 | bindinglist binding { $$ = newList($2, $1); }
69 binding : ID '=' INT { $$ = newBinding($1, $3); }
72 rules : /* lambda */ { $$ = 0; }
73 | rules rule { $$ = newList($2, $1); }
76 rule : ID ':' pattern '=' INT cost ';' { $$ = newRuleAST($1, $3, $5, $6); }
79 pattern : ID { $$ = newPatternAST($1, 0); }
80 | ID '(' pattern ')' { $$ = newPatternAST($1, newList($3,0)); }
81 | ID '(' pattern ',' pattern ')' { $$ = newPatternAST($1, newList($3, newList($5, 0))); }
84 cost : /* lambda */ { $$ = 0; }
85 | '(' INT costtail ')' { $$ = newIntList($2, $3); }
88 costtail : /* lambda */ { $$ = 0; }
89 | ',' INT costtail { $$ = newIntList($2, $3); }
90 | INT costtail { $$ = newIntList($1, $2); }