{- This isn't a lexer in the sense that it provides a JavaScript token-stream. - This module provides character-parsers for various JavaScript tokens. -} module WebBits.JavaScript.Lexer(identifier,reserved,operator,reservedOp,charLiteral, stringLiteral,natural,integer,float,naturalOrFloat, decimal,hexadecimal,octal,symbol,whiteSpace,parens, braces,brackets,squares,semi,comma,colon,dot, identifierStart) where import Prelude hiding (lex) import Text.ParserCombinators.Parsec import qualified Text.ParserCombinators.Parsec.Token as T identifierStart = (letter <|> oneOf "$_") javascriptDef = T.LanguageDef "/*" "*/" "//" False -- no nested comments {- Adapted from syntax/regexps.ss in Dave's code. -} identifierStart (alphaNum <|> oneOf "$_") -- identifier rest (oneOf "{}<>()~.,?:|&^=!+-*/%!") -- operator start (oneOf "=<>|&+") -- operator rest ["break", "case", "catch", "const", "continue", "debugger", "default", "delete", "do", "else", "enum", "false", "finally", "for", "function", "if", "instanceof", "in", "let", "new", "null", "return", "switch", "this", "throw", "true", "try", "typeof", "var", "void", "while", "with"] ["|=", "^=", "&=", "<<=", ">>=", ">>>=", "+=", "-=", "*=", "/=", "%=", "=", ";", ",", "?", ":", "||", "&&", "|", "^", "&", "===", "==", "=", "!==", "!=", "<<", "<=", "<", ">>>", ">>", ">=", ">", "++", "--", "+", "-", "*", "/", "%", "!", "~", ".", "[", "]", "{", "}", "(", ")","