From 72a1f8cb9ebb0e4e66eeab144028f62d7ce01820 Mon Sep 17 00:00:00 2001 From: Stu Black Date: Sun, 26 Oct 2025 10:10:19 -0400 Subject: [PATCH] Throw some comments around the FST table for tokenizing command line. This is slated for replacement, but it will help to be better documented first. --- WINGs/string.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/WINGs/string.c b/WINGs/string.c index 4851b6f7..527cf4d5 100644 --- a/WINGs/string.c +++ b/WINGs/string.c @@ -31,15 +31,16 @@ typedef struct { } DFA; static DFA mtable[9][6] = { - {{3, 1}, {0, 0}, {4, 0}, {1, 0}, {8, 0}, {6, 0}}, - {{1, 1}, {1, 1}, {2, 0}, {3, 0}, {5, 0}, {1, 1}}, - {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {5, 0}, {1, 1}}, - {{3, 1}, {5, 0}, {4, 0}, {1, 0}, {5, 0}, {6, 0}}, - {{3, 1}, {3, 1}, {3, 1}, {3, 1}, {5, 0}, {3, 1}}, - {{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* final state */ - {{6, 1}, {6, 1}, {7, 0}, {6, 1}, {5, 0}, {3, 0}}, - {{6, 1}, {6, 1}, {6, 1}, {6, 1}, {5, 0}, {6, 1}}, - {{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* final state */ + /* Ctype: ALPHA BLANK ESCAPE DQUOTE EOS SQUOTE + /* State 0: Start */ {{3, 1}, {0, 0}, {4, 0}, {1, 0}, {8, 0}, {6, 0}}, + /* State 1: In dquote */ {{1, 1}, {1, 1}, {2, 0}, {3, 0}, {5, 0}, {1, 1}}, + /* State 2: Escape in dquote */ {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {5, 0}, {1, 1}}, + /* State 3: In token */ {{3, 1}, {5, 0}, {4, 0}, {1, 0}, {5, 0}, {6, 0}}, + /* State 4: Escaping */ {{3, 1}, {3, 1}, {3, 1}, {3, 1}, {5, 0}, {3, 1}}, + /* State 5: End of string */ {{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* final state */ + /* State 6: In squote */ {{6, 1}, {6, 1}, {7, 0}, {6, 1}, {5, 0}, {3, 0}}, + /* State 7: Escape in squote */ {{6, 1}, {6, 1}, {6, 1}, {6, 1}, {5, 0}, {6, 1}}, + /* State 8: End of string */ {{-1, -1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, /* final state */ }; char *wtokennext(char *word, char **next)