<commit_before>%{

#include <stdio.h>
#include <stdlib.h>

extern int yylex();
extern int yyparse();
extern FILE* yyin;

void yyerror(const char* s);

%}

%union {
  int ival;
  char* sval;
  int bval;
}



%token<ival> T_INT
%token<sval> T_ID

%token T_AMPERSAND
%token T_LBRACE T_RBRACE
%token T_LPAREN T_RPAREN
%token T_PIPE T_COLON T_QUESTION T_AFTERCOND
%token T_PLUS T_MINUS T_MULTIPLY T_DIVIDE
%token T_NEWLINE T_QUIT
%token T_RELOP
%left T_PLUS T_MINUS
%left T_MULTIPLY T_DIVIDE

%type<ival> expr
%type<ival> factor
%type<ival> term
%type<bval> condexpr

%start stmts

%%

stmts   : line stmts
	| /* e */    
        ;
line    : stmt T_NEWLINE
	;
stmt	: assn 
        | cond
        | print        
        ;
print   : T_AMPERSAND T_ID            { printf("print %s\n",$2); }
	;
assn    : T_LBRACE expr T_RBRACE T_PIPE T_COLON T_ID   { printf("store %d in %s\n",$2,$6); }
	;
cond    : T_LPAREN condexpr T_RPAREN T_QUESTION T_QUESTION T_LPAREN stmt T_RPAREN T_AFTERCOND { printf("conditional stmt\n"); }
	;
condexpr : T_ID T_RELOP T_ID    { }
	 | T_ID T_RELOP T_INT   { }
         | T_INT T_RELOP T_ID   { }
         ;
expr	: expr '+' term		{ $$ = $1 + $3; }
     	| term
	;
term	: term '*' factor 	{ $$ = $1 * $3; }
     	| factor
	;
factor	: T_LPAREN expr T_RPAREN		{ printf("factor\n"); $$ = $2; }
       	| T_INT
	;
%%

extern int yy_flex_debug;
int main() {
        yy_flex_debug = 0;
	yyin = stdin;

	do { 
		yyparse();
	} while(!feof(yyin));
	return 0;
}

void yyerror(const char* s) {
	fprintf(stderr, "Parse error: %s\n", s);
	exit(1);
}<commit_msg>Create boolexpr<commit_after>%{

#include <stdio.h>
#include <stdlib.h>

extern int yylex();
extern int yyparse();
extern FILE* yyin;

void yyerror(const char* s);

%}

%union {
  int ival;
  char* sval;
  int bval;
}



%token<ival> T_INT
%token<sval> T_ID

%token T_AMPERSAND
%token T_LBRACE T_RBRACE
%token T_LPAREN T_RPAREN
%token T_PIPE T_COLON T_QUESTION T_AFTERCOND
%token T_PLUS T_MINUS T_MULTIPLY T_DIVIDE
%token T_NEWLINE T_QUIT
%token T_RELOP
%left T_PLUS T_MINUS
%left T_MULTIPLY T_DIVIDE

%type<ival> expr
%type<ival> factor
%type<ival> term
%type<bval> boolexpr

%start stmts

%%

stmts   : line stmts
	| /* e */    
        ;
line    : stmt T_NEWLINE
	;
stmt	: assn 
        | cond
        | print        
        ;
print   : T_AMPERSAND T_ID            { printf("print %s\n",$2); }
	;
assn    : T_LBRACE expr T_RBRACE T_PIPE T_COLON T_ID   { printf("store %d in %s\n",$2,$6); }
	;
cond    : T_LPAREN boolexpr T_RPAREN T_QUESTION T_QUESTION T_LPAREN stmt T_RPAREN T_AFTERCOND { printf("conditional stmt\n"); }
	;

boolexpr : expr T_RELOP expr { }
         ;

expr	: expr '+' term		{ $$ = $1 + $3; }
     	| term
	;
term	: term '*' factor 	{ $$ = $1 * $3; }
     	| factor
	;
factor	: T_LPAREN expr T_RPAREN		{ printf("factor\n"); $$ = $2; }
       	| T_INT
       	| T_ID
	;
%%

extern int yy_flex_debug;
int main() {
        yy_flex_debug = 0;
	yyin = stdin;

	do { 
		yyparse();
	} while(!feof(yyin));
	return 0;
}

void yyerror(const char* s) {
	fprintf(stderr, "Parse error: %s\n", s);
	exit(1);
}
{'fraction_non_alphanumeric': 0.13664394677052905, 'fraction_numerical': 0.007140538786108407, 'mean_word_length': 2.862155388471178, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '4830358', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1393, 'n_words': 316}