From 04fc9fe90f5ce1387c4fd232c4fbe4318b17d56a Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Tue, 6 Mar 2012 13:31:45 -0500 Subject: [PATCH] Added pattern class and updated assignment rule in preparation for macro expansion implementation --- source/dlparser/dlparser.cpp | 23 +++++++++++++---------- source/dlparser/macro/pattern.cpp | 10 ++++++++++ source/dlparser/macro/pattern.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 source/dlparser/macro/pattern.cpp create mode 100644 source/dlparser/macro/pattern.h diff --git a/source/dlparser/dlparser.cpp b/source/dlparser/dlparser.cpp index f6fd6c3..6a1f668 100644 --- a/source/dlparser/dlparser.cpp +++ b/source/dlparser/dlparser.cpp @@ -81,10 +81,6 @@ AST* DLParser::Expression(void) { ret = MacroDefinition(); } - //else if( isMacro( lookaheadToken(1) ) ) - //{ - // ret = MacroExpansion(); - //} else { ret = AssignExpr(); @@ -95,12 +91,19 @@ AST* DLParser::Expression(void) AST* DLParser::AssignExpr(void) { AST* ret = NULL; - ret = LogicalExpr(); - if(lookaheadType(1) == ASSIGN) - { - match(ASSIGN); - ret = new AST(ASSIGN, 2, ret, LogicalExpr()); - } + //if( isMacro( lookaheadToken(1) ) ) + //{ + // ret = MacroExpansion(); + //} + //else + //{ + ret = LogicalExpr(); + if(lookaheadType(1) == ASSIGN) + { + match(ASSIGN); + ret = new AST(ASSIGN, 2, ret, LogicalExpr()); + } + //} return ret; } diff --git a/source/dlparser/macro/pattern.cpp b/source/dlparser/macro/pattern.cpp new file mode 100644 index 0000000..c29cec4 --- /dev/null +++ b/source/dlparser/macro/pattern.cpp @@ -0,0 +1,10 @@ +#include "pattern.h" + +Pattern::Pattern(const std::list& patt, const AST* ast) : pattern(patt), expr_ast(ast) +{ +} + +Pattern::~Pattern() +{ +} + diff --git a/source/dlparser/macro/pattern.h b/source/dlparser/macro/pattern.h new file mode 100644 index 0000000..00d3688 --- /dev/null +++ b/source/dlparser/macro/pattern.h @@ -0,0 +1,29 @@ +#ifndef PATTERN_H +#define PATTERN_H + +#include +#include "ast.h" + +typedef enum { + MAP_TYP, + VECT_TYP, + LiST_TYP, + BLK_TYP, + ID_TYP, + NUM_TYP, + CHAR_TYP, + STR_TYP, + SYM_TYP, + EXPR_TYP +} PatternType_T; + +class Pattern { + private: + std::list pattern; + const AST* expr_ast; + public: + Pattern(const std::list& patt, const AST* ast); + ~Pattern(); +}; + +#endif -- 2.49.0