From bb82a809ff1429f752a2bb473452c231551534e3 Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Wed, 27 Feb 2013 19:39:29 -0500 Subject: [PATCH] Added comment handling to lexer --- source/lexer/lex.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/lexer/lex.c b/source/lexer/lex.c index 88e36d3..4ff5e96 100644 --- a/source/lexer/lex.c +++ b/source/lexer/lex.c @@ -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()) -- 2.55.0