]> git.mdlowis.com Git - archive/dlang.git/commitdiff
Fixed terminator recognition in lexer
authorMike D. Lowis <mike@mdlowis.com>
Fri, 11 May 2012 20:27:46 +0000 (16:27 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Fri, 11 May 2012 20:27:46 +0000 (16:27 -0400)
example.dl
source/dllexer/dllexer.cpp

index 70fe059cdc06d74017e2aae810259e34a9750006..5e6ad1bbdddb9fed727f667970036158aaad2652 100644 (file)
@@ -51,6 +51,7 @@ end
 # If statement
 if conditional
     if_branch
+else
     else_branch
 end
 
@@ -64,13 +65,22 @@ end
 (1 add (1 add 1))
 (1 - (1 + 1))
 
+## Define an infix operator (No Precedence)
+#infix =
+#
+## Define dummy keywords (Whitespace)
+#keyword ;
+#
+#foo = (1 + 1) ;
+
 # Macros
 macro let (:= =) ;
     (a := b)
-        define a b end
+        define a b
+
     (a = b)
-        set! a b end
+        set! a b
 end
 
-let foo := "bar" end
-let foo = 5 end
+let foo := "bar" ;
+let foo = 5 ;
index 8b1cbca060592b3cfacaaff63fec596d7d51d552..15f2781bfb8e192f3f7bf15526cd73f370fd5a7d 100644 (file)
@@ -47,6 +47,7 @@ std::string DLLexer::terminator(void)
 Token DLLexer::next(void)
 {
     Token ret;
+    bool escaped = false;
 
     // Prime the buffer. For empty input strings this results in us finding
     // the EOF and skipping the loop
@@ -111,7 +112,6 @@ Token DLLexer::next(void)
         // Everything else (except the unescaped terminator) is considered an ID
         else
         {
-            bool escaped = false;
             if ( lookahead(1) == '\\' )
             {
                 consume();
@@ -119,11 +119,11 @@ Token DLLexer::next(void)
             }
 
             Id(ret);
+        }
 
-            if( !escaped && (ret.text().compare( terminator_string ) == 0) )
-            {
-                ret.type( TERM );
-            }
+        if( !escaped && (ret.text().compare( terminator_string ) == 0) )
+        {
+            ret.type( TERM );
         }
     }