TT_MAX
};
-#if 0
+//#define TRACER
+#ifdef TRACER
static const char* const toks[TT_MAX] =
{
"none", "punct", "string", "list", "literal"
while ( c != EOF )
{
- //printf("state = %d, c = %d\n", state, c);
+#ifdef TRACER
+ printf("state = %d, c = %d\n", state, c);
+#endif
if ( c == '\n' )
{
state = 0;
break;
case 6: // token
- if ( isspace(c) || strchr(punct, c) )
+ if ( esc && c == '\\' )
+ {
+ state = 9;
+ }
+ else if ( isspace(c) || strchr(punct, c) )
{
prev = c;
return TT_LITERAL;
state = 1;
}
break;
+ case 9: // token escape
+ s += c;
+ state = 6;
+ break;
}
c = is.get();
chars++;
{ 7, 8, TT_PUNCT, FSM_SOB, "(", nullptr },
{ 8, 0, TT_PUNCT, FSM_EOB, ")", nullptr },
{ 8, 13, TT_LITERAL, FSM_KEY, "metadata", nullptr },
- { 8, 13, TT_LITERAL, FSM_KEY, "reference",":,;" },
+ { 8, 16, TT_LITERAL, FSM_KEY, "reference",":;" },
{ 8, 9, TT_LITERAL, FSM_KEY, nullptr, nullptr },
{ 9, 8, TT_PUNCT, FSM_END, ";", nullptr },
{ 9, 10, TT_PUNCT, FSM_NOP, ":", nullptr },
{ 14, 14, TT_NONE, FSM_SET, ",", nullptr },
{ 14, 14, TT_NONE, FSM_ADD, nullptr, nullptr },
{ 15, 0, TT_LITERAL, FSM_INC, nullptr, nullptr },
+ { 16, 14, TT_PUNCT, FSM_NOP, ":", ";" },
};
static const State* get_state(int num, TokenType type, const string& tok)
exec(s->action, tok, rps, sc);
num = s->next;
- esc = (rps.key == "pcre");
+ esc = (rps.key == "pcre" || rps.key == "reference");
if ( s->punct )
punct = s->punct;
++tokens;
const State* s = get_state(num, type, tok);
- //printf("%d: %s = '%s' -> %s\n",
- // num, toks[type], tok.c_str(), acts[s->action]);
+#ifdef TRACER
+ printf("%d: %s = '%s' -> %s\n",
+ num, toks[type], tok.c_str(), acts[s->action]);
+#endif
if ( exec(s->action, tok, rps, sc) )
break;
num = s->next;
- esc = (rps.key == "pcre");
+ esc = (rps.key == "pcre" || rps.key == "reference");
if ( s->punct )
punct = s->punct;