makeTokenParser

makeTokenParser :: Stream s m Char => GenLanguageDef s u m -> GenTokenParser s u m
parsec Text.Parsec.Token, parsec Text.ParserCombinators.Parsec.Token
The expression makeTokenParser language creates a GenTokenParser record that contains lexical parsers that are defined using the definitions in the language record. The use of this function is quite stylized - one imports the appropiate language definition and selects the lexical parsers that are needed from the resulting GenTokenParser. > module Main > > import Text.Parsec > import qualified Text.Parsec.Token as P > import Text.Parsec.Language (haskellDef) > > -- The parser > ... > > expr = parens expr > <|> identifier > <|> ... > > > -- The lexer > lexer = P.makeTokenParser haskellDef > > parens = P.parens lexer > braces = P.braces lexer > identifier = P.identifier lexer > reserved = P.reserved lexer > ...