haskell / haskell/happy

Unused states

Open
#138 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
322
Forks
86
PR merge metrics
No merged PRs in 30d

Description

With the grammar file below, and running with `-i`, happy produces two unused states (1 and 2). I don't know enough about how happy parsers run to know if these slow the parser down, but it seems these states can be trimmed. Initially discovered by @sdepew97.

```
%expect 0
%name parse
%tokentype { Token }
%error { (error . show) }

%token
NUMBER { NUMBER $$ }
'+' { PLUS }
'*' { TIMES }
'(' { LPAREN }
')' { RPAREN }

%%

sum : sum '+' prod { () }
| prod { () }

prod : prod '*' factor { () }
| factor { () }

factor : '(' sum ')' { () }
| NUMBER { () }

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.