ddc-core-0.3.1.1: Disciplined Disciple Compiler core language and type checker.

Safe HaskellNone

DDC.Core.Lexer.Tokens

Contents

Synopsis

Tokens

data Tok n Source

Tokens accepted by the core language parser.

Constructors

KJunk String

Some junk symbol that isn't part of the language.

KM !TokMeta

Meta tokens contain out-of-band information that is eliminated before parsing proper.

KA !TokAtom

Atomic tokens are keywords, punctuation and baked-in constructor names.

KN !(TokNamed n)

A named token that is specific to the language fragment (maybe it's a primop), or a user defined name.

Instances

Eq n => Eq (Tok n) 
Show n => Show (Tok n) 

renameTok :: Ord n2 => (n1 -> Maybe n2) -> Tok n1 -> Maybe (Tok n2)Source

Apply a function to all the names in a Tok.

describeTok :: Pretty n => Tok n -> StringSource

Describe a token for parser error messages.

Meta Tokens

data TokMeta Source

Meta tokens contain out-of-band information that is eliminated before parsing proper.

Constructors

KNewLine 
KCommentLineStart 
KCommentBlockStart 
KCommentBlockEnd 
KCommentUnterminated

This is injected by dropCommentBlock when it finds an unterminated block comment.

KOffsideClosingBrace

This is injected by applyOffside when it finds an explit close brace in a position where it would close a synthetic one.

Instances

describeTokMeta :: TokMeta -> StringSource

Describe a TokMeta, for lexer error messages.

Atomic Tokens

describeTokAtom :: TokAtom -> StringSource

Describe a TokAtom, for parser error messages.

Named Tokens

data TokNamed n Source

A token with a user-defined name.

Constructors

KCon n 
KVar n 
KLit n 

Instances

Eq n => Eq (TokNamed n) 
Show n => Show (TokNamed n) 

describeTokNamed :: Pretty n => TokNamed n -> StringSource

Describe a TokNamed, for parser error messages.