[2] | 1 | Grammar
|
---|
| 2 |
|
---|
| 3 | 0 $accept: line $end
|
---|
| 4 |
|
---|
| 5 | 1 line: /* empty */
|
---|
| 6 | 2 | line stmt '\n'
|
---|
| 7 | 3 | line error '\n'
|
---|
| 8 |
|
---|
| 9 | 4 stmt: expr
|
---|
| 10 |
|
---|
| 11 | 5 expr: OPEN_PAREN expr CLOSE_PAREN
|
---|
| 12 | 6 | '|' expr '|'
|
---|
| 13 | 7 | expr '*' expr
|
---|
| 14 | 8 | expr '/' expr
|
---|
| 15 | 9 | expr '%' expr
|
---|
| 16 | 10 | expr '-' expr
|
---|
| 17 | 11 | expr '+' expr
|
---|
| 18 | 12 | expr '!'
|
---|
| 19 | 13 | expr EXPONENT expr
|
---|
| 20 | 14 | '-' expr
|
---|
| 21 | 15 | number
|
---|
| 22 |
|
---|
| 23 | 16 number: PI
|
---|
| 24 | 17 | DIGIT
|
---|
| 25 | 18 | number DIGIT
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | Terminals, with rules where they appear
|
---|
| 29 |
|
---|
| 30 | $end (0) 0
|
---|
| 31 | '\n' (10) 2 3
|
---|
| 32 | '!' (33) 12
|
---|
| 33 | '%' (37) 9
|
---|
| 34 | '*' (42) 7
|
---|
| 35 | '+' (43) 11
|
---|
| 36 | '-' (45) 10 14
|
---|
| 37 | '/' (47) 8
|
---|
| 38 | '|' (124) 6
|
---|
| 39 | error (256) 3
|
---|
| 40 | DIGIT (258) 17 18
|
---|
| 41 | PI (259) 16
|
---|
| 42 | OPEN_PAREN (260) 5
|
---|
| 43 | CLOSE_PAREN (261) 5
|
---|
| 44 | UMINUS (262)
|
---|
| 45 | EXPONENT (263) 13
|
---|
| 46 |
|
---|
| 47 |
|
---|
| 48 | Nonterminals, with rules where they appear
|
---|
| 49 |
|
---|
| 50 | $accept (17)
|
---|
| 51 | on left: 0
|
---|
| 52 | line (18)
|
---|
| 53 | on left: 1 2 3, on right: 0 2 3
|
---|
| 54 | stmt (19)
|
---|
| 55 | on left: 4, on right: 2
|
---|
| 56 | expr (20)
|
---|
| 57 | on left: 5 6 7 8 9 10 11 12 13 14 15, on right: 4 5 6 7 8 9 10
|
---|
| 58 | 11 12 13 14
|
---|
| 59 | number (21)
|
---|
| 60 | on left: 16 17 18, on right: 15 18
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | state 0
|
---|
| 64 |
|
---|
| 65 | 0 $accept: . line $end
|
---|
| 66 |
|
---|
| 67 | $default reduce using rule 1 (line)
|
---|
| 68 |
|
---|
| 69 | line go to state 1
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | state 1
|
---|
| 73 |
|
---|
| 74 | 0 $accept: line . $end
|
---|
| 75 | 2 line: line . stmt '\n'
|
---|
| 76 | 3 | line . error '\n'
|
---|
| 77 |
|
---|
| 78 | $end shift, and go to state 2
|
---|
| 79 | error shift, and go to state 3
|
---|
| 80 | DIGIT shift, and go to state 4
|
---|
| 81 | PI shift, and go to state 5
|
---|
| 82 | OPEN_PAREN shift, and go to state 6
|
---|
| 83 | '|' shift, and go to state 7
|
---|
| 84 | '-' shift, and go to state 8
|
---|
| 85 |
|
---|
| 86 | stmt go to state 9
|
---|
| 87 | expr go to state 10
|
---|
| 88 | number go to state 11
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | state 2
|
---|
| 92 |
|
---|
| 93 | 0 $accept: line $end .
|
---|
| 94 |
|
---|
| 95 | $default accept
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | state 3
|
---|
| 99 |
|
---|
| 100 | 3 line: line error . '\n'
|
---|
| 101 |
|
---|
| 102 | '\n' shift, and go to state 12
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 | state 4
|
---|
| 106 |
|
---|
| 107 | 17 number: DIGIT .
|
---|
| 108 |
|
---|
| 109 | $default reduce using rule 17 (number)
|
---|
| 110 |
|
---|
| 111 |
|
---|
| 112 | state 5
|
---|
| 113 |
|
---|
| 114 | 16 number: PI .
|
---|
| 115 |
|
---|
| 116 | $default reduce using rule 16 (number)
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | state 6
|
---|
| 120 |
|
---|
| 121 | 5 expr: OPEN_PAREN . expr CLOSE_PAREN
|
---|
| 122 |
|
---|
| 123 | DIGIT shift, and go to state 4
|
---|
| 124 | PI shift, and go to state 5
|
---|
| 125 | OPEN_PAREN shift, and go to state 6
|
---|
| 126 | '|' shift, and go to state 7
|
---|
| 127 | '-' shift, and go to state 8
|
---|
| 128 |
|
---|
| 129 | expr go to state 13
|
---|
| 130 | number go to state 11
|
---|
| 131 |
|
---|
| 132 |
|
---|
| 133 | state 7
|
---|
| 134 |
|
---|
| 135 | 6 expr: '|' . expr '|'
|
---|
| 136 |
|
---|
| 137 | DIGIT shift, and go to state 4
|
---|
| 138 | PI shift, and go to state 5
|
---|
| 139 | OPEN_PAREN shift, and go to state 6
|
---|
| 140 | '|' shift, and go to state 7
|
---|
| 141 | '-' shift, and go to state 8
|
---|
| 142 |
|
---|
| 143 | expr go to state 14
|
---|
| 144 | number go to state 11
|
---|
| 145 |
|
---|
| 146 |
|
---|
| 147 | state 8
|
---|
| 148 |
|
---|
| 149 | 14 expr: '-' . expr
|
---|
| 150 |
|
---|
| 151 | DIGIT shift, and go to state 4
|
---|
| 152 | PI shift, and go to state 5
|
---|
| 153 | OPEN_PAREN shift, and go to state 6
|
---|
| 154 | '|' shift, and go to state 7
|
---|
| 155 | '-' shift, and go to state 8
|
---|
| 156 |
|
---|
| 157 | expr go to state 15
|
---|
| 158 | number go to state 11
|
---|
| 159 |
|
---|
| 160 |
|
---|
| 161 | state 9
|
---|
| 162 |
|
---|
| 163 | 2 line: line stmt . '\n'
|
---|
| 164 |
|
---|
| 165 | '\n' shift, and go to state 16
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | state 10
|
---|
| 169 |
|
---|
| 170 | 4 stmt: expr .
|
---|
| 171 | 7 expr: expr . '*' expr
|
---|
| 172 | 8 | expr . '/' expr
|
---|
| 173 | 9 | expr . '%' expr
|
---|
| 174 | 10 | expr . '-' expr
|
---|
| 175 | 11 | expr . '+' expr
|
---|
| 176 | 12 | expr . '!'
|
---|
| 177 | 13 | expr . EXPONENT expr
|
---|
| 178 |
|
---|
| 179 | '-' shift, and go to state 17
|
---|
| 180 | '+' shift, and go to state 18
|
---|
| 181 | '*' shift, and go to state 19
|
---|
| 182 | '/' shift, and go to state 20
|
---|
| 183 | '%' shift, and go to state 21
|
---|
| 184 | '!' shift, and go to state 22
|
---|
| 185 | EXPONENT shift, and go to state 23
|
---|
| 186 |
|
---|
| 187 | $default reduce using rule 4 (stmt)
|
---|
| 188 |
|
---|
| 189 |
|
---|
| 190 | state 11
|
---|
| 191 |
|
---|
| 192 | 15 expr: number .
|
---|
| 193 | 18 number: number . DIGIT
|
---|
| 194 |
|
---|
| 195 | DIGIT shift, and go to state 24
|
---|
| 196 |
|
---|
| 197 | $default reduce using rule 15 (expr)
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | state 12
|
---|
| 201 |
|
---|
| 202 | 3 line: line error '\n' .
|
---|
| 203 |
|
---|
| 204 | $default reduce using rule 3 (line)
|
---|
| 205 |
|
---|
| 206 |
|
---|
| 207 | state 13
|
---|
| 208 |
|
---|
| 209 | 5 expr: OPEN_PAREN expr . CLOSE_PAREN
|
---|
| 210 | 7 | expr . '*' expr
|
---|
| 211 | 8 | expr . '/' expr
|
---|
| 212 | 9 | expr . '%' expr
|
---|
| 213 | 10 | expr . '-' expr
|
---|
| 214 | 11 | expr . '+' expr
|
---|
| 215 | 12 | expr . '!'
|
---|
| 216 | 13 | expr . EXPONENT expr
|
---|
| 217 |
|
---|
| 218 | CLOSE_PAREN shift, and go to state 25
|
---|
| 219 | '-' shift, and go to state 17
|
---|
| 220 | '+' shift, and go to state 18
|
---|
| 221 | '*' shift, and go to state 19
|
---|
| 222 | '/' shift, and go to state 20
|
---|
| 223 | '%' shift, and go to state 21
|
---|
| 224 | '!' shift, and go to state 22
|
---|
| 225 | EXPONENT shift, and go to state 23
|
---|
| 226 |
|
---|
| 227 |
|
---|
| 228 | state 14
|
---|
| 229 |
|
---|
| 230 | 6 expr: '|' expr . '|'
|
---|
| 231 | 7 | expr . '*' expr
|
---|
| 232 | 8 | expr . '/' expr
|
---|
| 233 | 9 | expr . '%' expr
|
---|
| 234 | 10 | expr . '-' expr
|
---|
| 235 | 11 | expr . '+' expr
|
---|
| 236 | 12 | expr . '!'
|
---|
| 237 | 13 | expr . EXPONENT expr
|
---|
| 238 |
|
---|
| 239 | '|' shift, and go to state 26
|
---|
| 240 | '-' shift, and go to state 17
|
---|
| 241 | '+' shift, and go to state 18
|
---|
| 242 | '*' shift, and go to state 19
|
---|
| 243 | '/' shift, and go to state 20
|
---|
| 244 | '%' shift, and go to state 21
|
---|
| 245 | '!' shift, and go to state 22
|
---|
| 246 | EXPONENT shift, and go to state 23
|
---|
| 247 |
|
---|
| 248 |
|
---|
| 249 | state 15
|
---|
| 250 |
|
---|
| 251 | 7 expr: expr . '*' expr
|
---|
| 252 | 8 | expr . '/' expr
|
---|
| 253 | 9 | expr . '%' expr
|
---|
| 254 | 10 | expr . '-' expr
|
---|
| 255 | 11 | expr . '+' expr
|
---|
| 256 | 12 | expr . '!'
|
---|
| 257 | 13 | expr . EXPONENT expr
|
---|
| 258 | 14 | '-' expr .
|
---|
| 259 |
|
---|
| 260 | '!' shift, and go to state 22
|
---|
| 261 | EXPONENT shift, and go to state 23
|
---|
| 262 |
|
---|
| 263 | $default reduce using rule 14 (expr)
|
---|
| 264 |
|
---|
| 265 |
|
---|
| 266 | state 16
|
---|
| 267 |
|
---|
| 268 | 2 line: line stmt '\n' .
|
---|
| 269 |
|
---|
| 270 | $default reduce using rule 2 (line)
|
---|
| 271 |
|
---|
| 272 |
|
---|
| 273 | state 17
|
---|
| 274 |
|
---|
| 275 | 10 expr: expr '-' . expr
|
---|
| 276 |
|
---|
| 277 | DIGIT shift, and go to state 4
|
---|
| 278 | PI shift, and go to state 5
|
---|
| 279 | OPEN_PAREN shift, and go to state 6
|
---|
| 280 | '|' shift, and go to state 7
|
---|
| 281 | '-' shift, and go to state 8
|
---|
| 282 |
|
---|
| 283 | expr go to state 27
|
---|
| 284 | number go to state 11
|
---|
| 285 |
|
---|
| 286 |
|
---|
| 287 | state 18
|
---|
| 288 |
|
---|
| 289 | 11 expr: expr '+' . expr
|
---|
| 290 |
|
---|
| 291 | DIGIT shift, and go to state 4
|
---|
| 292 | PI shift, and go to state 5
|
---|
| 293 | OPEN_PAREN shift, and go to state 6
|
---|
| 294 | '|' shift, and go to state 7
|
---|
| 295 | '-' shift, and go to state 8
|
---|
| 296 |
|
---|
| 297 | expr go to state 28
|
---|
| 298 | number go to state 11
|
---|
| 299 |
|
---|
| 300 |
|
---|
| 301 | state 19
|
---|
| 302 |
|
---|
| 303 | 7 expr: expr '*' . expr
|
---|
| 304 |
|
---|
| 305 | DIGIT shift, and go to state 4
|
---|
| 306 | PI shift, and go to state 5
|
---|
| 307 | OPEN_PAREN shift, and go to state 6
|
---|
| 308 | '|' shift, and go to state 7
|
---|
| 309 | '-' shift, and go to state 8
|
---|
| 310 |
|
---|
| 311 | expr go to state 29
|
---|
| 312 | number go to state 11
|
---|
| 313 |
|
---|
| 314 |
|
---|
| 315 | state 20
|
---|
| 316 |
|
---|
| 317 | 8 expr: expr '/' . expr
|
---|
| 318 |
|
---|
| 319 | DIGIT shift, and go to state 4
|
---|
| 320 | PI shift, and go to state 5
|
---|
| 321 | OPEN_PAREN shift, and go to state 6
|
---|
| 322 | '|' shift, and go to state 7
|
---|
| 323 | '-' shift, and go to state 8
|
---|
| 324 |
|
---|
| 325 | expr go to state 30
|
---|
| 326 | number go to state 11
|
---|
| 327 |
|
---|
| 328 |
|
---|
| 329 | state 21
|
---|
| 330 |
|
---|
| 331 | 9 expr: expr '%' . expr
|
---|
| 332 |
|
---|
| 333 | DIGIT shift, and go to state 4
|
---|
| 334 | PI shift, and go to state 5
|
---|
| 335 | OPEN_PAREN shift, and go to state 6
|
---|
| 336 | '|' shift, and go to state 7
|
---|
| 337 | '-' shift, and go to state 8
|
---|
| 338 |
|
---|
| 339 | expr go to state 31
|
---|
| 340 | number go to state 11
|
---|
| 341 |
|
---|
| 342 |
|
---|
| 343 | state 22
|
---|
| 344 |
|
---|
| 345 | 12 expr: expr '!' .
|
---|
| 346 |
|
---|
| 347 | $default reduce using rule 12 (expr)
|
---|
| 348 |
|
---|
| 349 |
|
---|
| 350 | state 23
|
---|
| 351 |
|
---|
| 352 | 13 expr: expr EXPONENT . expr
|
---|
| 353 |
|
---|
| 354 | DIGIT shift, and go to state 4
|
---|
| 355 | PI shift, and go to state 5
|
---|
| 356 | OPEN_PAREN shift, and go to state 6
|
---|
| 357 | '|' shift, and go to state 7
|
---|
| 358 | '-' shift, and go to state 8
|
---|
| 359 |
|
---|
| 360 | expr go to state 32
|
---|
| 361 | number go to state 11
|
---|
| 362 |
|
---|
| 363 |
|
---|
| 364 | state 24
|
---|
| 365 |
|
---|
| 366 | 18 number: number DIGIT .
|
---|
| 367 |
|
---|
| 368 | $default reduce using rule 18 (number)
|
---|
| 369 |
|
---|
| 370 |
|
---|
| 371 | state 25
|
---|
| 372 |
|
---|
| 373 | 5 expr: OPEN_PAREN expr CLOSE_PAREN .
|
---|
| 374 |
|
---|
| 375 | $default reduce using rule 5 (expr)
|
---|
| 376 |
|
---|
| 377 |
|
---|
| 378 | state 26
|
---|
| 379 |
|
---|
| 380 | 6 expr: '|' expr '|' .
|
---|
| 381 |
|
---|
| 382 | $default reduce using rule 6 (expr)
|
---|
| 383 |
|
---|
| 384 |
|
---|
| 385 | state 27
|
---|
| 386 |
|
---|
| 387 | 7 expr: expr . '*' expr
|
---|
| 388 | 8 | expr . '/' expr
|
---|
| 389 | 9 | expr . '%' expr
|
---|
| 390 | 10 | expr . '-' expr
|
---|
| 391 | 10 | expr '-' expr .
|
---|
| 392 | 11 | expr . '+' expr
|
---|
| 393 | 12 | expr . '!'
|
---|
| 394 | 13 | expr . EXPONENT expr
|
---|
| 395 |
|
---|
| 396 | '*' shift, and go to state 19
|
---|
| 397 | '/' shift, and go to state 20
|
---|
| 398 | '%' shift, and go to state 21
|
---|
| 399 | '!' shift, and go to state 22
|
---|
| 400 | EXPONENT shift, and go to state 23
|
---|
| 401 |
|
---|
| 402 | $default reduce using rule 10 (expr)
|
---|
| 403 |
|
---|
| 404 |
|
---|
| 405 | state 28
|
---|
| 406 |
|
---|
| 407 | 7 expr: expr . '*' expr
|
---|
| 408 | 8 | expr . '/' expr
|
---|
| 409 | 9 | expr . '%' expr
|
---|
| 410 | 10 | expr . '-' expr
|
---|
| 411 | 11 | expr . '+' expr
|
---|
| 412 | 11 | expr '+' expr .
|
---|
| 413 | 12 | expr . '!'
|
---|
| 414 | 13 | expr . EXPONENT expr
|
---|
| 415 |
|
---|
| 416 | '*' shift, and go to state 19
|
---|
| 417 | '/' shift, and go to state 20
|
---|
| 418 | '%' shift, and go to state 21
|
---|
| 419 | '!' shift, and go to state 22
|
---|
| 420 | EXPONENT shift, and go to state 23
|
---|
| 421 |
|
---|
| 422 | $default reduce using rule 11 (expr)
|
---|
| 423 |
|
---|
| 424 |
|
---|
| 425 | state 29
|
---|
| 426 |
|
---|
| 427 | 7 expr: expr . '*' expr
|
---|
| 428 | 7 | expr '*' expr .
|
---|
| 429 | 8 | expr . '/' expr
|
---|
| 430 | 9 | expr . '%' expr
|
---|
| 431 | 10 | expr . '-' expr
|
---|
| 432 | 11 | expr . '+' expr
|
---|
| 433 | 12 | expr . '!'
|
---|
| 434 | 13 | expr . EXPONENT expr
|
---|
| 435 |
|
---|
| 436 | '!' shift, and go to state 22
|
---|
| 437 | EXPONENT shift, and go to state 23
|
---|
| 438 |
|
---|
| 439 | $default reduce using rule 7 (expr)
|
---|
| 440 |
|
---|
| 441 |
|
---|
| 442 | state 30
|
---|
| 443 |
|
---|
| 444 | 7 expr: expr . '*' expr
|
---|
| 445 | 8 | expr . '/' expr
|
---|
| 446 | 8 | expr '/' expr .
|
---|
| 447 | 9 | expr . '%' expr
|
---|
| 448 | 10 | expr . '-' expr
|
---|
| 449 | 11 | expr . '+' expr
|
---|
| 450 | 12 | expr . '!'
|
---|
| 451 | 13 | expr . EXPONENT expr
|
---|
| 452 |
|
---|
| 453 | '!' shift, and go to state 22
|
---|
| 454 | EXPONENT shift, and go to state 23
|
---|
| 455 |
|
---|
| 456 | $default reduce using rule 8 (expr)
|
---|
| 457 |
|
---|
| 458 |
|
---|
| 459 | state 31
|
---|
| 460 |
|
---|
| 461 | 7 expr: expr . '*' expr
|
---|
| 462 | 8 | expr . '/' expr
|
---|
| 463 | 9 | expr . '%' expr
|
---|
| 464 | 9 | expr '%' expr .
|
---|
| 465 | 10 | expr . '-' expr
|
---|
| 466 | 11 | expr . '+' expr
|
---|
| 467 | 12 | expr . '!'
|
---|
| 468 | 13 | expr . EXPONENT expr
|
---|
| 469 |
|
---|
| 470 | '!' shift, and go to state 22
|
---|
| 471 | EXPONENT shift, and go to state 23
|
---|
| 472 |
|
---|
| 473 | $default reduce using rule 9 (expr)
|
---|
| 474 |
|
---|
| 475 |
|
---|
| 476 | state 32
|
---|
| 477 |
|
---|
| 478 | 7 expr: expr . '*' expr
|
---|
| 479 | 8 | expr . '/' expr
|
---|
| 480 | 9 | expr . '%' expr
|
---|
| 481 | 10 | expr . '-' expr
|
---|
| 482 | 11 | expr . '+' expr
|
---|
| 483 | 12 | expr . '!'
|
---|
| 484 | 13 | expr . EXPONENT expr
|
---|
| 485 | 13 | expr EXPONENT expr .
|
---|
| 486 |
|
---|
| 487 | EXPONENT shift, and go to state 23
|
---|
| 488 |
|
---|
| 489 | $default reduce using rule 13 (expr)
|
---|