<commit_before>module Parser where

import Text.Parsec as P
import Control.Applicative ((<$>),(<*), (*>), (<*>)) 

type PropName = String
type VarName = String
data PropAccessPath = PropAccessPath  VarName [PropName] deriving (Show)

propAccessParser :: Parsec String st PropAccessPath
propAccessParser = PropAccessPath <$> (varName <* char '.') <*> accesses
  where
    identifier = alphaNum <|> char '_'
    varName = many1 identifier
    accesses = (P.many1 identifier) `sepBy` (char '.')

fileParser :: Parsec String st [PropAccessPath]
fileParser = P.many (P.many html *> propAccessParser <* P.many html) <* eof
  where
    html = spaces *> char '<' *> (many1 $ noneOf "<>") <* char '>' <* spaces

test :: Parsec String () a -> String -> Either ParseError a
test p = parse p ""
<commit_msg>Add type alias for Parser.<commit_after>module Parser (propAccessParser, fileParser, test) where

import Text.Parsec as P
import Control.Applicative ((<$>),(<*), (*>), (<*>)) 

type PropName = String
type VarName = String
data PropAccessPath = PropAccessPath  VarName [PropName] deriving (Show)

type Parser = Parsec String ()

propAccessParser :: Parser PropAccessPath
propAccessParser = PropAccessPath <$> (varName <* char '.') <*> accesses
  where
    identifier = alphaNum <|> char '_'
    varName = many1 identifier
    accesses = (P.many1 identifier) `sepBy` (char '.')

fileParser :: Parser [PropAccessPath]
fileParser = P.many (P.many html *> propAccessParser <* P.many html) <* eof
  where
    html :: Parser String
    html = spaces *> char '<' *> (many1 $ noneOf "<>") <* char '>' <* spaces

test :: Parsec String () a -> String -> Either ParseError a
test p = parse p ""

{'fraction_non_alphanumeric': 0.1466030989272944, 'fraction_numerical': 0.003575685339690107, 'mean_word_length': 4.182098765432099, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '5580152', 'n_tokens_mistral': 537, 'n_tokens_neox': 532, 'n_words': 164}