<commit_before>module Language.TheExperiment.Parser.Lexer where

import Text.Parsec
import qualified Text.Parsec.Token as T

import Control.Monad

eLanguageDef = T.LanguageDef
  { T.commentStart    = "/*"
  , T.commentEnd      = "*/"
  , T.commentLine     = "//"
  , T.nestedComments  = True
  , T.identStart      = letter <|> char '_'
  , T.identLetter     = alphaNum <|> char '_'
  , T.opStart         = oneOf ":!#$%&*+./<=>?@\\^|-~"
  , T.opLetter        = oneOf ":!#$%&*+./<=>?@\\^|-~"
  , T.reservedOpNames = []
  , T.reservedNames   = ["type", "var", "foreign"]
  , T.caseSensitive   = True
  }

lexer :: T.TokenParser ()
lexer = T.makeTokenParser eLanguageDef

parens        = T.parens lexer
identifier    = T.identifier lexer
lexeme        = T.lexeme lexer
comma         = T.comma lexer
commaSep1     = T.commaSep1 lexer
symbol        = T.symbol lexer
reserved      = T.reserved lexer
stringLiteral = T.stringLiteral lexer

typeIdent  = lexeme $ do
  f <- oneOf ['A'..'Z']
  r <- many $ alphaNum <|> char '_'
  return $ f : r
varIdent   = lexeme $ do<commit_msg>prettyify a few things.<commit_after>module Language.TheExperiment.Parser.Lexer where

import Text.Parsec
import qualified Text.Parsec.Token as T

import Control.Monad

opChars = oneOf ":!#$%&*+./<=>?@\\^|-~"

eLanguageDef = T.LanguageDef
  { T.commentStart    = "/*"
  , T.commentEnd      = "*/"
  , T.commentLine     = "//"
  , T.nestedComments  = True
  , T.identStart      = letter <|> char '_'
  , T.identLetter     = alphaNum <|> char '_'
  , T.opStart         = opChars
  , T.opLetter        = opChars
  , T.reservedOpNames = []
  , T.reservedNames   = ["type", "var", "foreign"]
  , T.caseSensitive   = True
  }

lexer :: T.TokenParser ()
lexer = T.makeTokenParser eLanguageDef

parens        = T.parens        lexer
identifier    = T.identifier    lexer
lexeme        = T.lexeme        lexer
comma         = T.comma         lexer
commaSep1     = T.commaSep1     lexer
symbol        = T.symbol        lexer
reserved      = T.reserved      lexer
stringLiteral = T.stringLiteral lexer

typeIdent  = lexeme $ do
  f <- oneOf ['A'..'Z']
  r <- many $ alphaNum <|> char '_'
  return $ f : r
varIdent   = lexeme $ do
{'fraction_non_alphanumeric': 0.14853747714808044, 'fraction_numerical': 0.0018281535648994515, 'mean_word_length': 2.357361963190184, 'pattern_counts': {'":': 3, '<': 16, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5319818', 'n_tokens_mistral': 840, 'n_tokens_neox': 781, 'n_words': 166}