From: Mike D. Lowis Date: Sat, 9 Jun 2012 00:52:36 +0000 (-0400) Subject: DLParser now fully unit tested. X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=3d81faa5ffbb087b0beaafdb7f3847dc1606d0fb;p=archive%2Fdlang.git DLParser now fully unit tested. --- diff --git a/source/dllexer/dllexer.h b/source/dllexer/dllexer.h index 693ffc8..c9e600f 100644 --- a/source/dllexer/dllexer.h +++ b/source/dllexer/dllexer.h @@ -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, diff --git a/source/dlparser/dlparser.cpp b/source/dlparser/dlparser.cpp index 95ebc9f..d328d3e 100644 --- a/source/dlparser/dlparser.cpp +++ b/source/dlparser/dlparser.cpp @@ -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; diff --git a/source/dlparser/dlparser.h b/source/dlparser/dlparser.h index e18e487..7a3aaf4 100644 --- a/source/dlparser/dlparser.h +++ b/source/dlparser/dlparser.h @@ -8,7 +8,7 @@ class DLParser : public BTParser { - private: + protected: std::map core_forms; std::map 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);