]> git.mdlowis.com Git - archive/dlang.git/commitdiff
DLParser now fully unit tested.
authorMike D. Lowis <mike@mdlowis.com>
Sat, 9 Jun 2012 00:52:36 +0000 (20:52 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Sat, 9 Jun 2012 00:52:36 +0000 (20:52 -0400)
source/dllexer/dllexer.h
source/dlparser/dlparser.cpp
source/dlparser/dlparser.h

index 693ffc8a3af16b618e1de9697d1bc0d7df9ee363..c9e600fe52b4f29d2b60b75d3f0e158686300cc9 100644 (file)
@@ -6,16 +6,18 @@
 
 typedef enum TokenTypes
 {
+    UNKNOWN    = 0,
+
     // Core Forms
-    PROGRAM    = 0,
-    DEFINE     = 1,
-    ASSIGN     = 2,
-    IF         = 3,
-    BEGIN      = 4,
-    QUOTE      = 5,
-    LAMBDA     = 6,
-    MACRO      = 7,
-    SYNTAX     = 8,
+    PROGRAM    = 1,
+    DEFINE     = 2,
+    ASSIGN     = 3,
+    IF         = 4,
+    BEGIN      = 5,
+    QUOTE      = 6,
+    LAMBDA     = 7,
+    MACRO      = 8,
+    SYNTAX     = 9,
 
     // Punctuation and Symbols
     LPAR       = 10,
index 95ebc9f9fc31a88b6608432bdbfc60569bace54b..d328d3e8380c385ae86ca28f164186daa53716e9 100644 (file)
@@ -33,7 +33,12 @@ bool DLParser::isCoreFormName(void)
 
 eTokenTypes DLParser::getCoreFormId(void)
 {
-    return core_forms[ lookaheadToken(1).text() ];
+    eTokenTypes type = UNKNOWN;
+    if ( isCoreFormName() )
+    {
+        type = core_forms[ lookaheadToken(1).text() ];
+    }
+    return type;
 }
 
 void DLParser::parse(void)
@@ -151,11 +156,6 @@ AST* DLParser::CoreForm(void)
     return ret;
 }
 
-AST* DLParser::FuncApp(void)
-{
-    return NULL;
-}
-
 AST* DLParser::BasicExp(void)
 {
     AST* ret = NULL;
@@ -176,7 +176,8 @@ AST* DLParser::BasicExp(void)
     }
 
     // Infix Function Application
-    else*/ if( lookaheadType(1) == LPAR )
+    else*/
+    if( lookaheadType(1) == LPAR )
     {
         AST* operation = NULL;
         AST* operand1  = NULL;
index e18e487a23040af07bce872dee84ab9e6db4d0c2..7a3aaf478fec5c81c292be6dcc547616cd2d2392 100644 (file)
@@ -8,7 +8,7 @@
 
 class DLParser : public BTParser
 {
-    private:
+    protected:
         std::map<std::string,eTokenTypes> core_forms;
         std::map<std::string,Syntax*> syntaxes;
     public:
@@ -19,7 +19,6 @@ class DLParser : public BTParser
         eTokenTypes getCoreFormId(void);
         void parse(void);
 
-    private:
         // Entry Rules
         AST* Program(void);
         AST* Expression(void);