From: Mike D. Lowis Date: Thu, 28 Feb 2013 00:39:29 +0000 (-0500) Subject: Added comment handling to lexer X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=bb82a809ff1429f752a2bb473452c231551534e3;p=proto%2Fsclpl.git Added comment handling to lexer --- 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())