| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
ReWire.Eidos.Lexer
Description
The lexical layer of the Eidos concrete syntax (doc/eidos.md §9): the
token parsers, the reserved-word table, and the identifier predicate —
each defined once, so that ReWire.Eidos.Parse (which reads the
format) and ReWire.Eidos.Pretty (which backtick-quotes exactly the
occurrence texts that would not lex as identifiers) cannot disagree.
The grammar is newline-insensitive: space skips -- line comments
along with whitespace, and a # separates an identifier from its
unique, terminating keywords too (case#1 is a name token).
Synopsis
- type Parser = Parsec Void Text
- failParse :: MonadError AstError m => ParseErrorBundle Text Void -> m a
- space :: Parser ()
- lexeme :: Parser a -> Parser a
- symbol :: Text -> Parser Text
- withSpan :: Parser (Annote -> a) -> Parser a
- getAnn :: Parser Annote
- keyword :: Text -> Parser ()
- reservedWords :: HashSet Text
- isIdentStart :: Char -> Bool
- isIdentChar :: Char -> Bool
- identStartChar :: Parser Char
- identChar :: Parser Char
- identRaw :: Parser Text
- uniqName :: Parser (Text, Uniq)
- bareName :: Parser Text
- tupleName :: Parser Text
- conName :: Parser Text
- listConName :: Parser Text
- underscore :: Parser ()
- natural :: Parser Natural
- integer :: Parser Integer
- stringLit :: Parser Text
- comma :: Parser ()
- semi :: Parser ()
- arrow :: Parser ()
- dcolon :: Parser ()
- equals :: Parser ()
- parens :: Parser a -> Parser a
- braces :: Parser a -> Parser a
- brackets :: Parser a -> Parser a
Documentation
failParse :: MonadError AstError m => ParseErrorBundle Text Void -> m a Source #
A parse failure as a located AstError (at the first error's
position).
withSpan :: Parser (Annote -> a) -> Parser a Source #
Run a parser that builds a node from an annotation, supplying it the source span the parser consumed so the node carries a real location.
getAnn :: Parser Annote Source #
A point annotation at the current position (for nodes built by folds,
where withSpan does not fit).
keyword :: Text -> Parser () Source #
# separates an identifier from its unique, so it terminates keywords
too: case#1 is a name token, not the keyword case.
reservedWords :: HashSet Text Source #
The reserved words of the concrete syntax: every keyword of the
grammar, plus _ (the default alternative). One table for the parser
(a bare name may not be one of these) and the printer (which quotes an
occurrence that is one).
isIdentStart :: Char -> Bool Source #
The identifier lexeme: a start character, then identifier characters
(dotted, primed, and $-marked names included). The printer's quoting
predicate is the same pair of tests.
isIdentChar :: Char -> Bool Source #
The identifier lexeme: a start character, then identifier characters
(dotted, primed, and $-marked names included). The printer's quoting
predicate is the same pair of tests.
identRaw :: Parser Text Source #
Raw (non-lexeme) dotted identifier text, or a backtick-quoted name (arbitrary text; the printer quotes occurrences that do not lex as identifiers, e.g. operator names).
uniqName :: Parser (Text, Uniq) Source #
A unique-carrying name token, occ#uniq (term variables, type
variables, labels). Reserved words are admitted as occurrence text:
the # disambiguates them from keywords.
bareName :: Parser Text Source #
A bare dotted name with no unique (type/data constructors, primitives, provenance names).
tupleName :: Parser Text Source #
The unit and tuple constructor names: (), (,), (,,), ...
(written tightly, as printed).
conName :: Parser Text Source #
A constructor name position: bare, the (,) family, or the list type
constructors (which appear as declared datatype names in dumps).
listConName :: Parser Text Source #
underscore :: Parser () Source #
The default-alternative wildcard (_ alone is also a valid identifier
start, so it needs the same guards as a keyword).