| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
IHP.Router.DSL.Parser
Description
The parser consumes the textual body of a [routes| ... |] block and
produces a Routes AST. Errors carry the source line number so the TH
splice can report them with useful context.
The parser is intentionally hand-rolled — the DSL is small (~7 production rules) and we want precise control over error messages.
Synopsis
- parseRoutes :: Text -> Either ParseError Routes
- data ParseError = ParseError {
- errorLine :: !Int
- errorMessage :: !Text
Documentation
parseRoutes :: Text -> Either ParseError Routes Source #
Parse a raw [routes|...|] body into a Routes AST.
The input is the text between the opening | and the closing |] (the
quoter strips those).
The block may optionally start with a controller-name header — a bare uppercase identifier on its own line before any route lines. If absent, the block is multi-controller and the splice groups routes by reifying each action constructor to find its parent type.
data ParseError Source #
Parse error from the DSL parser.
The Int is the 1-based source line number inside the quasi-quote body
(the controller header is line 1).
Constructors
| ParseError | |
Fields
| |
Instances
| Show ParseError Source # | |
Defined in IHP.Router.DSL.Parser Methods showsPrec :: Int -> ParseError -> ShowS # show :: ParseError -> String # showList :: [ParseError] -> ShowS # | |
| Eq ParseError Source # | |
Defined in IHP.Router.DSL.Parser | |