Got rid of non-determinism.
This commit is contained in:
parent
2c8475ff9c
commit
4fdb66076a
@ -79,9 +79,9 @@ static struct scan {
|
|||||||
size_t line;
|
size_t line;
|
||||||
int is_ws_expected, is_source;
|
int is_ws_expected, is_source;
|
||||||
#define X(n) EXPECT_ ## n
|
#define X(n) EXPECT_ ## n
|
||||||
/* "[something: expect; there; to; be; args]", in this case, `size = 5` and
|
/* "[something: expect; there; to; be; args]", in this case, expect would
|
||||||
expect would be 5 `EXPECT_KEYWORD`. */
|
be a stack of `size = 5` `EXPECT_KEYWORD`. */
|
||||||
struct { unsigned size; enum { EXPECT } expect[20]; } command;
|
struct { unsigned size; enum { EXPECT } expect[16]; } command;
|
||||||
#undef X
|
#undef X
|
||||||
} scan; /* Terrible, gah. */
|
} 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];
|
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) {
|
static void expect_pop(void) {
|
||||||
printf("<expect_pop>");
|
printf("<expect_pop>");
|
||||||
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]) {
|
switch(scan.command.expect[--scan.command.size]) {
|
||||||
case EXPECT_KEYWORD: printf("keyword\n");scan.condition = yyccommand_keyword; break;
|
case EXPECT_KEYWORD: printf("keyword\n");scan.condition = yyccommand_keyword; break;
|
||||||
case EXPECT_DATE: printf("date\n");scan.condition = yyccommand_date; break;
|
case EXPECT_DATE: printf("date\n");scan.condition = yyccommand_date; break;
|
||||||
@ -209,7 +211,9 @@ scan:
|
|||||||
<command_date> ws* @s0 date @s1 ws* ";"? / "]"?
|
<command_date> ws* @s0 date @s1 ws* ";"? / "]"?
|
||||||
{ x->s0 = s0, x->s1 = s1; expect_pop();
|
{ x->s0 = s0, x->s1 = s1; expect_pop();
|
||||||
return x->symbol = ARG_DATE, 1; }
|
return x->symbol = ARG_DATE, 1; }
|
||||||
<command_freeform> ws* @s0 [^\t\n\r\v\f;[\]\x00]* @s1 ws* ";"? / "]"?
|
<command_freeform> 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();
|
{ x->s0 = s0, x->s1 = s1; expect_pop();
|
||||||
return x->symbol = ARG_FREEFORM, 1; }
|
return x->symbol = ARG_FREEFORM, 1; }
|
||||||
<command, command_end> "]" => text
|
<command, command_end> "]" => text
|
||||||
|
Loading…
Reference in New Issue
Block a user