rewire-frontend-2.8: A Haskell-to-Verilog/VHDL compiler, front end (GHC driver, Eidos, Synolon)
Safe HaskellSafe
LanguageHaskell2010

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

Documentation

type Parser = Parsec Void Text Source #

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).

underscore :: Parser () Source #

The default-alternative wildcard (_ alone is also a valid identifier start, so it needs the same guards as a keyword).

stringLit :: Parser Text Source #

String literals, with exactly the escapes the printer emits: \\ \" \n \t \r.