mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-25 14:00:18 +00:00
some refactor
This commit is contained in:
parent
51a3c93f69
commit
90a9a404e2
@ -25,7 +25,6 @@ class Compiler {
|
||||
stack_no_copy<CodeEmitContext> contexts;
|
||||
VM* vm;
|
||||
bool unknown_global_scope; // for eval/exec() call
|
||||
bool used;
|
||||
// for parsing token stream
|
||||
int i = 0;
|
||||
std::vector<Token> tokens;
|
||||
|
||||
@ -106,7 +106,6 @@ struct Lexer {
|
||||
std::vector<Token> nexts;
|
||||
stack_no_copy<int, small_vector_no_copy_and_move<int, 8>> indents;
|
||||
int brackets_level = 0;
|
||||
bool used = false;
|
||||
|
||||
char peekchar() const{ return *curr_char; }
|
||||
bool match_n_chars(int n, char c0);
|
||||
|
||||
@ -1196,15 +1196,13 @@ __EAT_DOTS_END:
|
||||
Compiler::Compiler(VM* vm, std::string_view source, const Str& filename, CompileMode mode, bool unknown_global_scope)
|
||||
:lexer(vm, std::make_shared<SourceData>(source, filename, mode)){
|
||||
this->vm = vm;
|
||||
this->used = false;
|
||||
this->unknown_global_scope = unknown_global_scope;
|
||||
init_pratt_rules();
|
||||
}
|
||||
|
||||
|
||||
CodeObject_ Compiler::compile(){
|
||||
PK_ASSERT(!used)
|
||||
used = true;
|
||||
PK_ASSERT(i == 0) // make sure it is the first time to compile
|
||||
|
||||
tokens = lexer.run();
|
||||
CodeObject_ code = push_global_context();
|
||||
|
||||
@ -472,8 +472,6 @@ static bool is_unicode_Lo_char(uint32_t c) {
|
||||
}
|
||||
|
||||
std::vector<Token> Lexer::run() {
|
||||
PK_ASSERT(!used)
|
||||
used = true;
|
||||
while (lex_one_token());
|
||||
return std::move(nexts);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user