From: Mike D. Lowis Date: Thu, 3 May 2012 19:17:30 +0000 (-0400) Subject: Updated AST to create a node directly from a token (for literals like numbers) X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=29f2ff340d11bda28ec37113869644a1fd1b3522;p=archive%2Fparse-utils.git Updated AST to create a node directly from a token (for literals like numbers) --- diff --git a/source/parser/ast/ast.cpp b/source/parser/ast/ast.cpp index 4f3a993..9be1c15 100644 --- a/source/parser/ast/ast.cpp +++ b/source/parser/ast/ast.cpp @@ -12,6 +12,13 @@ AST::AST(ASTNodeType type) node_children = new list(); } +AST::AST(Token tok) +{ + node_type = tok.type(); + node_text = tok.text(); + node_children = new list(); +} + AST::AST(ASTNodeType type, const char* text) { node_type = type; diff --git a/source/parser/ast/ast.h b/source/parser/ast/ast.h index abce052..5e89442 100644 --- a/source/parser/ast/ast.h +++ b/source/parser/ast/ast.h @@ -4,6 +4,7 @@ #include #include #include +#include "token.h" typedef unsigned int ASTNodeType; @@ -15,6 +16,7 @@ class AST std::list* node_children; public: AST(ASTNodeType type); + AST(Token tok); AST(ASTNodeType type, const char* text); AST(ASTNodeType type, std::string text); AST(ASTNodeType type, int child_count, ...);