diff options
| author | hachem <im@hachem.wtf> | 2026-09-19 11:17:14 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-19 11:17:14 +0200 |
| commit | 768bbdd137f5b205e4282bd79572681aef4514e3 (patch) | |
| tree | c249765cd8607a34443e05709ea54441bf0dfd3e /sfinae.l | |
| parent | 08b8cbbccd8c8d7dab75746ee9d134f67455de91 (diff) | |
feat: add bison grammar for emit, decltype and difference
Diffstat (limited to 'sfinae.l')
| -rw-r--r-- | sfinae.l | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -2,12 +2,13 @@ %{ #include "lexer.h" +#include "ast.h" +#include "parser.h" #include <stdbool.h> #include <stdio.h> 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; -} |
