view Bison-Flex/CALC/Bison-Flex/calc-parser.output @ 0:db40c85cad7a default tip

upload sample source
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Mon, 09 May 2011 03:11:59 +0900
parents
children
line wrap: on
line source

Grammar

    0 $accept: unit "end of file"

    1 unit: state
    2     | unit state

    3 state: "identifier" '=' expr '\n'
    4      | "print" expr '\n'
    5      | "list" '\n'

    6 expr: expr '-' expr
    7     | expr '+' expr
    8     | expr '*' expr
    9     | expr '/' expr
   10     | '-' expr
   11     | '(' expr ')'
   12     | "identifier"
   13     | "ival"


Terminals, with rules where they appear

"end of file" (0) 0
'\n' (10) 3 4 5
'(' (40) 11
')' (41) 11
'*' (42) 8
'+' (43) 7
'-' (45) 6 10
'/' (47) 9
'=' (61) 3
error (256)
"ival" (258) 13
"identifier" (259) 3 12
"print" (260) 4
"list" (261) 5
NEG (262)


Nonterminals, with rules where they appear

$accept (16)
    on left: 0
unit (17)
    on left: 1 2, on right: 0 2
state (18)
    on left: 3 4 5, on right: 1 2
expr (19)
    on left: 6 7 8 9 10 11 12 13, on right: 3 4 6 7 8 9 10 11


state 0

    0 $accept: . unit "end of file"
    1 unit: . state
    2     | . unit state
    3 state: . "identifier" '=' expr '\n'
    4      | . "print" expr '\n'
    5      | . "list" '\n'

    "identifier"  shift, and go to state 1
    "print"       shift, and go to state 2
    "list"        shift, and go to state 3

    unit   go to state 4
    state  go to state 5


state 1

    3 state: "identifier" . '=' expr '\n'

    '='  shift, and go to state 6


state 2

    4 state: "print" . expr '\n'
    6 expr: . expr '-' expr
    7     | . expr '+' expr
    8     | . expr '*' expr
    9     | . expr '/' expr
   10     | . '-' expr
   11     | . '(' expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 11


state 3

    5 state: "list" . '\n'

    '\n'  shift, and go to state 12


state 4

    0 $accept: unit . "end of file"
    2 unit: unit . state
    3 state: . "identifier" '=' expr '\n'
    4      | . "print" expr '\n'
    5      | . "list" '\n'

    "end of file"  shift, and go to state 13
    "identifier"   shift, and go to state 1
    "print"        shift, and go to state 2
    "list"         shift, and go to state 3

    state  go to state 14


state 5

    1 unit: state .

    $default  reduce using rule 1 (unit)


state 6

    3 state: "identifier" '=' . expr '\n'
    6 expr: . expr '-' expr
    7     | . expr '+' expr
    8     | . expr '*' expr
    9     | . expr '/' expr
   10     | . '-' expr
   11     | . '(' expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 15


state 7

   13 expr: "ival" .

    $default  reduce using rule 13 (expr)


state 8

   12 expr: "identifier" .

    $default  reduce using rule 12 (expr)


state 9

    6 expr: . expr '-' expr
    7     | . expr '+' expr
    8     | . expr '*' expr
    9     | . expr '/' expr
   10     | . '-' expr
   10     | '-' . expr
   11     | . '(' expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 16


state 10

    6 expr: . expr '-' expr
    7     | . expr '+' expr
    8     | . expr '*' expr
    9     | . expr '/' expr
   10     | . '-' expr
   11     | . '(' expr ')'
   11     | '(' . expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 17


state 11

    4 state: "print" expr . '\n'
    6 expr: expr . '-' expr
    7     | expr . '+' expr
    8     | expr . '*' expr
    9     | expr . '/' expr

    '+'   shift, and go to state 18
    '-'   shift, and go to state 19
    '*'   shift, and go to state 20
    '/'   shift, and go to state 21
    '\n'  shift, and go to state 22


state 12

    5 state: "list" '\n' .

    $default  reduce using rule 5 (state)


state 13

    0 $accept: unit "end of file" .

    $default  accept


state 14

    2 unit: unit state .

    $default  reduce using rule 2 (unit)


state 15

    3 state: "identifier" '=' expr . '\n'
    6 expr: expr . '-' expr
    7     | expr . '+' expr
    8     | expr . '*' expr
    9     | expr . '/' expr

    '+'   shift, and go to state 18
    '-'   shift, and go to state 19
    '*'   shift, and go to state 20
    '/'   shift, and go to state 21
    '\n'  shift, and go to state 23


state 16

    6 expr: expr . '-' expr
    7     | expr . '+' expr
    8     | expr . '*' expr
    9     | expr . '/' expr
   10     | '-' expr .  ['+', '-', '*', '/', '\n', ')']

    $default  reduce using rule 10 (expr)

    Conflict between rule 10 and token '+' resolved as reduce ('+' < NEG).
    Conflict between rule 10 and token '-' resolved as reduce ('-' < NEG).
    Conflict between rule 10 and token '*' resolved as reduce ('*' < NEG).
    Conflict between rule 10 and token '/' resolved as reduce ('/' < NEG).


state 17

    6 expr: expr . '-' expr
    7     | expr . '+' expr
    8     | expr . '*' expr
    9     | expr . '/' expr
   11     | '(' expr . ')'

    '+'  shift, and go to state 18
    '-'  shift, and go to state 19
    '*'  shift, and go to state 20
    '/'  shift, and go to state 21
    ')'  shift, and go to state 24


state 18

    6 expr: . expr '-' expr
    7     | . expr '+' expr
    7     | expr '+' . expr
    8     | . expr '*' expr
    9     | . expr '/' expr
   10     | . '-' expr
   11     | . '(' expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 25


state 19

    6 expr: . expr '-' expr
    6     | expr '-' . expr
    7     | . expr '+' expr
    8     | . expr '*' expr
    9     | . expr '/' expr
   10     | . '-' expr
   11     | . '(' expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 26


state 20

    6 expr: . expr '-' expr
    7     | . expr '+' expr
    8     | . expr '*' expr
    8     | expr '*' . expr
    9     | . expr '/' expr
   10     | . '-' expr
   11     | . '(' expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 27


state 21

    6 expr: . expr '-' expr
    7     | . expr '+' expr
    8     | . expr '*' expr
    9     | . expr '/' expr
    9     | expr '/' . expr
   10     | . '-' expr
   11     | . '(' expr ')'
   12     | . "identifier"
   13     | . "ival"

    "ival"        shift, and go to state 7
    "identifier"  shift, and go to state 8
    '-'           shift, and go to state 9
    '('           shift, and go to state 10

    expr  go to state 28


state 22

    4 state: "print" expr '\n' .

    $default  reduce using rule 4 (state)


state 23

    3 state: "identifier" '=' expr '\n' .

    $default  reduce using rule 3 (state)


state 24

   11 expr: '(' expr ')' .

    $default  reduce using rule 11 (expr)


state 25

    6 expr: expr . '-' expr
    7     | expr . '+' expr  ['+', '-', '\n', ')']
    7     | expr '+' expr .  ['+', '-', '\n', ')']
    8     | expr . '*' expr
    9     | expr . '/' expr

    '*'  shift, and go to state 20
    '/'  shift, and go to state 21

    $default  reduce using rule 7 (expr)

    Conflict between rule 7 and token '+' resolved as reduce (%left '+').
    Conflict between rule 7 and token '-' resolved as reduce (%left '-').
    Conflict between rule 7 and token '*' resolved as shift ('+' < '*').
    Conflict between rule 7 and token '/' resolved as shift ('+' < '/').


state 26

    6 expr: expr . '-' expr  ['+', '-', '\n', ')']
    6     | expr '-' expr .  ['+', '-', '\n', ')']
    7     | expr . '+' expr
    8     | expr . '*' expr
    9     | expr . '/' expr

    '*'  shift, and go to state 20
    '/'  shift, and go to state 21

    $default  reduce using rule 6 (expr)

    Conflict between rule 6 and token '+' resolved as reduce (%left '+').
    Conflict between rule 6 and token '-' resolved as reduce (%left '-').
    Conflict between rule 6 and token '*' resolved as shift ('-' < '*').
    Conflict between rule 6 and token '/' resolved as shift ('-' < '/').


state 27

    6 expr: expr . '-' expr
    7     | expr . '+' expr
    8     | expr . '*' expr  ['+', '-', '*', '/', '\n', ')']
    8     | expr '*' expr .  ['+', '-', '*', '/', '\n', ')']
    9     | expr . '/' expr

    $default  reduce using rule 8 (expr)

    Conflict between rule 8 and token '+' resolved as reduce ('+' < '*').
    Conflict between rule 8 and token '-' resolved as reduce ('-' < '*').
    Conflict between rule 8 and token '*' resolved as reduce (%left '*').
    Conflict between rule 8 and token '/' resolved as reduce (%left '/').


state 28

    6 expr: expr . '-' expr
    7     | expr . '+' expr
    8     | expr . '*' expr
    9     | expr . '/' expr  ['+', '-', '*', '/', '\n', ')']
    9     | expr '/' expr .  ['+', '-', '*', '/', '\n', ')']

    $default  reduce using rule 9 (expr)

    Conflict between rule 9 and token '+' resolved as reduce ('+' < '/').
    Conflict between rule 9 and token '-' resolved as reduce ('-' < '/').
    Conflict between rule 9 and token '*' resolved as reduce (%left '*').
    Conflict between rule 9 and token '/' resolved as reduce (%left '/').