From 47940e2a528e30903c68abb6c0246cb86772d389 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 12 Jan 2021 21:40:11 -0500 Subject: Remove hacky tagging from hilex God that makes the lexers so much simpler. --- bin/hilex/c.l | 46 +++------------------------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) (limited to 'bin/hilex/c.l') diff --git a/bin/hilex/c.l b/bin/hilex/c.l index e89d3adc..21e7d44b 100644 --- a/bin/hilex/c.l +++ b/bin/hilex/c.l @@ -21,8 +21,7 @@ #include "hilex.h" %} -%s MacroLine MacroInclude MacroDefine -%s TypeDecl +%s MacroLine MacroInclude %x CharLiteral StringLiteral ident [_[:alpha:]][_[:alnum:]]* @@ -30,7 +29,6 @@ width "*"|[0-9]+ %% static int pop = INITIAL; - static int depth = 0; [[:blank:]]+ { return Normal; } @@ -51,19 +49,6 @@ sizeof|(_A|alignof) { return Number; } -enum|struct|typedef|union { - BEGIN(TypeDecl); - return Keyword; -} -{ident}/[[:space:]]*"{" { - BEGIN(pop); - return IdentifierTag; -} -. { - BEGIN(pop); - REJECT; -} - auto|break|case|const|continue|default|do|else|enum|extern|for|goto|if|inline | register|restrict|return|static|struct|switch|typedef|union|volatile|while | (_A|a)lignas|_Atomic|_Generic|(_N|n)oreturn|(_S|s)tatic_assert | @@ -75,28 +60,14 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while | BEGIN(pop = MacroInclude); return Macro; } -^"#"[[:blank:]]*define { - BEGIN(pop = MacroDefine); - return Macro; -} ^"#"[[:blank:]]*{ident} { BEGIN(pop = MacroLine); return Macro; } - "<"[^>]+">" { return String; } -{ident}/"(" { - BEGIN(pop = MacroLine); - return IdentifierTag; -} -{ident} { - BEGIN(pop = MacroLine); - return Macro; -} - -{ +{ "\n" { BEGIN(pop = INITIAL); return Normal; @@ -107,14 +78,6 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while | {ident} { return Identifier; } -{ident}/("["[^]]*"]")*[[:space:]]*"=" | -{ident}/"("[^)]*")"[[:space:]]*"{" { - return (!depth ? IdentifierTag : Identifier); -} -{ident}/"("[^)]*");" { - return (!depth ? IdentifierTag : Identifier); -} - "//"([^\n]|"\\\n")* | "/*"([^*]|"*"[^/])*"*"+"/" { return Comment; @@ -160,10 +123,7 @@ register|restrict|return|static|struct|switch|typedef|union|volatile|while | [^%\\""]+|. { return String; } } -"{" { depth++; REJECT; } -"}" { depth--; REJECT; } - -. { +. { return Macro; } -- cgit 1.4.1