<commit_before>{-# LANGUAGE ApplicativeDo #-}

module Modifiers where

import Control.Applicative
import Control.Monad

import Parsers
import Annotations

modifierP :: Parser String
modifierP = classModifierP
  <|> accessModifierP
  <|> varianceAnnotationP
  <|> memberModifierP
  <|> parameterModifierP
  <|> typeParameterModifierP
  <|> functionModifierP
  <|> propertyModifierP
--

modifiersP :: Parser String
modifiersP = do
  ls <- option0 [] $ spacesP \|/ modifierP <|> annotationsP
  return $ join ls
--

typeModifiersP :: Parser String
typeModifiersP = do
  ls <- option0 [] $ spacesP \|/ suspendModifierP <|> annotationsP
  return $ join ls
--

classModifierP :: Parser String
classModifierP = reservedLP "abstract"
  <|> reservedLP "final"
  <|> reservedLP "enum"
  <|> "open" ->> []
  <|> reservedLP "annotation"
  <|> "sealed" ->> "abstract"
  <|> "data" ->> []
--

memberModifierP :: Parser String
memberModifierP = reservedLP "final"
  <|> reservedLP "abstract"
  <|> "open" ->> []
  <|> "lateinit" ->> []
  <|> "override" ->> "@override"
--

accessModifierP :: Parser String
accessModifierP = reservedLP "public"
  <|> reservedLP "private"
  <|> reservedLP "protected"
  <|> "internal" ->> []
--

varianceAnnotationP :: Parser String
varianceAnnotationP = reservedLP "in" <|> reservedLP "out"

parameterModifierP :: Parser String
parameterModifierP = flip convertParserP [] $ reservedLP "noinline"
  <|> reservedLP "crossinline"
  <|> reservedLP "vararg"
--

typeParameterModifierP :: Parser String
typeParameterModifierP = reservedP "reified"

functionModifierP :: Parser String
functionModifierP = "tailrec" ->> []
  <|> reservedP "operator"
  <|> "infix" ->> []
  <|> reservedP "inline"
  <|> "external" ->> "/* This is a JNI function */"
  <|> suspendModifierP
--

propertyModifierP :: Parser String
propertyModifierP = reservedP "const"

suspendModifierP :: Parser String
suspendModifierP = reservedP "suspend"<commit_msg>update-modifiers<commit_after>{-# LANGUAGE ApplicativeDo #-}

module Modifiers where

import Control.Applicative
import Control.Monad

import Parsers
import Annotations

modifierP :: Parser String
modifierP = foldr1 (<|>) $ ms
  where
    ms = [ classModifierP
         , accessModifierP
         , varianceAnnotationP
         , memberModifierP
         , parameterModifierP
         , typeParameterModifierP
         , functionModifierP
         , propertyModifierP
         ]
--

modifiersP :: Parser String
modifiersP = do
  ls <- option0 [] $ spacesP \|/ modifierP <|> annotationsP
  return $ join ls
--

typeModifiersP :: Parser String
typeModifiersP = do
  ls <- option0 [] $ spacesP \|/ suspendModifierP <|> annotationsP
  return $ join ls
--

classModifierP :: Parser String
classModifierP = reservedWordsLP w
  <|> "sealed" ->> "abstract"
  <|> "data" ->> []
  <|> "open" ->> []
  where
    w =  [ "abstract"
         , "final"
         ,"enum"
         , "annotation"
         ]
--

memberModifierP :: Parser String
memberModifierP = reservedWordsLP w 
  <|> "open" ->> []
  <|> "lateinit" ->> []
  <|> "override" ->> "@override"
  where
    w = [ "final"
        , "abstract"
        ]
--

accessModifierP :: Parser String
accessModifierP = reservedLP "public"
  <|> reservedLP "private"
  <|> reservedLP "protected"
  <|> "internal" ->> []
--

varianceAnnotationP :: Parser String
varianceAnnotationP = reservedWordsLP [ "in", "out" ]

parameterModifierP :: Parser String
parameterModifierP = flip convertParserP [] $ reservedWordsLP w
  where
    w = [ "noinline"
        , "crossinline"
        , "vararg"
        ]
--

typeParameterModifierP :: Parser String
typeParameterModifierP = reservedLP "reified"

functionModifierP :: Parser String
functionModifierP = "tailrec" ->> []
  <|> reservedLP "operator"
  <|> "infix" ->> []
  <|> reservedLP "inline"
  <|> "external" ->> "/* This is a JNI function */"
  <|> suspendModifierP
--

propertyModifierP :: Parser String
propertyModifierP = reservedLP "const"

suspendModifierP :: Parser String
suspendModifierP = reservedLP "suspend"
{'fraction_non_alphanumeric': 0.14041604754829123, 'fraction_numerical': 0.0012382367508667657, 'mean_word_length': 3.6002277904328017, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 90, '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': '459931', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1311, 'n_words': 297}