From bc69779b67d536f505225ec6987bdc7c41d8f4c6 Mon Sep 17 00:00:00 2001 From: Stefano Sanfilippo Date: Sun, 23 Nov 2014 23:22:44 +0100 Subject: [PATCH] Cleaner handling of meta comments. --- Monicelli.ll | 3 ++- main.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Monicelli.ll b/Monicelli.ll index 5e9545c..e73362d 100644 --- a/Monicelli.ll +++ b/Monicelli.ll @@ -6,6 +6,7 @@ extern int lineNumber; extern void yyerror(const char *); +extern void meta(const char *); %} %option noyywrap @@ -22,7 +23,7 @@ CHAR [a-zA-Z_] } "#"[^\n]* { - fprintf(stderr, "META: %s\n", yytext + 1); + meta(yytext + 1); } "bituma"[^\n]* {} diff --git a/main.c b/main.c index aaab159..0b0bdc1 100644 --- a/main.c +++ b/main.c @@ -24,6 +24,13 @@ void emit(const char *text, ...) { va_end(args); } +void meta(const char *text) { + while (text != '\0' && *text == ' ') { + text += 1; + } + fprintf(stderr, "META: %s\n", text); +} + int main() { #if YYDEBUG yydebug = 1;