<commit_before>/* Ocamlyacc parser for MicroC */

%{
open Ast
%}

%token SEMI LPAREN RPAREN LBRACE RBRACE COMMA
%token PLUS MINUS TIMES DIVIDE ASSIGN NOT
%token EQ NEQ LT LEQ GT GEQ TRUE FALSE AND OR
%token RETURN RETURNS IF ELSE FOR WHILE INT FLOAT BOOL VOID STRING
%token <int> LITERAL
%token <float> FLOATLIT
%token <string> STRINGLIT
%token <string> ID
%token FUNCTION
%token EOF

%nonassoc NOELSE
%nonassoc ELSE
%right ASSIGN
%left OR
%left AND
%left EQ NEQ
%left LT GT LEQ GEQ
%left PLUS MINUS
%left TIMES DIVIDE
%right NOT NEG

%start program
%type <Ast.program> program

%%

program:
  fdecl stmts EOF { $1, $2 }

fdecls:
    /* nothing */       { [] }
  | fdecl_list          { List.rev $1 }

fdecl_list:
    fdecl               { [$1] }
  | fdecl_list fdecl    { $2 :: $1 }

stmts:
    /* nothing */       { [] }
  | stmt_list           { List.rev $1 }

stmt_list:
    stmt                { [$1] }
  | stmt_list stmt      { $2 :: $1 }

fdecl:
    FUNCTION ID LPAREN formals_opt RPAREN RETURNS typ LBRACE stmt_list RBRACE
    { {
        fname = $2;
        formals = $4;
        ftyp = $7;
        body = List.rev $9;
    } }

formals_opt:
    /* nothing */ { [] }
  | formal_list   { List.rev $1 }

formal_list:
    typ ID                   { [($1,$2)] }
  | formal_list COMMA typ ID { ($3,$4) :: $1 }

typ:
    INT { Int }
  | FLOAT { Float }
  | BOOL { Bool }
  | VOID { Void }
  | STRING { String }

var_decl:<commit_msg>fdecl list add<commit_after>/* Ocamlyacc parser for MicroC */

%{
open Ast
%}

%token SEMI LPAREN RPAREN LBRACE RBRACE COMMA
%token PLUS MINUS TIMES DIVIDE ASSIGN NOT
%token EQ NEQ LT LEQ GT GEQ TRUE FALSE AND OR
%token RETURN RETURNS IF ELSE FOR WHILE INT FLOAT BOOL VOID STRING
%token <int> LITERAL
%token <float> FLOATLIT
%token <string> STRINGLIT
%token <string> ID
%token FUNCTION
%token EOF

%nonassoc NOELSE
%nonassoc ELSE
%right ASSIGN
%left OR
%left AND
%left EQ NEQ
%left LT GT LEQ GEQ
%left PLUS MINUS
%left TIMES DIVIDE
%right NOT NEG

%start program
%type <Ast.program> program

%%

program:
  fdecl stmts EOF { $1, $2 }

fdecls:
                        { [] }
  | fdecl_list          { List.rev $1 }

fdecl_list:
    fdecl               { [$1] }
  | fdecl_list fdecl    { $2 :: $1 }

stmts:
                        { [] }
  | stmt_list           { List.rev $1 }

stmt_list:
    stmt                { [$1] }
  | stmt_list stmt      { $2 :: $1 }

fdecl:
    FUNCTION ID LPAREN formals_opt RPAREN RETURNS typ LBRACE stmt_list RBRACE
    { {
        fname = $2;
        formals = $4;
        ftyp = $7;
        body = List.rev $9;
    } }

formals_opt:
    /* nothing */ { [] }
  | formal_list   { List.rev $1 }

formal_list:
    typ ID                   { [($1,$2)] }
  | formal_list COMMA typ ID { ($3,$4) :: $1 }

typ:
    INT { Int }
  | FLOAT { Float }
  | BOOL { Bool }
  | VOID { Void }
  | STRING { String }

var_decl:
{'fraction_non_alphanumeric': 0.11912225705329153, 'fraction_numerical': 0.013932427725531174, 'mean_word_length': 2.1319520174482007, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5678917', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1123, 'n_words': 337}