-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto-resolve shift/reduce conflicts involving the catch token
When the current token is the catch token, we never reduce; we only ever shift. Hence it does not make sense to report shift/reduce conflicts involving the catch token: Error resumption mode will only ever try to shift it. The solution implemented in this patch is not to generate conflicting LR'Reduce actions in the first place by deleting the catch token from the lookahead sets of LR1 items.
- Loading branch information
Showing
5 changed files
with
64 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
module Main where | ||
|
||
import Data.Char | ||
} | ||
|
||
%name parseExp Exp | ||
%tokentype { Token } | ||
%error { abort } { reportError } | ||
|
||
%monad { ParseM } { (>>=) } { return } | ||
|
||
%token | ||
'1' { TOne } | ||
'+' { TPlus } | ||
'(' { TOpen } | ||
')' { TClose } | ||
|
||
%right '+' | ||
%expect 0 -- The point of this test: The List productions should expose a shift/reduce conflict because of catch | ||
|
||
%% | ||
|
||
Close :: { String } | ||
Close : ')' { ")" } | ||
| catch { "catch" } | ||
|
||
Exp :: { String } | ||
Exp : catch { "catch" } | ||
| '1' { "1"} | ||
| '(' List Close { "(" ++ $2 ++ $3 } | ||
|
||
List :: { String } | ||
: Exp '+' { $1 ++ "+" } | ||
| Exp '+' Exp { $1 ++ "+" ++ $3 } | ||
|
||
{ | ||
data Token = TOne | TPlus | TComma | TOpen | TClose | ||
|
||
type ParseM = Maybe | ||
|
||
abort :: [Token] -> ParseM a | ||
abort = undefined | ||
|
||
reportError :: [Token] -> ([Token] -> ParseM a) -> ParseM a | ||
reportError = undefined | ||
|
||
main :: IO () | ||
main = return () | ||
} |