happy-lib-2.1.7: Happy is a parser generator for Haskell implemented using this library

Safe Haskell | None
Language | Haskell98

Happy.Grammar

Description

This module exports the `Grammar` data type, which

Synopsis

- newtype Name = MkName {
  - getName :: Int
  }
- data Production eliminator = Production Name [Name] (eliminator, [Int]) Priority
- data TokenSpec
  - = TokenFixed String
  - | TokenWithValue ExpressionWithHole
- data Grammar eliminator = Grammar {
  - productions :: [Production eliminator]
  - lookupProdNo :: Int -> Production eliminator
  - lookupProdsOfName :: Name -> [Int]
  - token_specs :: [(Name, TokenSpec)]
  - terminals :: [Name]
  - non_terminals :: [Name]
  - starts :: [(String, Name, Name, Bool)]
  - types :: Array Name (Maybe String)
  - token_names :: Array Name String
  - first_nonterm :: Name
  - first_term :: Name
  - eof_term :: Name
  - priorities :: [(Name, Priority)]
  }
- data AttributeGrammarExtras = AttributeGrammarExtras {
  - attributes :: [(String, String)]
  - attributetype :: String
  }
- data Priority
  - = No
  - | Prio Assoc Int
  - | PrioLowest
- data Assoc
  - = LeftAssoc
  - | RightAssoc
  - | None
- data ErrorHandlerInfo
  - = DefaultErrorHandler
  - | CustomErrorHandler String
  - | ResumptiveErrorHandler String String
- data ErrorExpectedMode
  - = NoExpected
  - | OldExpected
  - | NewExpected
- data Directives = Directives {
  - token_type :: String
  - imported_identity :: Bool
  - monad :: (Bool, String, String, String, String)
  - expect :: Maybe Int
  - lexer :: Maybe (String, String)
  - error_handler :: ErrorHandlerInfo
  - error_expected :: ErrorExpectedMode
  }
- errorName :: String
- errorTok :: Name
- catchName :: String
- catchTok :: Name
- startName :: String
- dummyName :: String
- firstStartTok :: Name
- dummyTok :: Name
- eofName :: String
- epsilonTok :: Name

# Documentation

newtype Name Source #

Constructors

MkName |

Fields

- getName :: Int

#### Instances

Instances details

Enum Name Source # |
Instance details Defined in Happy.Grammar Methods succ :: Name -> Name Source # pred :: Name -> Name Source # toEnum :: Int -> Name Source # fromEnum :: Name -> Int Source # enumFrom :: Name -> [Name] Source # enumFromThen :: Name -> Name -> [Name] Source # enumFromTo :: Name -> Name -> [Name] Source # enumFromThenTo :: Name -> Name -> Name -> [Name] Source #
Ix Name Source # |
Instance details Defined in Happy.Grammar Methods range :: (Name, Name) -> [Name] Source # index :: (Name, Name) -> Name -> Int Source # unsafeIndex :: (Name, Name) -> Name -> Int Source # inRange :: (Name, Name) -> Name -> Bool Source # rangeSize :: (Name, Name) -> Int Source # unsafeRangeSize :: (Name, Name) -> Int Source #
Read Name Source # |
Instance details Defined in Happy.Grammar Methods readsPrec :: Int -> ReadS Name Source # readList :: ReadS [Name] Source # readPrec :: ReadPrec Name Source # readListPrec :: ReadPrec [Name] Source #
Show Name Source # |
Instance details Defined in Happy.Grammar Methods showsPrec :: Int -> Name -> ShowS Source # show :: Name -> String Source # showList :: [Name] -> ShowS Source #
Eq Name Source # |
Instance details Defined in Happy.Grammar Methods (==) :: Name -> Name -> Bool Source # (/=) :: Name -> Name -> Bool Source #
Ord Name Source # |
Instance details Defined in Happy.Grammar Methods compare :: Name -> Name -> Ordering Source # (<) :: Name -> Name -> Bool Source # (<=) :: Name -> Name -> Bool Source # (>) :: Name -> Name -> Bool Source # (>=) :: Name -> Name -> Bool Source # max :: Name -> Name -> Name Source # min :: Name -> Name -> Name Source #

data Production eliminator Source #

Constructors

Production Name [Name] (eliminator, [Int]) Priority |

#### Instances

Instances details

Show eliminator => Show (Production eliminator) Source # |
Instance details Defined in Happy.Grammar Methods showsPrec :: Int -> Production eliminator -> ShowS Source # show :: Production eliminator -> String Source # showList :: [Production eliminator] -> ShowS Source #

data TokenSpec Source #

Constructors

TokenFixed String | The token is just a fixed value
TokenWithValue ExpressionWithHole | The token is an expression involving the value of the lexed token.

#### Instances

Instances details

Show TokenSpec Source # |
Instance details Defined in Happy.Grammar Methods showsPrec :: Int -> TokenSpec -> ShowS Source # show :: TokenSpec -> String Source # showList :: [TokenSpec] -> ShowS Source #
Eq TokenSpec Source # |
Instance details Defined in Happy.Grammar Methods (==) :: TokenSpec -> TokenSpec -> Bool Source # (/=) :: TokenSpec -> TokenSpec -> Bool Source #

data Grammar eliminator Source #

Constructors

Grammar |

Fields

- productions :: [Production eliminator]
- lookupProdNo :: Int -> Production eliminator
- lookupProdsOfName :: Name -> [Int]
- token_specs :: [(Name, TokenSpec)]
- terminals :: [Name]
- non_terminals :: [Name]
- starts :: [(String, Name, Name, Bool)]
- types :: Array Name (Maybe String)
- token_names :: Array Name String
- first_nonterm :: Name
- first_term :: Name
- eof_term :: Name
- priorities :: [(Name, Priority)]

#### Instances

Instances details

Show eliminator => Show (Grammar eliminator) Source # |
Instance details Defined in Happy.Grammar Methods showsPrec :: Int -> Grammar eliminator -> ShowS Source # show :: Grammar eliminator -> String Source # showList :: [Grammar eliminator] -> ShowS Source #

data AttributeGrammarExtras Source #

Constructors

AttributeGrammarExtras |

Fields

- attributes :: [(String, String)]
- attributetype :: String

data Priority Source #

Constructors

No |
Prio Assoc Int |
PrioLowest |

#### Instances

Instances details

Show Priority Source # |
Instance details Defined in Happy.Grammar Methods showsPrec :: Int -> Priority -> ShowS Source # show :: Priority -> String Source # showList :: [Priority] -> ShowS Source #
Eq Priority Source # |
Instance details Defined in Happy.Grammar Methods (==) :: Priority -> Priority -> Bool Source # (/=) :: Priority -> Priority -> Bool Source #

data Assoc Source #

Constructors

LeftAssoc |
RightAssoc |
None |

#### Instances

Instances details

Show Assoc Source # |
Instance details Defined in Happy.Grammar Methods showsPrec :: Int -> Assoc -> ShowS Source # show :: Assoc -> String Source # showList :: [Assoc] -> ShowS Source #

data ErrorHandlerInfo Source #

Constructors

DefaultErrorHandler | Default handler `happyError`
CustomErrorHandler String | Call this handler on error.
ResumptiveErrorHandler String String | `ResumptiveErrorHandler abort report`: Upon encountering a parse error, call non-fatal function `report`. Then try to resume parsing by finding a catch production. If that ultimately fails, call `abort`.

data ErrorExpectedMode Source #

Constructors

NoExpected | Neither `%errorhandertype explist` nor `%error.expected`
OldExpected | `%errorhandertype explist`. The error handler takes a pair `(Token, [String])`
NewExpected | `%error.expected`. The error handler takes two (or more) args `Token -> [String] -> ...`.

#### Instances

Instances details

Eq ErrorExpectedMode Source # |
Instance details Defined in Happy.Grammar Methods (==) :: ErrorExpectedMode -> ErrorExpectedMode -> Bool Source # (/=) :: ErrorExpectedMode -> ErrorExpectedMode -> Bool Source #

data Directives Source #

Stuff like `%monad`, `%expect`

Constructors

Directives |

Fields

- token_type :: String
- imported_identity :: Bool
- monad :: (Bool, String, String, String, String)
- expect :: Maybe Int
- lexer :: Maybe (String, String)
- error_handler :: ErrorHandlerInfo
- error_expected :: ErrorExpectedMode

  Error handler specified in `error_handler` takes a `[String]` carrying the pretty-printed expected tokens

errorName :: String Source #

errorTok :: Name Source #

catchName :: String Source #

catchTok :: Name Source #

startName :: String Source #

dummyName :: String Source #

firstStartTok :: Name Source #

dummyTok :: Name Source #

eofName :: String Source #

epsilonTok :: Name Source #