bison - Using yacc precedence for rules with no terminals, only non-terminals -
Someone can help me This is my rule on:
e: T_NUM {$$ = Mk_ant ($ 1);} | T_POP E [l] {$$ = Mk_Ap (Mk_op (POP), $ l);} | T_NEXT E [l] {$$ = MK_Ap (MK_op (NEXT), $ l);} | "{" E [x] "," e [y] "}" {$$ = mk_point ($ x, $ y);} | E T_PLUS E {$$ = Mk_Ap (Mk_Ap (Mk_op (plus), $ 1), $ 3);} | E T_MINUS E {$$ = MK_Ap (Mk_Ap (MINUS), $ 1), $ 3);} | E T_DIV E {$$ = MK_Ap (Mk_Ap (Mk_op (DIV), $ 1), $ 3);} | E T_MULT E {$$ = MK_Ap (Mk_Ap (MKTOP (MULT), $ 1), $ 3);} | E T_LEQ E {$$ = MK_Ap (Mk_Ap (LEQ, $ 1), $ 3);} | E T_LEE {$$ = MK_Ap (Mk_app (Mk_op ($ 1), $ 3);} | E T_GEQ E {$$ = MK_Ap (Mk_Ap (MKAOP), $ 1), $ 3);} | E T_GE E {$$ = MK_Ap (Mk_Ap (Mk_op (GE), $ 1), $ 3);} | E T_OR E {$$ = Mk_Ap (Mk_app (MK_OP, $ 1), $ 3);} | E T_AND E {$$ = Mk_Ap (Mk_app (AND, $ 1), $ 3);} | T_ID {$$ = MK_ID ($ 1);} / * RECONCISE DIIIPUTER and variable variable * / | E T_EQ E {$$ = MK_Ap (Mk_Ap (Mk_op (EQ), $ 1), $ 3);} | T_NOT e [expr] {$$ = mk_app (mk_op (not), $ expr)}} T_FUN T_ID [var] arg_list [expr] {$$ = mk_fun ($ var, $ expr); Env = push_rec_env ($ var, $$, env);} / * DADDESS DE FANSIONS * / | T_LET T_ID [x] T_EQUAL E [AGG] T_IN E [XP] {$$ = MK_Ap (Mk_fan ($ x, $ EXP), $ arg); Env = push_rec_env ($ x, $$, env);} / * fonts in * / | E [exp] T_WHERE T_ID [x] T_EQUAL E [AG] {$$ = MK_Ap (Mk_fone ($ x, $ EXP), $ arg); env = push_rec_env ($ x, $$, env);} / * function WHERE * / | TIIF E [Cond] T_ATHNE [TO_BR] TILESEE [AAIBiB] {$$ = MKCand ($ CAD, $ RE _ BR, AADAB);} '[' List [L] ']' {$$ = $ l;} / * OP List list * / | E [EXPA] T_PUSH A [L] {$$ = MK_Ap (Mk_Ap (Mk_op (push), $ EXP), $ l);} | '(F.Gear [Funny] E [AG]' '$$ = MK_Ep ($ fun, $ AGR);} / * Exxoning de phonics a plural variables * / |' ('E') '{$$ = $ 2;} * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * I would like to remove, but it produces many conflicts if someone can give me a hand that how can I work out this syntax without brackets for information: f_arg: e {$$ = $ 1;} | f_arg [fun] e [ag] {$$ = mk_app ($ fun, $ agr);} < / p>
The problem is that the unknown function application in relation to all your binary information and prefixes is unclear - an input such as ab + c to (ab) + c Can be parsed as or a (b + c) as there is no token in the function application, so the usual yacc / bison privacy rule additional assistance Without work, will not work for it. Thinking that you want to give the Function app the highest priority (General Case, I), then you can do this work with some extra work.
Add the following authorization rule at the end of your list (top priority):
% left FUNCTION_APPLICATION T_NUM T_ID '{' '(' Create your own function rule:
| e [fun] e [arg]% prec FUNCTION_APPLICATION {$$ = mk_app ($ Fun, $ arg);} What else do you have in grammar, you may need to add some more tokens in the preceding rules and / or rearrange some things. Prioritize each token in the first (e) Are needed , And if its preference for the function is different from its predecessor for other uses, then things will not work (only one priority as each token). High Priority, from everything else, things can be resolved
Comments
Post a Comment