packages feed

funcons-tools-0.1.0.0: src/Funcons/Lexer.hs

module Funcons.Lexer where

import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Language (emptyDef)
import qualified Text.ParserCombinators.Parsec.Token as P

lexer = P.makeTokenParser emptyDef  { P.identStart  = letter
                                    , P.identLetter = alphaNum <|> (char '-')
                                    , P.reservedNames = [ "id", "void", "newline", "depends", "forall", "type_abs", "typevar", "atom", "?", "*", "+"]
                                    , P.reservedOpNames = ["|->", "=>"]
                                    , P.commentLine = "//"
                                    }

types_keywords = ["chars", "strings", "integers","meta", "atoms", "bounded-integers", "computation-types", "empty-type", "unicode-characters", "maps", "types", "algebraic-datatypes", "bits", "ieee-floats", "lists", "sets", "multisets", "vectors", "naturals", "rationals", "thunks", "tuples", "ascii-characters", "values", "unknown"] 

parens          = P.parens lexer 
brackets        = P.brackets lexer
braces          = P.braces lexer
identifier      = P.identifier lexer
natural         = P.natural lexer
reserved        = P.reserved lexer
reservedOp      = P.reservedOp lexer
comma           = P.comma lexer
stringLiteral   = P.stringLiteral lexer
period          = P.dot lexer
commaSep        = P.commaSep lexer
commaSep1       = P.commaSep1 lexer
whiteSpace      = P.whiteSpace lexer
bar             = whiteSpace *> char '|' <* whiteSpace
doubleArrow     = whiteSpace *> reservedOp "=>" <* whiteSpace
barredArrow     = whiteSpace *> reservedOp "|->" <* whiteSpace
barSep2 p       = (:) <$> p <* bar <*> sepBy1 p bar