/* Generated by re2c 1.1.1 */ /* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2018-2020 Couchbase, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include "lexer.h" const char *lex(const char *s, bm_TOKEN *tok) { const char *m, *k, *ke, *v, *ve; const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5;const char *yyt6; loop: { char yych; unsigned int yyaccept = 0; yych = *s; switch (yych) { case 0x00: goto yy3; case '\t': case '\n': case '\r': case ' ': goto yy7; case '"': yyt1 = s; goto yy10; case '-': yyt1 = s; goto yy12; case '=': yyt1 = s; goto yy2; default: yyt1 = s; goto yy5; } yy2: k = yyt1; ke = s; { tok->type = BM_TOKEN_WORD; tok->t.word.ptr = k; tok->t.word.len = (int)(ke - k); return s; } yy3: ++s; { return NULL; } yy5: yych = *++s; switch (yych) { case 0x00: case '\t': case '\n': case '\r': case ' ': case '=': goto yy2; default: goto yy5; } yy7: yych = *++s; switch (yych) { case '\t': case '\n': case '\r': case ' ': goto yy7; default: goto yy9; } yy9: { goto loop; } yy10: yyaccept = 0; yych = *(m = ++s); switch (yych) { case 0x00: case '=': goto yy2; case '\t': case '\n': case '\r': case ' ': goto yy13; default: goto yy10; } yy12: yych = *++s; switch (yych) { case 0x00: case '\t': case '\n': case '\r': case ' ': case '=': goto yy2; case '-': yyt1 = s; goto yy19; default: yyt1 = s; goto yy16; } yy13: yych = *++s; switch (yych) { case 0x00: case '=': goto yy15; case '"': goto yy20; default: goto yy13; } yy15: s = m; switch (yyaccept) { case 0: goto yy2; case 1: goto yy18; case 2: yyt2 = yyt3; yyt4 = yyt5; goto yy18; default: yyt1 = yyt3; yyt2 = yyt5; yyt4 = yyt6; goto yy18; } yy16: yych = *++s; switch (yych) { case 0x00: yyt2 = yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': yyt2 = s; goto yy22; case '"': yyt2 = yyt4 = s; goto yy24; case '=': yyt2 = s; goto yy26; default: goto yy16; } yy18: k = yyt1; ke = yyt2; v = yyt4; ve = s; { tok->type = BM_TOKEN_OPTION; tok->t.option.key = k; tok->t.option.klen = (int)(ke - k); tok->t.option.val = v; tok->t.option.vlen = (int)(ve - v); return s; } yy19: yych = *++s; switch (yych) { case 0x00: yyt2 = yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': yyt2 = s; goto yy22; case '"': yyt2 = yyt3 = yyt4 = s; goto yy28; case '=': yyt2 = s; goto yy26; default: yyt1 = s; goto yy16; } yy20: yyaccept = 0; yych = *(m = ++s); switch (yych) { case 0x00: case '=': goto yy2; case '"': goto yy20; default: goto yy13; } yy22: yych = *++s; switch (yych) { case 0x00: yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': goto yy22; case '"': yyt4 = s; goto yy32; case '=': goto yy26; default: yyt4 = s; goto yy30; } yy24: yych = *++s; switch (yych) { case 0x00: yyt2 = yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': yyt3 = s; goto yy34; case '"': yyt2 = yyt4 = s; goto yy24; case '=': yyt2 = s; goto yy26; default: goto yy24; } yy26: yych = *++s; switch (yych) { case 0x00: case '=': yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': goto yy26; case '"': yyt4 = s; goto yy32; default: yyt4 = s; goto yy30; } yy28: yych = *++s; switch (yych) { case 0x00: yyt1 = yyt3; yyt2 = yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': yyt5 = s; goto yy36; case '"': yyt1 = yyt3; yyt2 = yyt4 = s; goto yy24; case '=': yyt1 = yyt3; yyt2 = s; goto yy26; default: goto yy28; } yy30: yych = *++s; switch (yych) { case 0x00: case '\t': case '\n': case '\r': case ' ': case '=': goto yy18; default: goto yy30; } yy32: yyaccept = 1; yych = *(m = ++s); switch (yych) { case 0x00: case '=': goto yy18; case '\t': case '\n': case '\r': case ' ': goto yy38; default: goto yy32; } yy34: yych = *++s; switch (yych) { case 0x00: yyt2 = yyt3; yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': goto yy34; case '"': yyt2 = yyt3; yyt4 = s; goto yy32; case '=': yyt2 = yyt3; goto yy26; default: yyt5 = s; goto yy40; } yy36: yych = *++s; switch (yych) { case 0x00: yyt1 = yyt3; yyt2 = yyt5; yyt4 = s; goto yy18; case '\t': case '\n': case '\r': case ' ': goto yy36; case '"': yyt1 = yyt3; yyt2 = yyt5; yyt4 = s; goto yy32; case '=': yyt1 = yyt3; yyt2 = yyt5; goto yy26; default: yyt6 = s; goto yy42; } yy38: yych = *++s; switch (yych) { case 0x00: case '=': goto yy15; case '"': goto yy44; default: goto yy38; } yy40: yyaccept = 2; yych = *(m = ++s); switch (yych) { case 0x00: case '=': yyt2 = yyt3; yyt4 = yyt5; goto yy18; case '\t': case '\n': case '\r': case ' ': goto yy38; default: goto yy40; } yy42: yyaccept = 3; yych = *(m = ++s); switch (yych) { case 0x00: case '=': yyt1 = yyt3; yyt2 = yyt5; yyt4 = yyt6; goto yy18; case '\t': case '\n': case '\r': case ' ': goto yy38; default: goto yy42; } yy44: yyaccept = 1; yych = *(m = ++s); switch (yych) { case 0x00: case '=': goto yy18; case '"': goto yy44; default: goto yy38; } } return NULL; }