mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
[Tolk] Implement AST: intermediate representation of tolk files
Now, the whole .tolk file can be loaded as AST tree and then converted to Expr/Op. This gives a great ability to implement AST transformations. In the future, more and more code analysis will be moved out of legacy to AST-level.
This commit is contained in:
parent
6c30e5a7eb
commit
80001d1756
23 changed files with 3798 additions and 2233 deletions
|
@ -27,7 +27,8 @@
|
|||
#include "compiler-state.h"
|
||||
#include "lexer.h"
|
||||
#include <getopt.h>
|
||||
#include "git.h"
|
||||
#include "ast-from-tokens.h"
|
||||
#include "ast-to-legacy.h"
|
||||
#include <fstream>
|
||||
#include "td/utils/port/path.h"
|
||||
#include <sys/stat.h>
|
||||
|
@ -269,13 +270,13 @@ int tolk_proceed(const std::string &entrypoint_file_name) {
|
|||
if (locate_res.is_error()) {
|
||||
throw Fatal("Failed to locate stdlib: " + locate_res.error().message().str());
|
||||
}
|
||||
parse_source_file(locate_res.move_as_ok());
|
||||
process_file_ast(parse_src_file_to_ast(locate_res.move_as_ok()));
|
||||
}
|
||||
td::Result<SrcFile*> locate_res = locate_source_file(entrypoint_file_name);
|
||||
if (locate_res.is_error()) {
|
||||
throw Fatal("Failed to locate " + entrypoint_file_name + ": " + locate_res.error().message().str());
|
||||
}
|
||||
parse_source_file(locate_res.move_as_ok());
|
||||
process_file_ast(parse_src_file_to_ast(locate_res.move_as_ok()));
|
||||
|
||||
// todo #ifdef TOLK_PROFILING + comment
|
||||
// lexer_measure_performance(all_src_files.get_all_files());
|
||||
|
@ -293,6 +294,10 @@ int tolk_proceed(const std::string &entrypoint_file_name) {
|
|||
unif_err.print_message(std::cerr);
|
||||
std::cerr << std::endl;
|
||||
return 2;
|
||||
} catch (UnexpectedASTNodeType& error) {
|
||||
std::cerr << "fatal: " << error.what() << std::endl;
|
||||
std::cerr << "It's a compiler bug, please report to developers" << std::endl;
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue