From 658c2fa36f3359325665c744ebe57478d539b28d Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Wed, 13 Apr 2022 17:29:33 -0400 Subject: Include ast, add function to print tokens --- tnslc/parse/parse.tnsl | 10 +--------- tnslc/parse/token.tnsl | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'tnslc/parse') diff --git a/tnslc/parse/parse.tnsl b/tnslc/parse/parse.tnsl index 52fd0c7..5d3bfa5 100644 --- a/tnslc/parse/parse.tnsl +++ b/tnslc/parse/parse.tnsl @@ -21,15 +21,7 @@ /; print_tokens(~{}parse.Token dat) /;loop (int i = 0; i < len dat`) [i++] - ;tnsl.io.print("{ ") - ;tnsl.io.print(dat`{i}.token_type) - ;tnsl.io.print(" ") - ;tnsl.io.print(dat`{i}.data`) - ;tnsl.io.print(" ") - ;tnsl.io.print(dat`{i}.line) - ;tnsl.io.print(" ") - ;tnsl.io.print(dat`{i}.col) - ;tnsl.io.print(" } ") + ;dat`{i}.print() ;/ ;tnsl.io.print("\n") ;/ diff --git a/tnslc/parse/token.tnsl b/tnslc/parse/token.tnsl index 6c402fd..e18ade5 100644 --- a/tnslc/parse/token.tnsl +++ b/tnslc/parse/token.tnsl @@ -40,6 +40,18 @@ /; method Token + /; print + ;tnsl.io.print("{ ") + ;tnsl.io.print(self.token_type) + ;tnsl.io.print(" ") + ;tnsl.io.print(self.data`) + ;tnsl.io.print(" ") + ;tnsl.io.print(self.line) + ;tnsl.io.print(" ") + ;tnsl.io.print(self.col) + ;tnsl.io.print(" } ") + ;/ + /; operator delete ;delete self.data ;/ @@ -310,6 +322,10 @@ ;return TOKEN_TYPE.DEFWORD ;;else if (len s` == 1) + + /; if (is_digit(s`{0})) + ;return TOKEN_TYPE.LITERAL + ;/ /; if (is_in_string(~DELIMITS, s`{0})) ;return TOKEN_TYPE.DELIMIT -- cgit v1.2.3