From 46716620e3c6db7cbeb065405f256055e3bd0b16 Mon Sep 17 00:00:00 2001 From: ValKmjolnir Date: Tue, 28 Dec 2021 20:23:47 +0800 Subject: [PATCH] add test file 'turingmachine.nas' & change output format of ast & bug fixed --- makefile | 1 + nasal_ast.h | 21 ++++++++++++----- nasal_dbg.h | 2 +- nasal_err.h | 6 ++--- test/turingmachine.nas | 51 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 test/turingmachine.nas diff --git a/makefile b/makefile index 21bb601..beeff76 100644 --- a/makefile +++ b/makefile @@ -29,5 +29,6 @@ test:nasal ./nasal -t test/quick_sort.nas ./nasal test/scalar.nas ./nasal test/trait.nas + ./nasal -t test/turingmachine.nas ./nasal -t test/ycombinator.nas \ No newline at end of file diff --git a/nasal_ast.h b/nasal_ast.h index 26601d6..ed5530c 100644 --- a/nasal_ast.h +++ b/nasal_ast.h @@ -138,7 +138,7 @@ public: nasal_ast(const uint32_t l=0,const uint32_t t=ast_null):_line(l),_type(t){} nasal_ast(const nasal_ast&); nasal_ast(nasal_ast&&); - void print(const int); + void print(int,bool); void clear(); nasal_ast& operator=(const nasal_ast&); @@ -209,10 +209,11 @@ void nasal_ast::clear() _child.clear(); } -void nasal_ast::print(const int depth) +void nasal_ast::print(int depth,bool last=false) { - for(int i=0;i intentation={}; + for(auto& i:intentation) + std::cout<>3)==0?0:((line>>3)<<3); end=(1+(line>>3))<<3; for(uint32_t i=begin;i'); + state=action[4]; + break; + } + prt(state,pointer,paper,action); + } +} + +run(table,{},'q0','q3'); \ No newline at end of file