Some yacc basics
Yacc rules are of the format
lname : definition ;
If there are actions associated with the rule,they must come in between colon and semicolon.
lname is a non-terminal that is it has to be "decompposed" and definition could consist of
terminals and non-terminals.A word about terminals and non-terminals:tokens that are recognized by
lex and passed to parser(yacc generated) are called "terminal symbols" as they cant be "decomposed" futher.Any symbol "terminal" or "non-terminal" is called a name.A symbol cant start with a digit but can contain letters,underscores ,dots and digits.
If there are several grammar rules with the same left hand side they can be seperated by "|".
lname : definition ;
If there are actions associated with the rule,they must come in between colon and semicolon.
lname is a non-terminal that is it has to be "decompposed" and definition could consist of
terminals and non-terminals.A word about terminals and non-terminals:tokens that are recognized by
lex and passed to parser(yacc generated) are called "terminal symbols" as they cant be "decomposed" futher.Any symbol "terminal" or "non-terminal" is called a name.A symbol cant start with a digit but can contain letters,underscores ,dots and digits.
If there are several grammar rules with the same left hand side they can be seperated by "|".
A : B C D ;
A : E F ;
A : G ;
A : B C D
| E F
| G
;

0 Comments:
Post a Comment
<< Home