diff --git a/docs/features/precompile.md b/docs/features/precompile.md index 5c49e01d..629275bc 100644 --- a/docs/features/precompile.md +++ b/docs/features/precompile.md @@ -46,16 +46,17 @@ print(code) ``` ```txt -pkpy:1.4.4 +pkpy:1.4.5 0 -|print| +=1 +print =6 5,1,0, -6,1,5,1,0, -42,1,1, -8,1,1,S48656c6c6f2c20776f726c6421 -43,1,0, -3,1,0, +6,0,,, +42,,1, +8,,,S48656c6c6f2c20776f726c6421 +43,,0, +3,,, ``` diff --git a/include/pocketpy/compiler.h b/include/pocketpy/compiler.h index 2e630b75..4cbbba6b 100644 --- a/include/pocketpy/compiler.h +++ b/include/pocketpy/compiler.h @@ -132,7 +132,7 @@ struct TokenDeserializer{ TokenDeserializer(const char* source): curr(source), source(source) {} char read_char(){ return *curr++; } - char peek_char(){ return *curr; } + bool match_char(char c){ if(*curr == c) { curr++; return true; } return false; } std::string_view read_string(char c); Str read_string_from_hex(char c); diff --git a/src/compiler.cpp b/src/compiler.cpp index 146d34fb..ecf1be49 100644 --- a/src/compiler.cpp +++ b/src/compiler.cpp @@ -1252,13 +1252,10 @@ __EAT_DOTS_END: if(is_raw_string_used(token.type)){ ss << token_indices[token.sv()] << ','; } - if(i>0 && tokens[i-1].line == token.line) ss << ','; else ss << token.line << ','; - if(i>0 && tokens[i-1].brackets_level == token.brackets_level) ss << ','; else ss << token.brackets_level << ','; - // visit token value std::visit([&ss](auto&& arg){ using T = std::decay_t; @@ -1306,13 +1303,13 @@ __EAT_DOTS_END: t.length = 0; } - if(deserializer.peek_char() == ','){ + if(deserializer.match_char(',')){ t.line = tokens.back().line; }else{ t.line = (int)deserializer.read_uint(','); } - if(deserializer.peek_char() == ','){ + if(deserializer.match_char(',')){ t.brackets_level = tokens.back().brackets_level; }else{ t.brackets_level = (int)deserializer.read_uint(','); diff --git a/src/io.cpp b/src/io.cpp index 75693270..069686cc 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -176,7 +176,7 @@ void add_module_os(VM* vm){ std::filesystem::directory_iterator di; try{ di = std::filesystem::directory_iterator(path); - }catch(std::filesystem::filesystem_error& e){ + }catch(std::filesystem::filesystem_error&){ vm->IOError(path.string()); } List ret;