Safe Haskell | None |
---|---|
Language | Haskell2010 |
Front.Scanner
Description
Scanner for sslang.
In addition to tokenizing the input text stream, this scanner is responsible for the following:
- Insert implicit open braces after any block-starting token, if necessary;
- Insert implicit separators for aligned lines within the same block; and
- Insert implicit close braces if an implicit block closed, either by a decrease in indentation, or by the closure of a surrounding explicit block.
As such, the scanner's state is enriched with a stack of contexts which it uses to perform basic delimiter matching. It also relies on epsilon transitions to emit implicit tokens.
Synopsis
- scanTokens :: String -> Pass [Token]
- scanTokenTypes :: String -> Pass [TokenType]
- lexerForHappy :: (Token -> Alex a) -> Alex a
- newtype Token = Token (Span, TokenType)
- data TokenType
- = TEOF
- | TType
- | TIf
- | TElse
- | TWhile
- | TDo
- | TPar
- | TLoop
- | TLet
- | TNow
- | TAtAt
- | TBreak
- | TMatch
- | TAfter
- | TWait
- | TFun
- | TExtern
- | TEq
- | TLarrow
- | TRarrow
- | TDRarrow
- | TDBar
- | TColon
- | TSemicolon
- | TBar
- | TComma
- | TUnderscore
- | TAt
- | TAmpersand
- | TLparen
- | TRparen
- | TLbrace
- | TRbrace
- | TLbracket
- | TRbracket
- | TInteger Integer
- | TString String
- | TId Identifier
- | TOp Identifier
- | TCSym Identifier
- | TCQuote String
- | TCBlock String
- data Span = Span {}
- syntaxErr :: String -> Alex a
- internalErr :: String -> Alex a
- liftErr :: String -> Error
Documentation
scanTokenTypes :: String -> Pass [TokenType] Source #
Extract a stream of token types (without span) from an input string.
Tokens extracted from source text.
The types of tokens that can appear in a sslang source file.
Constructors
The location of a token in the source text.
internalErr :: String -> Alex a Source #
Internal compiler error for unreachable code.