<commit_before>module Javelin.ByteCode.DescSign
where

import Javelin.ByteCode.Data
  
import Text.ParserCombinators.Parsec.Prim
import Text.ParserCombinators.Parsec.Char
import Text.Parsec.Error
import Control.Applicative ((<$), (<$>), (<*), (<*>), (*>))
import Text.ParserCombinators.Parsec.Combinator (endBy, sepBy)

parseFieldType = parse fieldTypeP ""
parseBaseType = parse baseTypeP ""
parseFieldDescriptor = parse fieldDescriptorP ""
parseMethodDescriptor = parse methodDescriptorP ""
parseMethodTypeSignature = parse methodTypeSignatureP ""
parseClassSignature = parse classSignatureP ""

-- Fundamental definitions
type StringParser a = CharParser () a

unqualifiedNameP :: StringParser UnqualifiedName
unqualifiedNameP = undefined
qualifiedNameP = endBy classPartsP (char ';')
classPartsP = sepBy anyChar (char '/')

fieldTypeP = BaseType <$> baseTypeP
             <|> ObjectType <$> (char 'L' *> qualifiedNameP <* char ';')
             <|> ArrayType <$> fieldTypeP <* char '['
             <?> "FieldType"

baseTypeP :: StringParser BaseType
baseTypeP = ByteT <$ char 'B'
            <|> CharT <$ char 'C'
            <|> DoubleT <$ char 'D'
            <|> FloatT <$ char 'F'
            <|> IntT <$ char 'I'
            <|> LongT <$ char 'J'
            <|> ShortT <$ char 'S'
            <|> BooleanT <$ char 'Z'
            <?> "BaseType"
            
-- FieldDescriptor
fieldDescriptorP = FieldDescriptor <$> fieldTypeP

-- MethodDescriptor
methodDescriptorP = MethodDescriptor <$> many fieldTypeP <*> returnDescriptorP
returnDescriptorP = FieldTypeDescriptor <$> fieldTypeP
                    <|> VoidDescriptor <$ voidDescriptorP
                    <?> "ReturnDescriptor"
voidDescriptorP = char 'v'

-- ClassSignature<commit_msg>Signatures names<commit_after>module Javelin.ByteCode.DescSign
where

import Javelin.ByteCode.Data
  
import Text.ParserCombinators.Parsec.Prim
import Text.ParserCombinators.Parsec.Char
import Text.Parsec.Error
import Control.Applicative ((<$), (<$>), (<*), (<*>), (*>))
import Text.ParserCombinators.Parsec.Combinator (endBy, sepBy)

parseFieldType = parse fieldTypeP ""
parseBaseType = parse baseTypeP ""
parseFieldDescriptor = parse fieldDescriptorP ""
parseMethodDescriptor = parse methodDescriptorP ""
parseMethodTypeSignature = parse methodTypeSignatureP ""
parseClassSignature = parse classSignatureP ""

-- Fundamental definitions
type StringParser a = CharParser () a

unqualifiedNameP :: StringParser UnqualifiedName
nameSymbol = (noneOf ".;[/")
unqualifiedNameP = many nameSymbol
qualifiedNameP = endBy classPartsP (char ';')
classPartsP = sepBy nameSymbol (char '/')

fieldTypeP = BaseType <$> baseTypeP
             <|> ObjectType <$> (char 'L' *> qualifiedNameP <* char ';')
             <|> ArrayType <$> fieldTypeP <* char '['
             <?> "FieldType"

baseTypeP :: StringParser BaseType
baseTypeP = ByteT <$ char 'B'
            <|> CharT <$ char 'C'
            <|> DoubleT <$ char 'D'
            <|> FloatT <$ char 'F'
            <|> IntT <$ char 'I'
            <|> LongT <$ char 'J'
            <|> ShortT <$ char 'S'
            <|> BooleanT <$ char 'Z'
            <?> "BaseType"
            
-- FieldDescriptor
fieldDescriptorP = FieldDescriptor <$> fieldTypeP

-- MethodDescriptor
methodDescriptorP = MethodDescriptor <$> many fieldTypeP <*> returnDescriptorP
returnDescriptorP = FieldTypeDescriptor <$> fieldTypeP
                    <|> VoidDescriptor <$ voidDescriptorP
                    <?> "ReturnDescriptor"
voidDescriptorP = char 'v'

-- ClassSignature
{'fraction_non_alphanumeric': 0.12672876093705898, 'fraction_numerical': 0.0, 'mean_word_length': 3.2853688029020556, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 51, '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': '647125', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1027, 'n_words': 235}