Safe Haskell | Safe |
---|---|
Language | Haskell98 |
DDC.Core.Lexer.Offside
Description
Apply the offside rule to a token stream to add braces.
- data Lexeme n
- = LexemeToken (Located (Token n))
- | LexemeStartLine Int
- | LexemeStartBlock Int
- applyOffside :: (Eq n, Show n) => [Paren] -> [Context] -> [Lexeme n] -> [Located (Token n)]
- addStarts :: (Eq n, Show n) => [Located (Token n)] -> [Lexeme n]
Documentation
Holds a real token or start symbol which is used to apply the offside rule.
Constructors
LexemeToken (Located (Token n)) | |
LexemeStartLine Int | |
LexemeStartBlock Int | Signal that we're starting a block in this column. |
Arguments
:: (Eq n, Show n) | |
=> [Paren] | What parenthesis we're inside. |
-> [Context] | Current layout context. |
-> [Lexeme n] | Input lexemes. |
-> [Located (Token n)] |
Apply the offside rule to this token stream.
It should have been processed with addStarts first to add the LexemeStartLine/LexemeStartLine tokens.
Unlike the definition in the Haskell 98 report, we explicitly track which parenthesis we're inside. We use these to partly implement the layout rule that says we much check for entire parse errors to perform the offside rule.