diff options
-rw-r--r-- | usr.bin/oasm/lex.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.bin/oasm/lex.c b/usr.bin/oasm/lex.c index 3ca9e8d..a33a570 100644 --- a/usr.bin/oasm/lex.c +++ b/usr.bin/oasm/lex.c @@ -34,6 +34,7 @@ #include <oasm/lex.h> #include <oasm/log.h> +#define COMMENT '!' #define is_num(c) ((c) >= '0' && (c) <= '9') static char putback = '\0'; @@ -268,6 +269,7 @@ lex_tok(struct oasm_state *state, struct oasm_token *ttp) { char *p = NULL; char c = ' '; + short in_comment = 0; int tmp; tt_t tok; @@ -276,13 +278,19 @@ lex_tok(struct oasm_state *state, struct oasm_token *ttp) } /* - * Grab characters. If they are skippable, - * don't use them. + * Grab characters. If they are skippable or + * comments, don't use them. */ - while (lex_skippable(state, c) == 0) { + while (lex_skippable(state, c) == 0 || in_comment) { if ((c = lex_cin(state)) == 0) { return -1; } + + if (c == COMMENT) { + in_comment = 1; + } else if (c == '\n') { + in_comment = 0; + } } switch (c) { |