From 768bbdd137f5b205e4282bd79572681aef4514e3 Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 19 Sep 2026 11:17:14 +0200 Subject: feat: add bison grammar for emit, decltype and difference --- sfinae.l | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'sfinae.l') diff --git a/sfinae.l b/sfinae.l index f969a98..5c67f3c 100644 --- a/sfinae.l +++ b/sfinae.l @@ -2,12 +2,13 @@ %{ #include "lexer.h" +#include "ast.h" +#include "parser.h" #include #include static bool failed = false; -static char character = '\0'; static char unescape(char escaped) { @@ -24,7 +25,7 @@ static int fail(const char* message) { (void)fprintf(stderr, "line %d: %s\n", yylineno, message); failed = true; - return TOK_END; + return 0; } %} @@ -36,8 +37,8 @@ static int fail(const char* message) "decltype" return TOK_DECLTYPE; "difference" return TOK_DIFFERENCE; [<>(),;] return yytext[0]; -'\\.' character = unescape(yytext[2]); return TOK_CHAR; -'.' character = yytext[1]; return TOK_CHAR; +'\\.' yylval.character = unescape(yytext[2]); return TOK_CHAR; +'.' yylval.character = yytext[1]; return TOK_CHAR; "//"[^\n]* /* a comment */ [ \t\r\n]+ /* blanks */ [0-9]+ return fail("numeric literals are for the weak, subtract two characters"); @@ -50,8 +51,3 @@ bool lexer_failed(void) { return failed; } - -char lexer_character(void) -{ - return character; -} -- cgit v1.3