<commit_before>%define api.prefix {gdb}
%locations

%{
	#include <common/log.h>
	#include <gdb/gdb.h>
	#include <gdb/value.h>
	#include <gdb/result.h>
	#include <gdb/variable.h>
	#include <gdb/lexer.lex.h>


	int gdberror(gdbif* gdb, const char* s);
%}

%union{
	char* sptr;
	unsigned int num;

	result_t* result;
	value_t* value;
	result_class_t rclass;
	variable_t variable;

	struct{
		result_class_t rclass;
		result_t* result;
	} record;
}


%parse-param { gdbif* gdb }

%initial-action
{
	xxxx:;
}

/* terminals */
%token NEWLINE
%token GDB
%token <rclass> RESULT_CLASS
%token <sptr> STRING
%token <num> NUMBER
%token <variable> VARIABLE

/* non-terminals */
%type <record> record
%type <result> result
%type <result> result-list
%type <value> value
%type <value> value-list
%type <value> const
%type <value> tuple
%type <value> list
%type <num> token


%%


output :	out-of-band-record GDB NEWLINE			{ DEBUG("gdb parser: reduced to output\n"); };
<commit_msg>[gdb: parser cleanup]<commit_after>%define api.prefix {gdb}
%locations

%{
	#include <common/log.h>
	#include <gdb/gdb.h>
	#include <gdb/value.h>
	#include <gdb/result.h>
	#include <gdb/variable.h>
	#include <gdb/lexer.lex.h>


	int gdberror(gdbif* gdb, const char* s);
%}

%union{
	char* sptr;
	unsigned int num;

	result_t* result;
	value_t* value;
	result_class_t rclass;
	variable_t variable;

	struct{
		result_class_t rclass;
		result_t* result;
	} record;
}


%parse-param { gdbif* gdb }


/* terminals */
%token NEWLINE
%token GDB
%token <rclass> RESULT_CLASS
%token <sptr> STRING
%token <num> NUMBER
%token <variable> VARIABLE

/* non-terminals */
%type <record> record
%type <result> result
%type <result> result-list
%type <value> value
%type <value> value-list
%type <value> const
%type <value> tuple
%type <value> list
%type <num> token


%%


output :	out-of-band-record GDB NEWLINE			{ DEBUG("gdb parser: reduced to output\n"); };

{'fraction_non_alphanumeric': 0.15115062761506276, 'fraction_numerical': 0.0, 'mean_word_length': 4.328690807799443, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '1243787', 'n_tokens_mistral': 805, 'n_tokens_neox': 777, 'n_words': 202}