<commit_before>%require "3.0.4"
%skeleton "lalr1.cc"

%debug
%define api.namespace {myparser}

%code requires{
class MyLexer;

#include "MyAst.h"

#include "Expr.h"
#include "AssignExpr.h"
#include "IdExpr.h"
#include "NumExpr.h"

#include "FuncType.h"
#include "DefineType.h"
#include "ArgType.h"
#include "Import.h"
}

%{

#include <iostream>

using namespace std;

void yyerror(const char* );

%}

%union{
    int num;
    std::string* str;
    char chr;
    Expr* expr_type;
    FuncType* func_type;
    DefineType* define_type;
    ArgType* arg_type;
    Import* import_type;
}

%destructor { delete $$; } <str> <import_type> <expr_type> // <define_type>  <func_type> <arg_type>

%code{
int yylex(myparser::parser::semantic_type* , MyLexer&);
}

%token <num> NUM
%token <str> ID
%token EOL
%token ASSIGN "="

%token LPAREN "("
%token RPAREN ")"
%token COMMA ","

%token IMPORT "import"
%token PRINT
%token FUN
%token END

%type <expr_type> expr
// %type <func_type> func
// %type <define_type> define
// %type <arg_type> arg
%type <import_type> import

%param{ 
    MyLexer& myLexer
};

%parse-param { MyAst* myAst };

%initial-action
{
    // Initial code
};

%%

%start root;

root
    : %empty 
    | import root { myAst->importLibrary($1); }
    | expr root
    ;

import
    : "import" ID EOL { $$ = new Import(*$2); }<commit_msg>токены<commit_after>%require "3.0.4"
%skeleton "lalr1.cc"

%debug
%define api.namespace {myparser}

%code requires{
class MyLexer;

#include "MyAst.h"

#include "Expr.h"
#include "AssignExpr.h"
#include "IdExpr.h"
#include "NumExpr.h"

#include "FuncType.h"
#include "DefineType.h"
#include "ArgType.h"
#include "Import.h"
}

%{

#include <iostream>

using namespace std;

void yyerror(const char* );

%}

%union{
    int num;
    std::string* str;
    char chr;
    Expr* expr_type;
    FuncType* func_type;
    DefineType* define_type;
    ArgType* arg_type;
    Import* import_type;
}

%destructor { delete $$; } <str> <import_type> <expr_type> // <define_type>  <func_type> <arg_type>

%code{
int yylex(myparser::parser::semantic_type* , MyLexer&);
}

%token <num> NUM
%token <str> ID
%token EOL
%token ASSIGN "="

%token LPAREN "("
%token RPAREN ")"
%token COMMA ","

%token IMPORT "import"
%token PRINT "print"
%token FUN "fun"
%token END "end"

%type <expr_type> expr
// %type <func_type> func
// %type <define_type> define
// %type <arg_type> arg
%type <import_type> import

%param{ 
    MyLexer& myLexer
};

%parse-param { MyAst* myAst };

%initial-action
{
    // Initial code
};

%%

%start root;

root
    : %empty 
    | import root { myAst->importLibrary($1); }
    | expr root
    ;

import
    : "import" ID EOL { $$ = new Import(*$2); }
{'fraction_non_alphanumeric': 0.16487189008540662, 'fraction_numerical': 0.004455997029335313, 'mean_word_length': 3.793594306049822, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, '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': '4296763', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1084, 'n_words': 265}