<commit_before>{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Haskell98 #-}
module Core.Lexers where

import Prelude hiding (lex)
import Core.Datatypes

import Control.Applicative ((<*),(<$>),(<*>),(*>),(<$))
import Text.Parsec
import Text.Parsec.String
import Text.Parsec.Char
import Text.Parsec.Error
import Text.Parsec.Token as P
import Text.Parsec.Prim
import Text.Parsec.Language
import Text.Parsec.Expr


-- stuff about the language and the default lexer
tagletter = oneOf "~!@#$%^&*_+|`-=\\{}:\"<>?[]',./"

lang :: LanguageDef st
lang = javaStyle
     { reservedNames = ["commentstyle","tagstyle","if","else","true","false"]
     , caseSensitive = True
     , opStart  = tagletter
     , opLetter = tagletter
     }

lex = P.makeTokenParser lang

-- alternative lexer for style definitions
styleLang :: LanguageDef st
styleLang = emptyDef
          { opStart  = tagletter
          , opLetter = tagletter }

styleLex = P.makeTokenParser styleLang


-- TODO make parameterised lexer for body?<commit_msg>apparently not<commit_after>{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE Haskell98 #-}
module Core.Lexers where

import Prelude hiding (lex)
import Core.Datatypes

import Control.Applicative ((<*),(<$>),(<*>),(*>),(<$))
import Text.Parsec
import Text.Parsec.String
import Text.Parsec.Char
import Text.Parsec.Error
import Text.Parsec.Token as P
import Text.Parsec.Prim
import Text.Parsec.Language
import Text.Parsec.Expr


-- stuff about the language and the default lexer
tagletter = oneOf "~!@#$%^&*_+|`-=\\{}:\"<>?[]',./"

lang :: LanguageDef st
lang = javaStyle
     { reservedNames = ["commentstyle","tagstyle","if","else","true","false"]
     , caseSensitive = True
     , opStart  = tagletter
     , opLetter = tagletter
     }

lex = P.makeTokenParser lang

-- alternative lexer for style definitions
styleLang :: LanguageDef st
styleLang = emptyDef
          { opStart  = tagletter
          , opLetter = tagletter }

styleLex = P.makeTokenParser styleLang
{'fraction_non_alphanumeric': 0.14610717896865522, 'fraction_numerical': 0.0020222446916076846, 'mean_word_length': 3.9598997493734336, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '3054222', 'n_tokens_mistral': 669, 'n_tokens_neox': 640, 'n_words': 160}