]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
Added comment handling to lexer
authorMike D. Lowis <mike@mdlowis.com>
Thu, 28 Feb 2013 00:39:29 +0000 (19:39 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Thu, 28 Feb 2013 00:39:29 +0000 (19:39 -0500)
source/lexer/lex.c

index 88e36d321270c5548a892e07a572165a7cec6b47..4ff5e96bda2c047e497858c924b4f7b3bb97582e 100644 (file)
@@ -20,6 +20,7 @@ static void abort(void);
 static void reset(void);
 static void match_and_consume(char ch);
 static bool one_or_more(predicate_t pfn);
+static void comment(void);
 static void punctuation(void);
 static void number(void);
 static void hexadecimal(void);
@@ -96,6 +97,8 @@ void next_token(tok_t* p_token)
         /* Mark our starting point so we can resume if we abort */
         if (0 == setjmp(Jump_Point))
         {
+            if (matches('#')) comment();
+
             if (matches_any("()[]{};"))
                 punctuation();
             else if (matches('-') || digit() || matches('h'))
@@ -120,6 +123,14 @@ void next_token(tok_t* p_token)
     tok_copy( p_token );
 }
 
+static void comment(void)
+{
+    while (!matches('\n'))
+        tok_discard();
+    while( whitespace() )
+        tok_discard();
+}
+
 static void punctuation(void)
 {
     switch (file_peek())