Created
June 2, 2020 12:20
-
-
Save aiya000/471ca6a06e9c982324afad9d98888f7f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
module Main where | |
} | |
%error { parseError } | |
%errorhandlertype explist | |
%monad { Either String } | |
%name parseFoo | |
%tokentype { Char } | |
%token | |
char { $$ } | |
%% | |
Foo :: { String } | |
: char {% Left "error" } | |
| char { "good" } | |
{ | |
parseError :: ([Char], [String]) -> Either String a | |
parseError (got, expected) = Left $ show got <> ", " <> show expected | |
main :: IO () | |
main = print $ parseFoo "x" | |
-- unused rules: 1 | |
-- reduce/reduce conflicts: 1 | |
-- Right "good" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment