]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Updated macro class for new style of macros
authorMike D. Lowis <mike@mdlowis.com>
Fri, 11 May 2012 20:56:00 +0000 (16:56 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Fri, 11 May 2012 20:56:00 +0000 (16:56 -0400)
source/dlparser/dlparser.h
source/dlparser/macro/macro.cpp
source/dlparser/macro/macro.h
source/visitors/macroprocessor.cpp
source/visitors/macroprocessor.h

index 5e4931097699c69e39f6b0d3b4548413d99ca731..1b01ea2e79ea91f5ae1432ec1961e025bda01e8a 100644 (file)
@@ -2,7 +2,6 @@
 #define DLPARSER_H
 
 #include <map>
-#include <set>
 #include "btparser.h"
 #include "dllexer.h"
 #include "macro.h"
@@ -11,7 +10,7 @@ class DLParser : public BTParser
 {
     private:
         std::map<std::string,eTokenTypes> core_forms;
-        std::set<std::string> macros;
+        std::map<std::string,Macro*> macros;
     public:
         DLParser();
         ~DLParser();
@@ -19,9 +18,6 @@ class DLParser : public BTParser
         bool isCoreFormName(void);
         eTokenTypes getCoreFormId(void);
         void parse(void);
-        bool isMacro(Token& token);
-        bool speculate_GroupExpr(void);
-        bool speculate_MacroPatternMatch(Pattern patt);
 
     private:
         // Entry Rules
index 20171cf18cc47fe881ad351794f1263c8f947709..65546165f823a8ac2da9b092805e6e716a59dc5c 100644 (file)
@@ -1,24 +1,30 @@
 #include "macro.h"
 
-Macro::Macro()
+Macro::Macro() : str_name(""), str_terminator("")
 {
 }
 
-Macro::Macro(const std::list<Pattern>& patts) : patterns(patts)
+Macro::~Macro()
 {
 }
 
-Macro::~Macro()
+const std::string& Macro::name() const
+{
+    return str_name;
+}
+
+void Macro::name(std::string& name)
 {
+    str_name = name;
 }
 
-std::list<Pattern>::iterator Macro::begin()
+const std::string& Macro::terminator() const
 {
-    return patterns.begin();
+    return str_terminator;
 }
 
-std::list<Pattern>::iterator Macro::end()
+void Macro::terminator(std::string& term)
 {
-    return patterns.end();
+    str_terminator = term;
 }
 
index f5b62ae41af723da16739ab3e32e99089e13b8ca..06728f2e028fc7df77248a0e6fe282a759d65dc5 100644 (file)
@@ -1,18 +1,23 @@
 #ifndef MACRO_H
 #define MACRO_H
 
-#include <list>
-#include "pattern.h"
+#include <string>
 
 class Macro {
     private:
-        std::list<Pattern> patterns;
+        std::string str_name;
+        std::string str_terminator;
     public:
         Macro();
-        Macro(const std::list<Pattern>& patts);
         ~Macro();
-        std::list<Pattern>::iterator begin();
-        std::list<Pattern>::iterator end();
+        const std::string& name() const;
+        void name(std::string& name);
+        //const std::string& keywords() const;
+        //void keywords(std::string& nm);
+        const std::string& terminator() const;
+        void terminator(std::string& term);
+        //const std::string& transforms() const;
+        //void transforms(std::string& nm);
 };
 
 #endif
index dc058e664b3c01333aca1e172bdb6c5a1e9b66e1..ae631baf04cffa592ff29d3e464871a6d5fadca1 100644 (file)
@@ -1,6 +1,6 @@
 #include "macroprocessor.h"
 
-MacroProcessor::MacroProcessor(std::set<std::string> &macros) : macro_registry(macros)
+MacroProcessor::MacroProcessor(std::map<std::string,Macro*> &macros) : macro_registry(macros)
 {
 }
 
@@ -24,7 +24,10 @@ void MacroProcessor::afterChildren(AST* cur, int depth)
 {
     if (cur->type() == MACRO)
     {
-        macro_registry.insert( (*(cur->children()->begin()))->text() );
+        std::string name = (*(cur->children()->begin()))->text();
+        Macro* macro = new Macro();
+        macro->name( name );
+        macro_registry[ macro->name() ] = macro;
     }
 }
 
index a9ba0bd3ff69951623728482c78f3cbc4f240e41..99aae82311de8329f1340541e5192f1ea41383a8 100644 (file)
@@ -1,15 +1,16 @@
 #ifndef MACRO_PROCESSOR_H
 #define MACRO_PROCESSOR_H
 
-#include <set>
+#include <map>
 #include "ivisitor.h"
 #include "dllexer.h"
+#include "macro.h"
 
 class MacroProcessor : public IVisitor {
     protected:
-        std::set<std::string>& macro_registry;
+        std::map<std::string,Macro*>& macro_registry;
     public:
-        MacroProcessor(std::set<std::string>& macros);
+        MacroProcessor(std::map<std::string,Macro*>& macros);
     private:
         void beforeVisit(AST* cur, int depth);
         void afterVisit(AST* cur, int depth);