diff --git a/src/lex.re_c.c b/src/lex.re_c.c index 8e968dc..943e191 100644 --- a/src/lex.re_c.c +++ b/src/lex.re_c.c @@ -79,9 +79,9 @@ static struct scan { size_t line; int is_ws_expected, is_source; #define X(n) EXPECT_ ## n - /* "[something: expect; there; to; be; args]", in this case, `size = 5` and - expect would be 5 `EXPECT_KEYWORD`. */ - struct { unsigned size; enum { EXPECT } expect[20]; } command; + /* "[something: expect; there; to; be; args]", in this case, expect would + be a stack of `size = 5` `EXPECT_KEYWORD`. */ + struct { unsigned size; enum { EXPECT } expect[16]; } command; #undef X } scan; /* Terrible, gah. */ @@ -118,9 +118,11 @@ id = [a-zA-Z_][a-zA-Z_\-0-9]{0,63}; date = "-"? natural "-" [0-1][0-9] "-" [0-1][0-9]; */ +/** I don't think `re2c` supports branching on variable conditions. + It does now? */ static void expect_pop(void) { printf(""); - if(!scan.command.size) { printf("nostack\n"); scan.condition = yyccommand_end; return; } + if(!scan.command.size) { printf("allfinished\n"); scan.condition = yyccommand_end; return; } switch(scan.command.expect[--scan.command.size]) { case EXPECT_KEYWORD: printf("keyword\n");scan.condition = yyccommand_keyword; break; case EXPECT_DATE: printf("date\n");scan.condition = yyccommand_date; break; @@ -209,7 +211,9 @@ scan: ws* @s0 date @s1 ws* ";"? / "]"? { x->s0 = s0, x->s1 = s1; expect_pop(); return x->symbol = ARG_DATE, 1; } - ws* @s0 [^\t\n\r\v\f;[\]\x00]* @s1 ws* ";"? / "]"? + ws* @s0 + [^ \t\n\r\v\f;[\]\x00][^\t\n\r\v\f;[\]\x00]*[^ \t\n\r\v\f;[\]\x00]* + @s1 ws* ";"? / "]"? { x->s0 = s0, x->s1 = s1; expect_pop(); return x->symbol = ARG_FREEFORM, 1; } "]" => text