Implement character set difference

This commit is contained in:
Max Brunsfeld 2014-02-07 12:57:35 -08:00
parent b94fa3ed35
commit df3397f02c
7 changed files with 200 additions and 139 deletions

View file

@ -5,12 +5,12 @@ enum ts_symbol {
ts_symbol_factor,
ts_aux_token1,
ts_symbol_plus,
ts_aux_token2,
ts_symbol_number,
ts_symbol_times,
ts_symbol_expression,
ts_symbol_variable,
ts_aux_token2,
ts_symbol_term,
ts_symbol_variable,
ts_symbol_expression,
ts_symbol___END__,
};
@ -18,12 +18,12 @@ static const char *ts_symbol_names[] = {
"factor",
"token1",
"plus",
"token2",
"number",
"times",
"expression",
"variable",
"token2",
"term",
"variable",
"expression",
"__END__",
};
@ -73,11 +73,11 @@ static void ts_lex(TSParser *parser) {
ADVANCE(8);
LEX_ERROR(2, EXPECT({")", "+"}));
case 10:
if ((LOOKAHEAD_CHAR() == '('))
ADVANCE(12);
if (('A' <= LOOKAHEAD_CHAR() && LOOKAHEAD_CHAR() <= 'Z') ||
('a' <= LOOKAHEAD_CHAR() && LOOKAHEAD_CHAR() <= 'z'))
ADVANCE(13);
if ((LOOKAHEAD_CHAR() == '('))
ADVANCE(12);
if (('0' <= LOOKAHEAD_CHAR() && LOOKAHEAD_CHAR() <= '9'))
ADVANCE(11);
LEX_ERROR(4, EXPECT({"(", "0-9", "A-Z", "a-z"}));
@ -124,10 +124,10 @@ static TSParseResult ts_parse(const char *input) {
SHIFT(42);
case ts_symbol_number:
SHIFT(41);
case ts_symbol_variable:
SHIFT(41);
case ts_symbol_term:
SHIFT(2);
case ts_symbol_variable:
SHIFT(41);
case ts_symbol_expression:
SHIFT(1);
default:
@ -190,12 +190,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(32);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(32);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:
@ -252,12 +252,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(23);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(23);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:
@ -282,12 +282,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(14);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(14);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:
@ -356,12 +356,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(20);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(20);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:
@ -452,12 +452,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(29);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(29);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:
@ -544,12 +544,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(38);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(38);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:
@ -598,12 +598,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(43);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(43);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:
@ -634,10 +634,10 @@ static TSParseResult ts_parse(const char *input) {
case 45:
SET_LEX_STATE(15);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_plus:
REDUCE(ts_symbol_term, 1, COLLAPSE({0}));
case ts_symbol___END__:
REDUCE(ts_symbol_term, 1, COLLAPSE({0}));
case ts_symbol_plus:
REDUCE(ts_symbol_term, 1, COLLAPSE({0}));
case ts_symbol_times:
SHIFT(46);
default:
@ -672,12 +672,12 @@ static TSParseResult ts_parse(const char *input) {
switch (LOOKAHEAD_SYM()) {
case ts_symbol_factor:
SHIFT(16);
case ts_symbol_expression:
SHIFT(49);
case ts_aux_token1:
SHIFT(13);
case ts_symbol_number:
SHIFT(12);
case ts_symbol_expression:
SHIFT(49);
case ts_symbol_variable:
SHIFT(12);
case ts_symbol_term:

View file

@ -4,36 +4,36 @@
enum ts_symbol {
ts_aux_token6,
ts_symbol_number,
ts_symbol_string,
ts_symbol_array,
ts_symbol_value,
ts_aux_token5,
ts_aux_repeat_helper1,
ts_aux_repeat_helper2,
ts_aux_token4,
ts_aux_token3,
ts_aux_token1,
ts_symbol_object,
ts_aux_token2,
ts_aux_token5,
ts_aux_token7,
ts_aux_token4,
ts_aux_repeat_helper2,
ts_aux_token1,
ts_aux_token3,
ts_symbol_value,
ts_symbol_string,
ts_aux_token2,
ts_symbol_array,
ts_aux_repeat_helper1,
ts_symbol___END__,
};
static const char *ts_symbol_names[] = {
"token6",
"number",
"string",
"array",
"value",
"token5",
"repeat_helper1",
"repeat_helper2",
"token4",
"token3",
"token1",
"object",
"token2",
"token5",
"token7",
"token4",
"repeat_helper2",
"token1",
"token3",
"value",
"string",
"token2",
"array",
"repeat_helper1",
"__END__",
};
@ -79,10 +79,10 @@ static void ts_lex(TSParser *parser) {
case 10:
if ((LOOKAHEAD_CHAR() == '{'))
ADVANCE(16);
if ((LOOKAHEAD_CHAR() == '\"'))
ADVANCE(12);
if ((LOOKAHEAD_CHAR() == '['))
ADVANCE(15);
if ((LOOKAHEAD_CHAR() == '\"'))
ADVANCE(12);
if (('0' <= LOOKAHEAD_CHAR() && LOOKAHEAD_CHAR() <= '9'))
ADVANCE(11);
LEX_ERROR(4, EXPECT({"\"", "0-9", "[", "{"}));
@ -128,14 +128,14 @@ static TSParseResult ts_parse(const char *input) {
case 0:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(53);
case ts_symbol_string:
SHIFT(53);
case ts_symbol_array:
SHIFT(53);
case ts_symbol_object:
SHIFT(53);
case ts_symbol_number:
SHIFT(53);
case ts_aux_token5:
SHIFT(47);
case ts_aux_token1:
@ -156,14 +156,14 @@ static TSParseResult ts_parse(const char *input) {
case 2:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_value:
@ -176,14 +176,14 @@ static TSParseResult ts_parse(const char *input) {
case 3:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_value:
@ -226,18 +226,18 @@ static TSParseResult ts_parse(const char *input) {
case 7:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(43);
case ts_symbol_string:
SHIFT(43);
case ts_aux_token5:
SHIFT(35);
case ts_symbol_object:
SHIFT(43);
case ts_symbol_array:
SHIFT(43);
case ts_symbol_value:
SHIFT(41);
case ts_symbol_object:
SHIFT(43);
case ts_symbol_number:
SHIFT(43);
case ts_aux_token5:
SHIFT(35);
case ts_aux_token1:
SHIFT(8);
default:
@ -246,14 +246,14 @@ static TSParseResult ts_parse(const char *input) {
case 8:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_value:
@ -312,18 +312,18 @@ static TSParseResult ts_parse(const char *input) {
case 14:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_value:
SHIFT(15);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_aux_token1:
SHIFT(3);
default:
@ -378,18 +378,18 @@ static TSParseResult ts_parse(const char *input) {
case 20:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(34);
case ts_symbol_string:
SHIFT(34);
case ts_aux_token5:
SHIFT(26);
case ts_symbol_object:
SHIFT(34);
case ts_symbol_array:
SHIFT(34);
case ts_symbol_value:
SHIFT(32);
case ts_symbol_object:
SHIFT(34);
case ts_symbol_number:
SHIFT(34);
case ts_aux_token5:
SHIFT(26);
case ts_aux_token1:
SHIFT(21);
default:
@ -398,14 +398,14 @@ static TSParseResult ts_parse(const char *input) {
case 21:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_value:
@ -474,18 +474,18 @@ static TSParseResult ts_parse(const char *input) {
case 28:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_value:
SHIFT(29);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_aux_token1:
SHIFT(3);
default:
@ -524,10 +524,10 @@ static TSParseResult ts_parse(const char *input) {
case 32:
SET_LEX_STATE(9);
switch (LOOKAHEAD_SYM()) {
case ts_aux_token7:
REDUCE(ts_aux_repeat_helper1, 4, COLLAPSE({1, 0, 1, 0}));
case ts_aux_token2:
SHIFT(18);
case ts_aux_token7:
REDUCE(ts_aux_repeat_helper1, 4, COLLAPSE({1, 0, 1, 0}));
case ts_aux_repeat_helper1:
SHIFT(33);
default:
@ -570,18 +570,18 @@ static TSParseResult ts_parse(const char *input) {
case 37:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_value:
SHIFT(38);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_aux_token1:
SHIFT(3);
default:
@ -620,10 +620,10 @@ static TSParseResult ts_parse(const char *input) {
case 41:
SET_LEX_STATE(6);
switch (LOOKAHEAD_SYM()) {
case ts_aux_token2:
SHIFT(7);
case ts_aux_token4:
REDUCE(ts_aux_repeat_helper2, 2, COLLAPSE({1, 0}));
case ts_aux_token2:
SHIFT(7);
case ts_aux_repeat_helper2:
SHIFT(42);
default:
@ -694,18 +694,18 @@ static TSParseResult ts_parse(const char *input) {
case 49:
SET_LEX_STATE(10);
switch (LOOKAHEAD_SYM()) {
case ts_symbol_number:
SHIFT(25);
case ts_symbol_string:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_array:
SHIFT(25);
case ts_symbol_value:
SHIFT(50);
case ts_symbol_object:
SHIFT(25);
case ts_symbol_number:
SHIFT(25);
case ts_aux_token5:
SHIFT(12);
case ts_aux_token1:
SHIFT(3);
default: