wip: working on analyzer
This commit is contained in:
+34
-1
@@ -1,4 +1,5 @@
|
||||
#include <common/fzl_colors.h>
|
||||
#include <compiler/fzl_analyzer.h>
|
||||
#include <compiler/fzl_debug.h>
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/fzl_reader.h>
|
||||
@@ -122,7 +123,39 @@ int main(int argc, char **argv)
|
||||
printf("%sok%s!\n", FZL_COK, FZL_CRST);
|
||||
fzl_debug_print_ast(parser->root);
|
||||
printf("%s> building%s\n", FZL_CDEBUG, FZL_CRST);
|
||||
printf("%s-> walking AST...%s\n", FZL_CDEBUG, FZL_CRST);
|
||||
printf("%s-> analyzing AST...%s\n", FZL_CDEBUG, FZL_CRST);
|
||||
}
|
||||
|
||||
fzl_analyzer_t *analyzer = fzl_mkanalyzer(parser->root);
|
||||
if (!analyzer)
|
||||
{
|
||||
printf("%sError%s: failed to allocate analyzer\n", FZL_CERROR, FZL_CRST);
|
||||
fzl_freeoptions(opts);
|
||||
fzl_freeast(parser->root);
|
||||
fzl_freeparser(parser);
|
||||
fzl_freereader(rd);
|
||||
fzl_freelinked(linked);
|
||||
}
|
||||
|
||||
fzl_analyze(analyzer);
|
||||
if (analyzer->errors_top > 0)
|
||||
{
|
||||
for (ssize_t i = analyzer->errors_top - 1; i >= 0; i--)
|
||||
printf("%sError%s: %s\n", FZL_CERROR, FZL_CRST, analyzer->errors[i]);
|
||||
|
||||
fzl_freeoptions(opts);
|
||||
fzl_freeanalyzer(analyzer);
|
||||
fzl_freeast(parser->root);
|
||||
fzl_freeparser(parser);
|
||||
fzl_freereader(rd);
|
||||
fzl_freelinked(linked);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (analyzer->warnings_top > 0)
|
||||
{
|
||||
for (ssize_t i = analyzer->warnings_top - 1; i >= 0; i--)
|
||||
printf("%sWarning%s: %s\n", FZL_CERROR, FZL_CRST, analyzer->warnings[i]);
|
||||
}
|
||||
|
||||
fzl_walker_t *walker = fzl_mkwalker(parser->root);
|
||||
|
||||
Reference in New Issue
Block a user