<commit_before>open Batteries;;

(*let string_of_declaration = Grammar_j.string_of_declaration;;*)

exception ParserError of string;;

type sym =
    Svar
  | Sfield
  | Sarg
  | Sstat
  ;;

let scope2sym s = 
    match s with
    | `FIELD -> Sfield
    | `STATIC -> Sstat
    | _ -> raise (Failure "bad scope")

class symbol_table () =
    object (s)
        val classt = BatHashtbl.create 50
        val mutable subt = BatHashtbl.create 0

        method start_subroutine () =
            subt <- BatHashtbl.create 50;

        method define (name:Grammar.identifier) (typ:Grammar.var_type) (kind:Grammar.var_scope) =
            match kind with
            | `FIELD | `STATIC -> BatHashtbl.add classt name (typ, kind, (BatHashtbl.length classt) + 1)
            | `ARG | `VAR -> BatHashtbl.add subt name (typ, kind, (BatHashtbl.length subt) + 1)
        method var_count (kind:Grammar.var_scope) : int =
            let ht_enum =
                if kind = `FIELD || kind = `STATIC then
                    BatHashtbl.enum classt
                else
                    BatHashtbl.enum subt
            in
            let count_types (c, kind) ((_: Grammar.var_type), (v: (Grammar.identifier * Grammar.var_scope * int))) =<commit_msg>Fixed order of types in count_types signature.<commit_after>open Batteries;;

(*let string_of_declaration = Grammar_j.string_of_declaration;;*)

exception ParserError of string;;

type sym =
    Svar
  | Sfield
  | Sarg
  | Sstat
  ;;

let scope2sym s = 
    match s with
    | `FIELD -> Sfield
    | `STATIC -> Sstat
    | _ -> raise (Failure "bad scope")

class symbol_table () =
    object (s)
        val classt = BatHashtbl.create 50
        val mutable subt = BatHashtbl.create 0

        method start_subroutine () =
            subt <- BatHashtbl.create 50;

        method define (name:Grammar.identifier) (typ:Grammar.var_type) (kind:Grammar.var_scope) =
            match kind with
            | `FIELD | `STATIC -> BatHashtbl.add classt name (typ, kind, (BatHashtbl.length classt) + 1)
            | `ARG | `VAR -> BatHashtbl.add subt name (typ, kind, (BatHashtbl.length subt) + 1)
        method var_count (kind:Grammar.var_scope) : int =
            let ht_enum =
                if kind = `FIELD || kind = `STATIC then
                    BatHashtbl.enum classt
                else
                    BatHashtbl.enum subt
            in
            let count_types (c, kind) ((_: Grammar.identifier), (v: (Grammar.var_type * Grammar.var_scope * int))) =
{'fraction_non_alphanumeric': 0.10490626246509772, 'fraction_numerical': 0.006382130035899481, 'mean_word_length': 2.103960396039604, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '208229', 'n_tokens_mistral': 851, 'n_tokens_neox': 806, 'n_words': 210}