diff options
author | Yuichiro Kaneko <spiketeika@gmail.com> | 2019-11-11 08:57:15 +0900 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2019-11-11 10:37:30 +0100 |
commit | 17d34c231b185b5612dbe4f842f76f2c9490f2f4 (patch) | |
tree | 89148021de074d7cd0c3a0d2e99130718e8dd015 /tests/sets.at | |
parent | af000bab111768a04021bf5ffa4bbe91d44e231c (diff) | |
download | bison-17d34c231b185b5612dbe4f842f76f2c9490f2f4.tar.gz |
gram.c: also print terminals in grammar_dump
* src/gram.c (grammar_dump): Print terminals likewise non terminals.
* tests/sets.at (Reduced Grammar): Update test case to catch up the
change and add a test case where prec and assoc are used.
Diffstat (limited to 'tests/sets.at')
-rw-r--r-- | tests/sets.at | 111 |
1 files changed, 105 insertions, 6 deletions
diff --git a/tests/sets.at b/tests/sets.at index 5dbc50dc..a694cc95 100644 --- a/tests/sets.at +++ b/tests/sets.at @@ -329,14 +329,27 @@ Reduced Grammar ntokens = 7, nvars = 4, nsyms = 11, nrules = 6, nritems = 17 -Variables ---------- +Tokens +------ Value Sprec Sassoc Tag - 7 0 0 $accept - 8 0 0 expr - 9 0 0 term - 10 0 0 fact + 0 0 0 $end + 1 0 0 error + 2 0 0 $undefined + 3 0 0 "+" + 4 0 0 "*" + 5 0 0 "useless" + 6 0 0 "num" + + +Non terminals +------------- + +Value Tag + 7 $accept + 8 expr + 9 term + 10 fact Rules @@ -368,3 +381,89 @@ reduced input.y defines 7 terminals, 4 nonterminals, and 6 productions. ]]) AT_CLEANUP + + +## ------------------------------------- ## +## Reduced Grammar with prec and assoc. ## +## ------------------------------------- ## + +# Check information about the grammar, once reduced. + +AT_SETUP([Reduced Grammar with prec and assoc]) + +AT_DATA([input.y], +[[%nonassoc '<' '>' +%left '+' '-' +%right '^' '=' +%% +exp: + exp '<' exp + | exp '>' exp + | exp '+' exp + | exp '-' exp + | exp '^' exp + | exp '=' exp + | "exp" + ; +]]) + +AT_BISON_CHECK([[--trace=grammar -o input.c input.y]], [], [], +[[Reduced Grammar + +ntokens = 10, nvars = 2, nsyms = 12, nrules = 8, nritems = 29 + +Tokens +------ + +Value Sprec Sassoc Tag + 0 0 0 $end + 1 0 0 error + 2 0 0 $undefined + 3 1 3 '<' + 4 1 3 '>' + 5 2 2 '+' + 6 2 2 '-' + 7 3 1 '^' + 8 3 1 '=' + 9 0 0 "exp" + + +Non terminals +------------- + +Value Tag + 10 $accept + 11 exp + + +Rules +----- + +Num (Prec, Assoc, Useful, UselessChain) Lhs -> (Ritem Range) Rhs + 0 ( 0, 0, t, f) 10 -> ( 0- 1) 11 0 + 1 ( 1, 3, t, f) 11 -> ( 3- 5) 11 3 11 + 2 ( 1, 3, t, f) 11 -> ( 7- 9) 11 4 11 + 3 ( 2, 2, t, f) 11 -> (11-13) 11 5 11 + 4 ( 2, 2, t, f) 11 -> (15-17) 11 6 11 + 5 ( 3, 1, t, f) 11 -> (19-21) 11 7 11 + 6 ( 3, 1, t, f) 11 -> (23-25) 11 8 11 + 7 ( 0, 0, t, t) 11 -> (27-27) 9 + + +Rules interpreted +----------------- + +0 $accept: exp $end +1 exp: exp '<' exp +2 exp: exp '>' exp +3 exp: exp '+' exp +4 exp: exp '-' exp +5 exp: exp '^' exp +6 exp: exp '=' exp +7 exp: "exp" + + +reduced input.y defines 10 terminals, 2 nonterminals, and 8 productions. +]]) + +AT_CLEANUP |