Happy.Grammar

happy-lib-2.2: 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 #

Constructors

MkName |
Fields getName :: Int

#### Instances

Instances details

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

data Production eliminator #

Constructors

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

#### Instances

Instances details

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

data TokenSpec #

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

data Grammar eliminator #

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) # |
Instance details Defined in Happy.Grammar Methods showsPrec :: Int -> Grammar eliminator -> ShowS # show :: Grammar eliminator -> String # showList :: [Grammar eliminator] -> ShowS #

data AttributeGrammarExtras #

Constructors

AttributeGrammarExtras |
Fields attributes :: [(String, String)] attributetype :: String

data Priority #

Constructors

No |
Prio Assoc Int |
PrioLowest |

#### Instances

Instances details

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

data Assoc #

Constructors

LeftAssoc |
RightAssoc |
None |

#### Instances

Instances details

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

data ErrorHandlerInfo #

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 #

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 # |
Instance details Defined in Happy.Grammar Methods (==) :: ErrorExpectedMode -> ErrorExpectedMode -> Bool # (/=) :: ErrorExpectedMode -> ErrorExpectedMode -> Bool #

data Directives #

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 #

errorTok :: Name #

catchName :: String #

catchTok :: Name #

startName :: String #

dummyName :: String #

firstStartTok :: Name #

dummyTok :: Name #

eofName :: String #

epsilonTok :: Name #