4
Copyright (c) 2022 МГТУ им. Н.Э. Баумана, кафедра ИУ-6, Михаил Фетисов,
6
https://bmstu.codes/lsx/simodo/loom
9
#include "simodo/interpret/builtins/hosts/fuze/FuzeAnalyzer.h"
10
#include "simodo/interpret/AnalyzeException.h"
12
#include "simodo/inout/convert/functions.h"
14
// inline const u16string EXCEEDED = u"The number of errors has exceeded the allowable limit";
18
simodo::interpret::SemanticDataCollector_null null_semantic_collector;
21
namespace simodo::interpret::builtins
24
FuzeAnalyzer::FuzeAnalyzer(Interpret * inter,
25
std::string grammar_name,
26
parser::Grammar & grammar,
27
parser::TableBuildMethod method,
28
bool need_strict_rule_consistency)
29
: FuzeInterpret_abstract(inter, grammar_name, grammar, method, need_strict_rule_consistency)
30
, _collector(null_semantic_collector)
34
FuzeAnalyzer::FuzeAnalyzer(Interpret * inter,
35
SemanticDataCollector_interface & collector,
36
std::string grammar_name,
37
parser::Grammar & grammar,
38
parser::TableBuildMethod method,
39
bool need_strict_rule_consistency)
40
: FuzeInterpret_abstract(inter, grammar_name, grammar, method, need_strict_rule_consistency)
41
, _collector(collector)
45
InterpretState FuzeAnalyzer::executeGlobalScript(const inout::Token & label, const ast::Node & script)
47
InterpretState state = FuzeInterpret_abstract::executeGlobalScript(label, script);
49
_collector.collectNameDeclared({label.lexeme(), {variable::ValueType::Function, variable::Object {{
50
{u"@", variable::InternalFunction {&script, {}}},
51
{{}, variable::ValueType::Null},
52
}}}, label.location()});
57
InterpretState FuzeAnalyzer::executeProduction(const inout::Token & production,
58
const std::vector<inout::Token> & pattern,
59
const inout::Token & direction_token,
60
const ast::Node & action)
62
InterpretState state = FuzeInterpret_abstract::executeProduction(production, pattern, direction_token, action);
64
_productions.insert({production.lexeme(),{production, pattern}});
65
_directions.push_back(direction_token);
70
InterpretState FuzeAnalyzer::executeRef(const inout::Token & token, const std::u16string & ref)
72
_collector.collectRef(token, ref);
73
return FuzeInterpret_abstract::executeRef(token, ref);