From 33481e105a24471e91beb1099f31e6a44f645680 Mon Sep 17 00:00:00 2001 From: Dimitar Trendafilov Date: Wed, 24 Oct 2018 22:05:30 +0300 Subject: Added the parser generators slides to the contents --- .../slides/04_parser_generators/parser.html | 334 +++++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 website/content/slides/04_parser_generators/parser.html (limited to 'website/content/slides/04_parser_generators/parser.html') diff --git a/website/content/slides/04_parser_generators/parser.html b/website/content/slides/04_parser_generators/parser.html new file mode 100644 index 0000000..724b703 --- /dev/null +++ b/website/content/slides/04_parser_generators/parser.html @@ -0,0 +1,334 @@ + + + + + + parser.y - GNU Bison XML Automaton Report + + +

GNU Bison XML Automaton Report

+ input grammar: parser.y

+ +

Table of Contents

Reductions

Nonterminals useless in grammar

+ +

Terminals unused in grammar

+ +

Rules useless in grammar

+

Conflicts

+ +

Grammar

+

+ 0 $accept → input $end + + 1 input → %empty + 2 | expr + + 3 expr → NUMBER + 4 | '(' expr ')' + 5 | expr PLUS expr + 6 | expr MINUS expr + 7 | expr MULT expr + 8 | expr DIV expr +

+ +

Terminals, with rules where they appear

+ +

$end (0) 0 +'(' (40) 4 +')' (41) 4 +error (256) +NUMBER (258) 3 +PLUS (259) 5 +MINUS (260) 6 +MULT (261) 7 +DIV (262) 8 +

+ +

Nonterminals, with rules where they appear

+ +

$accept (10) + on left: 0 +input (11) + on left: 1 2 + on right: 0 +expr (12) + on left: 3 4 5 6 7 8 + on right: 2 4 5 6 7 8 +

Automaton

+ +

state 0

+ +

0 $accept → . input $end + 1 input → . %empty [$end] + 2 | . expr + 3 expr → . NUMBER + 4 | . '(' expr ')' + 5 | . expr PLUS expr + 6 | . expr MINUS expr + 7 | . expr MULT expr + 8 | . expr DIV expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + $default reduce using rule 1 (input) + + input go to state 3 + expr go to state 4 +

+ +

state 1

+ +

3 expr → NUMBER . + + $default reduce using rule 3 (expr) +

+ +

state 2

+ +

3 expr → . NUMBER + 4 | . '(' expr ')' + 4 | '(' . expr ')' + 5 | . expr PLUS expr + 6 | . expr MINUS expr + 7 | . expr MULT expr + 8 | . expr DIV expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 5 +

+ +

state 3

+ +

0 $accept → input . $end + + $end shift, and go to state 6 +

+ +

state 4

+ +

2 input → expr . [$end] + 5 expr → expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + + PLUS shift, and go to state 7 + MINUS shift, and go to state 8 + MULT shift, and go to state 9 + DIV shift, and go to state 10 + + $default reduce using rule 2 (input) +

+ +

state 5

+ +

4 expr → '(' expr . ')' + 5 | expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + + PLUS shift, and go to state 7 + MINUS shift, and go to state 8 + MULT shift, and go to state 9 + DIV shift, and go to state 10 + ')' shift, and go to state 11 +

+ +

state 6

+ +

0 $accept → input $end . + + $default accept +

+ +

state 7

+ +

3 expr → . NUMBER + 4 | . '(' expr ')' + 5 | . expr PLUS expr + 5 | expr PLUS . expr + 6 | . expr MINUS expr + 7 | . expr MULT expr + 8 | . expr DIV expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 12 +

+ +

state 8

+ +

3 expr → . NUMBER + 4 | . '(' expr ')' + 5 | . expr PLUS expr + 6 | . expr MINUS expr + 6 | expr MINUS . expr + 7 | . expr MULT expr + 8 | . expr DIV expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 13 +

+ +

state 9

+ +

3 expr → . NUMBER + 4 | . '(' expr ')' + 5 | . expr PLUS expr + 6 | . expr MINUS expr + 7 | . expr MULT expr + 7 | expr MULT . expr + 8 | . expr DIV expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 14 +

+ +

state 10

+ +

3 expr → . NUMBER + 4 | . '(' expr ')' + 5 | . expr PLUS expr + 6 | . expr MINUS expr + 7 | . expr MULT expr + 8 | . expr DIV expr + 8 | expr DIV . expr + + NUMBER shift, and go to state 1 + '(' shift, and go to state 2 + + expr go to state 15 +

+ +

state 11

+ +

4 expr → '(' expr ')' . + + $default reduce using rule 4 (expr) +

+ +

state 12

+ +

5 expr → expr . PLUS expr + 5 | expr PLUS expr . [$end, PLUS, MINUS, ')'] + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + + MULT shift, and go to state 9 + DIV shift, and go to state 10 + + $default reduce using rule 5 (expr) + + Conflict between rule 5 and token PLUS resolved as reduce (%left PLUS). + Conflict between rule 5 and token MINUS resolved as reduce (%left MINUS). + Conflict between rule 5 and token MULT resolved as shift (PLUS < MULT). + Conflict between rule 5 and token DIV resolved as shift (PLUS < DIV). +

+ +

state 13

+ +

5 expr → expr . PLUS expr + 6 | expr . MINUS expr + 6 | expr MINUS expr . [$end, PLUS, MINUS, ')'] + 7 | expr . MULT expr + 8 | expr . DIV expr + + MULT shift, and go to state 9 + DIV shift, and go to state 10 + + $default reduce using rule 6 (expr) + + Conflict between rule 6 and token PLUS resolved as reduce (%left PLUS). + Conflict between rule 6 and token MINUS resolved as reduce (%left MINUS). + Conflict between rule 6 and token MULT resolved as shift (MINUS < MULT). + Conflict between rule 6 and token DIV resolved as shift (MINUS < DIV). +

+ +

state 14

+ +

5 expr → expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 7 | expr MULT expr . [$end, PLUS, MINUS, MULT, DIV, ')'] + 8 | expr . DIV expr + + $default reduce using rule 7 (expr) + + Conflict between rule 7 and token PLUS resolved as reduce (PLUS < MULT). + Conflict between rule 7 and token MINUS resolved as reduce (MINUS < MULT). + Conflict between rule 7 and token MULT resolved as reduce (%left MULT). + Conflict between rule 7 and token DIV resolved as reduce (%left DIV). +

+ +

state 15

+ +

5 expr → expr . PLUS expr + 6 | expr . MINUS expr + 7 | expr . MULT expr + 8 | expr . DIV expr + 8 | expr DIV expr . [$end, PLUS, MINUS, MULT, DIV, ')'] + + $default reduce using rule 8 (expr) + + Conflict between rule 8 and token PLUS resolved as reduce (PLUS < DIV). + Conflict between rule 8 and token MINUS resolved as reduce (MINUS < DIV). + Conflict between rule 8 and token MULT resolved as reduce (%left MULT). + Conflict between rule 8 and token DIV resolved as reduce (%left DIV). +

+ + + -- cgit v1.3.1-23-gd82d