mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] Embedded stdlib.tolk, CompilerState, strict includes
Several related changes: - stdlib.tolk is embedded into a distribution (deb package or tolk-js), the user won't have to download it and store as a project file; it's an important step to maintain correct language versioning - stdlib.tolk is auto-included, that's why all its functions are available out of the box - strict includes: you can't use symbol `f` from another file unless you've #include'd this file - drop all C++ global variables holding compilation state, merge them into a single struct CompilerState located at compiler-state.h; for instance, stdlib filename is also there
This commit is contained in:
parent
f0e6470d0b
commit
6c30e5a7eb
21 changed files with 604 additions and 506 deletions
|
@ -15,6 +15,7 @@
|
|||
along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "lexer.h"
|
||||
#include "compiler-state.h"
|
||||
#include "symtable.h"
|
||||
#include <cassert>
|
||||
|
||||
|
@ -426,7 +427,7 @@ struct ChunkIdentifierOrKeyword final : ChunkLexerBase {
|
|||
if (TokenType kw_tok = maybe_keyword(str_val)) {
|
||||
lex->add_token(kw_tok, str_val);
|
||||
} else {
|
||||
symbols.lookup_add(static_cast<std::string>(str_val));
|
||||
G.symbols.lookup_add(static_cast<std::string>(str_val));
|
||||
lex->add_token(tok_identifier, str_val);
|
||||
}
|
||||
return true;
|
||||
|
@ -452,7 +453,7 @@ struct ChunkIdentifierInBackticks final : ChunkLexerBase {
|
|||
|
||||
std::string_view str_val(str_begin + 1, lex->c_str() - str_begin - 1);
|
||||
lex->skip_chars(1);
|
||||
symbols.lookup_add(static_cast<std::string>(str_val));
|
||||
G.symbols.lookup_add(static_cast<std::string>(str_val));
|
||||
lex->add_token(tok_identifier, str_val);
|
||||
return true;
|
||||
}
|
||||
|
@ -611,7 +612,7 @@ void Lexer::next_special(TokenType parse_next_as, const char* str_expected) {
|
|||
|
||||
int Lexer::cur_sym_idx() const {
|
||||
assert(tok() == tok_identifier);
|
||||
return symbols.lookup_add(cur_str_std_string());
|
||||
return G.symbols.lookup_add(cur_str_std_string());
|
||||
}
|
||||
|
||||
void Lexer::error(const std::string& err_msg) const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue