A Nix language parser implemented in C (ragel + bison)

parser

+5963
+4
.gitignore
··· 53 53 54 54 # debug information files 55 55 *.dwo 56 + 57 + /bin 58 + /vic 59 + /tmp
+29
Justfile
··· 1 + nothing: 2 + 3 + ragel: 4 + ragel -C -G2 -o parser/machine.c parser/machine.rl 5 + 6 + bison: 7 + bison -d -o parser/parser.c parser/parser.y 8 + 9 + build: ragel bison 10 + gcc -std=c11 -O2 -I parser -o bin/lexdemo \ 11 + parser/main.c parser/machine.c parser/parser.c parser/nodetype.c parser/lexer_helper.c parser/lexer_adapter.c 12 + gcc -std=c11 -O2 -I parser -o bin/walk \ 13 + parser/walk.c parser/machine.c parser/parser.c parser/nodetype.c parser/lexer_helper.c parser/lexer_adapter.c 14 + 15 + run: build 16 + ./bin/lexdemo nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix 17 + 18 + run-walk: build 19 + ./bin/walk ./nixpkgs/lib 20 + 21 + test: build gen-c-ast 22 + @echo "Done" 23 + 24 + test_nix := "nixpkgs/pkgs/development/haskell-modules/hackage-packages.nix" 25 + # test_nix := "nixpkgs/pkgs/top-level/all-packages.nix" 26 + # test_nix := "test.nix" 27 + 28 + gen-c-ast: build 29 + ./bin/lexdemo {{test_nix}} > tmp/c.ast
+94
parser/lexer.h
··· 1 + #ifndef PARSER_LEXER_H 2 + #define PARSER_LEXER_H 3 + 4 + #include <stddef.h> 5 + 6 + #ifdef __cplusplus 7 + extern "C" { 8 + #endif 9 + 10 + typedef struct { 11 + int Sym; 12 + int Pos; 13 + int End; 14 + int Prev; 15 + } lexerToken; 16 + 17 + typedef struct { 18 + char *filename; /* owned */ 19 + char *data; /* owned */ 20 + int len; 21 + 22 + lexerToken *tokens; 23 + size_t ntokens; 24 + size_t ctokens; 25 + 26 + lexerToken *comments; 27 + size_t ncomments; 28 + size_t ccomments; 29 + 30 + int *lines; /* offsets of line starts */ 31 + size_t nlines; 32 + size_t clines; 33 + 34 + char *errmsg; 35 + } LexResult; 36 + 37 + /* Backrefs: stack of pairs (index, fin) */ 38 + typedef struct { 39 + int *v; /* flat array of pairs */ 40 + size_t n; 41 + size_t c; 42 + } Backrefs; 43 + 44 + /* Create/destroy */ 45 + LexResult *newLexResult(const char *path, int size); 46 + void freeLexResult(LexResult *r); 47 + 48 + /* Helper to convert sym to string (optional, implemented in parser) */ 49 + const char *symString(int sym); 50 + 51 + /* Ragel-generated lexer entry point (implemented after running ragel on machine.rl) 52 + Signature may be adjusted when you convert the Ragel wrapper to C. */ 53 + int lexData(const char *data, int len, LexResult *r); 54 + 55 + /* Low-level push helpers used by macros (defined in lexer_helper.c) */ 56 + void lexresult_push_token(LexResult *r, int sym, int ts, int te); 57 + void lexresult_push_comment(LexResult *r, int sym, int ts, int te); 58 + 59 + /* Backrefs helpers */ 60 + void backrefs_push(Backrefs *s, int i, int fin); 61 + int backrefs_pop(Backrefs *s, int *i, int *fin); 62 + size_t backrefs_len(const Backrefs *s); 63 + void backrefs_free(Backrefs *s); 64 + 65 + /* Implementations called by the Ragel actions (prototypes) */ 66 + void tokenter_impl(int sym, int fin, LexResult *r, Backrefs *backrefs, int ts, int te); 67 + int tokleave_impl(int sym, LexResult *r, Backrefs *backrefs, int *top, int ts, int te); 68 + int tokarg_impl(LexResult *r, int ts, int te); 69 + void add_lines_impl(LexResult *r, int ts, int te); 70 + void add_line_impl(LexResult *r, int ts); 71 + 72 + /* Scanner adapter helpers (implemented in lexer_adapter.c) */ 73 + void *create_scanner(const char *buf, int len, const char *filename); 74 + void free_scanner(void *scanner); 75 + LexResult *scanner_lexresult(void *scanner); 76 + 77 + /* Convenience macros used inside the Ragel actions. These expect the 78 + local variables `ts`, `te`, `top` and `backrefs` to be available in 79 + the lexical function generated by Ragel (this mirrors the original 80 + Go code's closures). ts and te are pointers into the input buffer; 81 + compute integer offsets relative to `data`. */ 82 + #define tok(sym, r) lexresult_push_token((r), (sym), (int)((ts) - (data)), (int)((te) - (data))) 83 + #define tokcomment(sym, r) lexresult_push_comment((r), (sym), (int)((ts) - (data)), (int)((te) - (data))) 84 + #define tokenter(sym,fin,r) tokenter_impl((sym),(fin),(r), &backrefs, (int)((ts) - (data)), (int)((te) - (data))) 85 + #define tokleave(sym,r) tokleave_impl((sym),(r), &backrefs, &top, (int)((ts) - (data)), (int)((te) - (data))) 86 + #define tokarg(r) tokarg_impl((r), (int)((ts) - (data)), (int)((te) - (data))) 87 + #define add_lines(r,ts_,te_) add_lines_impl((r),(int)((ts_) - (data)),(int)((te_) - (data))) 88 + #define add_line(r,ts_) add_line_impl((r),(int)((ts_) - (data))) 89 + 90 + #ifdef __cplusplus 91 + } 92 + #endif 93 + 94 + #endif /* PARSER_LEXER_H */
+166
parser/lexer_adapter.c
··· 1 + #include <stdio.h> 2 + #include <stdlib.h> 3 + #include <string.h> 4 + 5 + #include "lexer.h" 6 + #include "node.h" 7 + #include "parser.h" /* provides parser token enums and YYSTYPE */ 8 + 9 + /* Legacy token numeric values from parser/tokens.h (copied here to avoid include-order issues) 10 + These are the values produced by the Ragel lexer (legacy mapping). */ 11 + #define LEG_ASSERT_ 57346 12 + #define LEG_IF_ 57347 13 + #define LEG_THEN 57348 14 + #define LEG_ELSE_ 57349 15 + #define LEG_LET 57350 16 + #define LEG_IN 57351 17 + #define LEG_WITH 57352 18 + #define LEG_OR_ 57353 19 + #define LEG_REC 57354 20 + #define LEG_INHERIT 57355 21 + #define LEG_ELLIPSIS 57356 22 + #define LEG_INTERP 57357 23 + #define LEG_SPACE 57358 24 + #define LEG_COMMENT 57359 25 + #define LEG_II 57360 26 + #define LEG_URI 57361 27 + #define LEG_PATH 57362 28 + #define LEG_FLOAT 57363 29 + #define LEG_INT_ 57364 30 + #define LEG_T_ID 57365 31 + #define LEG_TEXT 57366 32 + #define LEG_ARG_ID 57367 33 + #define LEG_ARG_BRACKET 57368 34 + #define LEG_IMPL 57369 35 + #define LEG_OR 57370 36 + #define LEG_AND 57371 37 + #define LEG_EQ 57372 38 + #define LEG_NEQ 57373 39 + #define LEG_LEQ 57374 40 + #define LEG_GEQ 57375 41 + #define LEG_UPDATE 57376 42 + #define LEG_CONCAT 57377 43 + #define LEG_NEGATE 57378 44 + 45 + /* Scanner context passed as 'scanner' to yyparse/yylex */ 46 + typedef struct Scanner { 47 + LexResult *lr; /* lex result, created on demand by yylex */ 48 + int pos; /* next token index to return */ 49 + char *buf; /* owned copy of input */ 50 + int len; 51 + char *filename; /* owned */ 52 + } Scanner; 53 + 54 + void *create_scanner_from_buffer(const char *buf, int len, const char *filename) { 55 + Scanner *s = calloc(1, sizeof(*s)); 56 + if (!s) return NULL; 57 + s->buf = malloc(len); 58 + if (!s->buf) { free(s); return NULL; } 59 + memcpy(s->buf, buf, len); 60 + s->len = len; 61 + s->pos = 0; 62 + s->lr = NULL; 63 + if (filename) { 64 + size_t n = strlen(filename) + 1; 65 + s->filename = malloc(n); 66 + if (s->filename) memcpy(s->filename, filename, n); 67 + } 68 + return s; 69 + } 70 + 71 + void destroy_scanner(void *scannerp) { 72 + if (!scannerp) return; 73 + Scanner *s = (Scanner*)scannerp; 74 + if (s->lr) freeLexResult(s->lr); 75 + free(s->buf); 76 + free(s->filename); 77 + free(s); 78 + } 79 + 80 + /* Translate legacy lexer token numbers to the parser's token enums. When the 81 + legacy token is an ASCII single-char (small value < 256), return it as-is. */ 82 + static int translate_token(int legacy) { 83 + switch (legacy) { 84 + case LEG_ASSERT_: return ASSERT_; 85 + case LEG_IF_: return IF_; 86 + case LEG_THEN: return THEN; 87 + case LEG_ELSE_: return ELSE_; 88 + case LEG_LET: return LET; 89 + case LEG_IN: return IN; 90 + case LEG_WITH: return WITH; 91 + case LEG_OR_: return OR_; 92 + case LEG_REC: return REC; 93 + case LEG_INHERIT: return INHERIT; 94 + case LEG_ELLIPSIS: return ELLIPSIS; 95 + case LEG_INTERP: return INTERP; 96 + case LEG_SPACE: return SPACE; 97 + case LEG_COMMENT: return COMMENT; 98 + case LEG_II: return II; 99 + case LEG_URI: return URI; 100 + case LEG_PATH: return PATH; 101 + case LEG_FLOAT: return FLOAT; 102 + case LEG_INT_: return INT_; 103 + case LEG_T_ID: return T_ID; 104 + case LEG_TEXT: return TEXT; 105 + case LEG_ARG_ID: return ARG_ID; 106 + case LEG_ARG_BRACKET: return ARG_BRACKET; 107 + case LEG_IMPL: return IMPL; 108 + case LEG_OR: return OR; 109 + case LEG_AND: return AND; 110 + case LEG_EQ: return EQ; 111 + case LEG_NEQ: return NEQ; 112 + case LEG_LEQ: return LEQ; 113 + case LEG_GEQ: return GEQ; 114 + case LEG_UPDATE: return UPDATE; 115 + case LEG_CONCAT: return CONCAT; 116 + case LEG_NEGATE: return NEGATE; 117 + default: 118 + if (legacy >= 0 && legacy < 256) return legacy; /* ASCII token */ 119 + return legacy; /* fallback (may be out of range) */ 120 + } 121 + } 122 + 123 + /* The parser expects yylex to fill YYSTYPE and return token numbers. 124 + We'll run the Ragel lexData once per input and then stream tokens from the 125 + resulting LexResult. yylval->token will be set to the token's start position 126 + (this mirrors the original grammar expecting integer token values). */ 127 + int yylex(YYSTYPE *yylval, void *scannerp) { 128 + if (!scannerp) return 0; 129 + Scanner *s = (Scanner*)scannerp; 130 + if (!s->lr) { 131 + s->lr = newLexResult(s->filename, s->len); 132 + if (!s->lr) { 133 + fprintf(stderr, "out of memory creating LexResult\n"); 134 + return 0; 135 + } 136 + int err = lexData(s->buf, s->len, s->lr); 137 + if (err) { 138 + fprintf(stderr, "lexing failed: %s\n", s->lr->errmsg ? s->lr->errmsg : "unknown"); 139 + return 0; 140 + } 141 + } 142 + if (s->pos >= (int)s->lr->ntokens) return 0; /* EOF */ 143 + lexerToken *t = &s->lr->tokens[s->pos]; 144 + int sym = translate_token(t->Sym); 145 + if (yylval) yylval->token = s->pos; /* return token index, not byte offset */ 146 + s->pos++; 147 + return sym; 148 + } 149 + 150 + /* Simple helper used by main.c to create/destroy scanner */ 151 + 152 + /* Keep these symbols available to other translation units */ 153 + 154 + void *create_scanner(const char *buf, int len, const char *filename) { 155 + return create_scanner_from_buffer(buf, len, filename); 156 + } 157 + 158 + void free_scanner(void *scanner) { 159 + destroy_scanner(scanner); 160 + } 161 + 162 + LexResult *scanner_lexresult(void *scanner) { 163 + if (!scanner) return NULL; 164 + Scanner *s = (Scanner*)scanner; 165 + return s->lr; 166 + }
+12
parser/lexer_adapter.h
··· 1 + #ifndef PARSER_LEXER_ADAPTER_H 2 + #define PARSER_LEXER_ADAPTER_H 3 + 4 + #include "lexer.h" 5 + 6 + void *create_scanner(const char *buf, int len, const char *filename); 7 + void free_scanner(void *scanner); 8 + 9 + /* Expose lexresult for inspection (lexer.h already defines LexResult) */ 10 + LexResult *scanner_lexresult(void *scanner); 11 + 12 + #endif /* PARSER_LEXER_ADAPTER_H */
+267
parser/lexer_helper.c
··· 1 + #include <stdio.h> 2 + #include <stdlib.h> 3 + #include <string.h> 4 + 5 + #include "lexer.h" 6 + #include "tokens.h" 7 + 8 + /* Portable strdup replacement */ 9 + static char *my_strdup(const char *s) { 10 + if (!s) return NULL; 11 + size_t n = strlen(s) + 1; 12 + char *p = malloc(n); 13 + if (!p) return NULL; 14 + memcpy(p, s, n); 15 + return p; 16 + } 17 + 18 + /* Capacity helpers */ 19 + static void ensure_tokens_capacity(LexResult *r) { 20 + if (r->ntokens >= r->ctokens) { 21 + size_t nc = r->ctokens ? r->ctokens * 2 : 64; 22 + lexerToken *t = realloc(r->tokens, nc * sizeof(lexerToken)); 23 + if (!t) return; /* OOM, keep old state */ 24 + r->tokens = t; 25 + r->ctokens = nc; 26 + } 27 + } 28 + 29 + static void ensure_comments_capacity(LexResult *r) { 30 + if (r->ncomments >= r->ccomments) { 31 + size_t nc = r->ccomments ? r->ccomments * 2 : 16; 32 + lexerToken *t = realloc(r->comments, nc * sizeof(lexerToken)); 33 + if (!t) return; 34 + r->comments = t; 35 + r->ccomments = nc; 36 + } 37 + } 38 + 39 + static void ensure_lines_capacity(LexResult *r) { 40 + if (r->nlines >= r->clines) { 41 + size_t nc = r->clines ? r->clines * 2 : 16; 42 + int *t = realloc(r->lines, nc * sizeof(int)); 43 + if (!t) return; 44 + r->lines = t; 45 + r->clines = nc; 46 + } 47 + } 48 + 49 + /* Return a newly allocated string for file:line:col: like legacy At() */ 50 + static char *lex_at(const LexResult *r, int offset) { 51 + if (!r) return NULL; 52 + const char *filename = r->filename ? r->filename : "(string)"; 53 + int line = 1; 54 + int col = offset + 1; 55 + if (r->nlines > 0) { 56 + int idx = 0; 57 + for (size_t i = 0; i < r->nlines; ++i) { 58 + if (r->lines[i] <= offset) idx = (int)i; else break; 59 + } 60 + line = idx + 1; 61 + col = offset - r->lines[idx] + 1; 62 + } 63 + char buf[512]; 64 + snprintf(buf, sizeof(buf), "%s:%d:%d: ", filename, line, col); 65 + return my_strdup(buf); 66 + } 67 + 68 + /* Map legacy token numbers to human names similar to Go symString. Returns a 69 + pointer to a static buffer for ASCII tokens or a static string for named tokens. */ 70 + const char *symString(int sym) { 71 + switch (sym) { 72 + case ASSERT_: return "assert"; 73 + case IF_: return "if"; 74 + case THEN: return "then"; 75 + case ELSE_: return "else"; 76 + case LET: return "let"; 77 + case IN: return "in"; 78 + case WITH: return "with"; 79 + case OR_: return "or"; 80 + case REC: return "rec"; 81 + case INHERIT: return "inherit"; 82 + case ELLIPSIS: return "..."; 83 + case INTERP: return "interp"; 84 + case SPACE: return "space"; 85 + case COMMENT: return "comment"; 86 + case II: return "ii"; 87 + case URI: return "uri"; 88 + case PATH: return "path"; 89 + case FLOAT: return "float"; 90 + case INT_: return "int"; 91 + case T_ID: return "id"; 92 + case TEXT: return "text"; 93 + case ARG_ID: return "argID"; 94 + case ARG_BRACKET: return "argBracket"; 95 + case IMPL: return "->"; 96 + case OR: return "||"; 97 + case AND: return "&&"; 98 + case EQ: return "=="; 99 + case NEQ: return "!="; 100 + case LEQ: return "<="; 101 + case GEQ: return ">="; 102 + case UPDATE: return "//"; 103 + case CONCAT: return "++"; 104 + case NEGATE: return "!"; 105 + default: { 106 + static char buf[8]; 107 + if (sym >= 0 && sym < 256) { 108 + int c = sym; 109 + buf[0] = '\''; 110 + buf[1] = (char)c; 111 + buf[2] = '\''; 112 + buf[3] = '\0'; 113 + return buf; 114 + } 115 + return "?"; 116 + } 117 + } 118 + } 119 + 120 + LexResult *newLexResult(const char *path, int size) { 121 + LexResult *r = calloc(1, sizeof(*r)); 122 + if (!r) return NULL; 123 + if (path) { 124 + r->filename = malloc(strlen(path) + 1); 125 + if (r->filename) memcpy(r->filename, path, strlen(path) + 1); 126 + } 127 + r->data = NULL; 128 + r->len = size; 129 + r->tokens = NULL; 130 + r->ntokens = r->ctokens = 0; 131 + r->comments = NULL; 132 + r->ncomments = r->ccomments = 0; 133 + r->lines = NULL; 134 + r->nlines = r->clines = 0; 135 + r->errmsg = NULL; 136 + /* ensure there is an initial line at offset 0 to match Go behavior */ 137 + ensure_lines_capacity(r); 138 + r->lines[r->nlines++] = 0; 139 + return r; 140 + } 141 + 142 + void freeLexResult(LexResult *r) { 143 + if (!r) return; 144 + free(r->filename); 145 + free(r->data); 146 + free(r->tokens); 147 + free(r->comments); 148 + free(r->lines); 149 + free(r->errmsg); 150 + free(r); 151 + } 152 + 153 + void lexresult_push_token(LexResult *r, int sym, int ts, int te) { 154 + ensure_tokens_capacity(r); 155 + r->tokens[r->ntokens].Sym = sym; 156 + r->tokens[r->ntokens].Pos = ts; 157 + r->tokens[r->ntokens].End = te; 158 + /* legacy Go lexer leaves Prev as zero (Go zero-value); keep same semantics */ 159 + r->tokens[r->ntokens].Prev = 0; 160 + r->ntokens++; 161 + } 162 + 163 + void lexresult_push_comment(LexResult *r, int sym, int ts, int te) { 164 + ensure_comments_capacity(r); 165 + r->comments[r->ncomments].Sym = sym; 166 + r->comments[r->ncomments].Pos = ts; 167 + r->comments[r->ncomments].End = te; 168 + r->comments[r->ncomments].Prev = 0; 169 + r->ncomments++; 170 + } 171 + 172 + void backrefs_push(Backrefs *s, int i, int fin) { 173 + if (s->n + 2 > s->c) { 174 + size_t nc = s->c ? s->c * 2 : 16; 175 + int *t = realloc(s->v, nc * sizeof(int)); 176 + if (!t) return; 177 + s->v = t; 178 + s->c = nc; 179 + } 180 + s->v[s->n++] = i; 181 + s->v[s->n++] = fin; 182 + } 183 + 184 + int backrefs_pop(Backrefs *s, int *i, int *fin) { 185 + if (s->n < 2) return 0; 186 + s->n -= 2; 187 + *fin = s->v[s->n+1]; 188 + *i = s->v[s->n]; 189 + return 1; 190 + } 191 + 192 + size_t backrefs_len(const Backrefs *s) { return s->n / 2; } 193 + void backrefs_free(Backrefs *s) { free(s->v); s->v = NULL; s->n = s->c = 0; } 194 + 195 + void tokenter_impl(int sym, int fin, LexResult *r, Backrefs *backrefs, int ts, int te) { 196 + backrefs_push(backrefs, (int)r->ntokens, fin); 197 + lexresult_push_token(r, sym, ts, te); 198 + } 199 + 200 + int tokleave_impl(int sym, LexResult *r, Backrefs *backrefs, int *top, int ts, int te) { 201 + lexresult_push_token(r, sym, ts, te); 202 + if (backrefs_len(backrefs) == 0) { 203 + if (r->errmsg) free(r->errmsg); 204 + r->errmsg = my_strdup("does not close anything"); 205 + return 0; 206 + } 207 + int iprev, prevsym; 208 + if (!backrefs_pop(backrefs, &iprev, &prevsym)) return 0; 209 + if (prevsym != sym) { 210 + /* construct error similar to legacy: "<file:line:col: >%s is not terminated" style */ 211 + char *at = lex_at(r, r->tokens[iprev].Pos); 212 + const char *name = symString(r->tokens[iprev].Sym); 213 + size_t n = 0; 214 + if (at) n += strlen(at); 215 + if (name) n += strlen(name); 216 + n += 32; 217 + char *msg = malloc(n); 218 + if (msg) { 219 + if (at) snprintf(msg, n, "%s%s does not close %s", at, "", name); 220 + else snprintf(msg, n, "does not close %s", name); 221 + } 222 + if (r->errmsg) free(r->errmsg); 223 + if (msg) r->errmsg = msg; 224 + free(at); 225 + return 0; 226 + } 227 + r->tokens[r->ntokens-1].Prev = iprev; 228 + return 1; 229 + } 230 + 231 + int tokarg_impl(LexResult *r, int ts, int te) { 232 + /* push token whose Sym is the byte at ts (mirrors legacy int(data[ts])) */ 233 + int sym = (unsigned char)r->data[ts]; 234 + lexresult_push_token(r, sym, ts, te); 235 + if (r->ntokens == 1) { 236 + if (r->errmsg) free(r->errmsg); 237 + r->errmsg = my_strdup("does not follow anything"); 238 + return 0; 239 + } 240 + int previdx = r->ntokens - 2; 241 + int prevsym = r->tokens[previdx].Sym; 242 + if (prevsym == T_ID || prevsym == ID) { 243 + r->tokens[previdx].Sym = ARG_ID; 244 + } else if (prevsym == '}') { 245 + int prevprev = r->tokens[previdx].Prev; 246 + if (prevprev >= 0) r->tokens[prevprev].Sym = ARG_BRACKET; 247 + } else { 248 + if (r->errmsg) free(r->errmsg); 249 + r->errmsg = my_strdup("does not follow an argument of a function"); 250 + return 0; 251 + } 252 + return 1; 253 + } 254 + 255 + void add_lines_impl(LexResult *r, int ts, int te) { 256 + for (int i = ts; i < te; i++) { 257 + if ((unsigned char)r->data[i] == '\n') { 258 + ensure_lines_capacity(r); 259 + r->lines[r->nlines++] = i; 260 + } 261 + } 262 + } 263 + 264 + void add_line_impl(LexResult *r, int ts) { 265 + ensure_lines_capacity(r); 266 + r->lines[r->nlines++] = ts; 267 + }
+2424
parser/machine.c
··· 1 + 2 + #line 1 "parser/machine.rl" 3 + // compile-command: "ragel -Z -G2 machine.rl" 4 + 5 + /* C port of the Ragel lexer (ported from legacy Go). This file is pure C and 6 + uses the helpers declared in parser/lexer.h. */ 7 + 8 + #include <stdlib.h> 9 + #include <string.h> 10 + #include "lexer.h" 11 + #include "tokens.h" 12 + 13 + #define maxstack 64 14 + 15 + 16 + #line 102 "parser/machine.rl" 17 + 18 + 19 + 20 + #line 16 "parser/machine.c" 21 + static const int expr_start = 22; 22 + static const int expr_first_final = 22; 23 + static const int expr_error = 0; 24 + 25 + static const int expr_en_qstring = 79; 26 + static const int expr_en_istring = 82; 27 + static const int expr_en_expr = 22; 28 + 29 + 30 + #line 105 "parser/machine.rl" 31 + 32 + /* C lexical wrapper generated by Ragel */ 33 + 34 + int lexData(const char *data, int len, LexResult *r) { 35 + int cs = 0, act = 0; 36 + const char *p = data; 37 + const char *pe = data + len; 38 + const char *eof = pe; 39 + const char *ts = NULL, *te = NULL; 40 + int top = 0; 41 + int stack[maxstack]; 42 + Backrefs backrefs = { NULL, 0, 0 }; 43 + 44 + /* helper to set an error message (allocated) */ 45 + void set_err(const char *msg) { 46 + if (r->errmsg) { free(r->errmsg); r->errmsg = NULL; } 47 + size_t m = strlen(msg) + 1; 48 + r->errmsg = malloc(m); 49 + if (r->errmsg) memcpy(r->errmsg, msg, m); 50 + } 51 + 52 + /* nostack check used by actions; returns 1 on error (and sets r->errmsg) */ 53 + #define nostack() ( (top) >= maxstack ? (set_err("exceeds recursion limit"), 1) : 0 ) 54 + 55 + /* append or set r->data */ 56 + if (r->data == NULL) { 57 + r->data = malloc(len); 58 + if (!r->data) { set_err("out of memory"); return 1; } 59 + memcpy(r->data, data, len); 60 + r->len = len; 61 + } else { 62 + char *nd = realloc(r->data, r->len + len); 63 + if (!nd) { set_err("out of memory"); return 1; } 64 + r->data = nd; 65 + memcpy(r->data + r->len, data, len); 66 + r->len += len; 67 + } 68 + 69 + 70 + #line 62 "parser/machine.c" 71 + { 72 + cs = expr_start; 73 + top = 0; 74 + ts = 0; 75 + te = 0; 76 + act = 0; 77 + } 78 + 79 + #line 144 "parser/machine.rl" 80 + (void)expr_first_final; (void)expr_error; (void)expr_en_qstring; (void)expr_en_istring; (void)expr_en_expr; 81 + 82 + /* Ragel exec block will use the macros (tok, tokenter, tokleave, tokarg, add_lines, add_line) 83 + declared in parser/lexer.h and expect local variables ts, te, top, backrefs, data, p, pe, cs. */ 84 + 85 + 86 + 87 + #line 75 "parser/machine.c" 88 + { 89 + if ( p == pe ) 90 + goto _test_eof; 91 + goto _resume; 92 + 93 + _again: 94 + switch ( cs ) { 95 + case 22: goto st22; 96 + case 23: goto st23; 97 + case 1: goto st1; 98 + case 24: goto st24; 99 + case 2: goto st2; 100 + case 3: goto st3; 101 + case 25: goto st25; 102 + case 26: goto st26; 103 + case 27: goto st27; 104 + case 28: goto st28; 105 + case 29: goto st29; 106 + case 30: goto st30; 107 + case 31: goto st31; 108 + case 32: goto st32; 109 + case 33: goto st33; 110 + case 4: goto st4; 111 + case 5: goto st5; 112 + case 34: goto st34; 113 + case 35: goto st35; 114 + case 36: goto st36; 115 + case 37: goto st37; 116 + case 6: goto st6; 117 + case 38: goto st38; 118 + case 7: goto st7; 119 + case 8: goto st8; 120 + case 39: goto st39; 121 + case 40: goto st40; 122 + case 9: goto st9; 123 + case 10: goto st10; 124 + case 41: goto st41; 125 + case 42: goto st42; 126 + case 43: goto st43; 127 + case 44: goto st44; 128 + case 45: goto st45; 129 + case 11: goto st11; 130 + case 12: goto st12; 131 + case 46: goto st46; 132 + case 47: goto st47; 133 + case 48: goto st48; 134 + case 13: goto st13; 135 + case 14: goto st14; 136 + case 49: goto st49; 137 + case 50: goto st50; 138 + case 51: goto st51; 139 + case 52: goto st52; 140 + case 53: goto st53; 141 + case 54: goto st54; 142 + case 55: goto st55; 143 + case 56: goto st56; 144 + case 57: goto st57; 145 + case 58: goto st58; 146 + case 59: goto st59; 147 + case 60: goto st60; 148 + case 61: goto st61; 149 + case 62: goto st62; 150 + case 63: goto st63; 151 + case 64: goto st64; 152 + case 65: goto st65; 153 + case 66: goto st66; 154 + case 67: goto st67; 155 + case 68: goto st68; 156 + case 69: goto st69; 157 + case 70: goto st70; 158 + case 71: goto st71; 159 + case 72: goto st72; 160 + case 73: goto st73; 161 + case 74: goto st74; 162 + case 75: goto st75; 163 + case 76: goto st76; 164 + case 15: goto st15; 165 + case 77: goto st77; 166 + case 78: goto st78; 167 + case 79: goto st79; 168 + case 80: goto st80; 169 + case 16: goto st16; 170 + case 17: goto st17; 171 + case 81: goto st81; 172 + case 82: goto st82; 173 + case 83: goto st83; 174 + case 18: goto st18; 175 + case 19: goto st19; 176 + case 20: goto st20; 177 + case 21: goto st21; 178 + case 84: goto st84; 179 + case 85: goto st85; 180 + case 86: goto st86; 181 + case 0: goto st0; 182 + default: break; 183 + } 184 + 185 + if ( ++p == pe ) 186 + goto _test_eof; 187 + _resume: 188 + switch ( cs ) 189 + { 190 + tr0: 191 + #line 98 "parser/machine.rl" 192 + {{p = ((te))-1;}{ tok((int)(*ts), r); }} 193 + goto st22; 194 + tr2: 195 + #line 72 "parser/machine.rl" 196 + {{p = ((te))-1;}{ tok(FLOAT, r); }} 197 + goto st22; 198 + tr5: 199 + #line 1 "NONE" 200 + { switch( act ) { 201 + case 9: 202 + {{p = ((te))-1;} tok(ASSERT_, r); } 203 + break; 204 + case 10: 205 + {{p = ((te))-1;} tok(ELSE_, r); } 206 + break; 207 + case 11: 208 + {{p = ((te))-1;} tok(IF_, r); } 209 + break; 210 + case 12: 211 + {{p = ((te))-1;} tok(IN, r); } 212 + break; 213 + case 13: 214 + {{p = ((te))-1;} tok(INHERIT, r); } 215 + break; 216 + case 14: 217 + {{p = ((te))-1;} tok(LET, r); } 218 + break; 219 + case 15: 220 + {{p = ((te))-1;} tok(OR_, r); } 221 + break; 222 + case 16: 223 + {{p = ((te))-1;} tok(REC, r); } 224 + break; 225 + case 17: 226 + {{p = ((te))-1;} tok(THEN, r); } 227 + break; 228 + case 18: 229 + {{p = ((te))-1;} tok(WITH, r); } 230 + break; 231 + case 27: 232 + {{p = ((te))-1;} tok(FLOAT, r); } 233 + break; 234 + case 28: 235 + {{p = ((te))-1;} tok(INT_, r); } 236 + break; 237 + case 29: 238 + {{p = ((te))-1;} tok(ID, r); } 239 + break; 240 + case 30: 241 + {{p = ((te))-1;} tok(ELLIPSIS, r); } 242 + break; 243 + case 39: 244 + {{p = ((te))-1;} tok(CONCAT, r); } 245 + break; 246 + case 48: 247 + {{p = ((te))-1;} tok((int)(*ts), r); } 248 + break; 249 + } 250 + } 251 + goto st22; 252 + tr14: 253 + #line 67 "parser/machine.rl" 254 + {te = p+1;{ tokcomment(COMMENT, r); add_lines(r, ts, te); }} 255 + goto st22; 256 + tr17: 257 + #line 71 "parser/machine.rl" 258 + {te = p+1;{ tok(PATH, r); }} 259 + goto st22; 260 + tr30: 261 + #line 98 "parser/machine.rl" 262 + {te = p+1;{ tok((int)(*ts), r); }} 263 + goto st22; 264 + tr33: 265 + #line 65 "parser/machine.rl" 266 + {te = p+1;{ add_line(r, ts); }} 267 + goto st22; 268 + tr35: 269 + #line 87 "parser/machine.rl" 270 + {te = p+1;{ tokenter('"', '"', r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 22;goto st79;}} }} 271 + goto st22; 272 + tr40: 273 + #line 91 "parser/machine.rl" 274 + {te = p+1;{ tokenter('(', ')', r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 22;goto st22;}} }} 275 + goto st22; 276 + tr41: 277 + #line 94 "parser/machine.rl" 278 + {te = p+1;{ if (!tokleave((int)(*ts), r)) return 1; {cs = stack[--top];goto _again;} }} 279 + goto st22; 280 + tr48: 281 + #line 96 "parser/machine.rl" 282 + {te = p+1;{ if (!tokarg(r)) return 1; }} 283 + goto st22; 284 + tr53: 285 + #line 92 "parser/machine.rl" 286 + {te = p+1;{ tokenter('[', ']', r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 22;goto st22;}} }} 287 + goto st22; 288 + tr63: 289 + #line 93 "parser/machine.rl" 290 + {te = p+1;{ tokenter('{', '}', r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 22;goto st22;}} }} 291 + goto st22; 292 + tr66: 293 + #line 98 "parser/machine.rl" 294 + {te = p;p--;{ tok((int)(*ts), r); }} 295 + goto st22; 296 + tr68: 297 + #line 72 "parser/machine.rl" 298 + {te = p;p--;{ tok(FLOAT, r); }} 299 + goto st22; 300 + tr70: 301 + #line 64 "parser/machine.rl" 302 + {te = p;p--;} 303 + goto st22; 304 + tr71: 305 + #line 81 "parser/machine.rl" 306 + {te = p+1;{ tok(NEQ, r); }} 307 + goto st22; 308 + tr72: 309 + #line 66 "parser/machine.rl" 310 + {te = p;p--;{ tokcomment(COMMENT, r); }} 311 + goto st22; 312 + tr73: 313 + #line 90 "parser/machine.rl" 314 + {te = p+1;{ tokenter(INTERP, '}', r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 22;goto st22;}} }} 315 + goto st22; 316 + tr74: 317 + #line 79 "parser/machine.rl" 318 + {te = p+1;{ tok(AND, r); }} 319 + goto st22; 320 + tr75: 321 + #line 88 "parser/machine.rl" 322 + {te = p+1;{ tokenter(II, II, r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 22;goto st82;}} }} 323 + goto st22; 324 + tr77: 325 + #line 69 "parser/machine.rl" 326 + {te = p;p--;{ tok(PATH, r); }} 327 + goto st22; 328 + tr79: 329 + #line 77 "parser/machine.rl" 330 + {te = p+1;{ tok(IMPL, r); }} 331 + goto st22; 332 + tr83: 333 + #line 84 "parser/machine.rl" 334 + {te = p+1;{ tok(UPDATE, r); }} 335 + goto st22; 336 + tr84: 337 + #line 73 "parser/machine.rl" 338 + {te = p;p--;{ tok(INT_, r); }} 339 + goto st22; 340 + tr86: 341 + #line 74 "parser/machine.rl" 342 + {te = p;p--;{ tok(ID, r); }} 343 + goto st22; 344 + tr87: 345 + #line 82 "parser/machine.rl" 346 + {te = p+1;{ tok(LEQ, r); }} 347 + goto st22; 348 + tr88: 349 + #line 80 "parser/machine.rl" 350 + {te = p+1;{ tok(EQ, r); }} 351 + goto st22; 352 + tr89: 353 + #line 83 "parser/machine.rl" 354 + {te = p+1;{ tok(GEQ, r); }} 355 + goto st22; 356 + tr90: 357 + #line 68 "parser/machine.rl" 358 + {te = p;p--;{ tok(URI, r); }} 359 + goto st22; 360 + tr101: 361 + #line 56 "parser/machine.rl" 362 + {te = p;p--;{ tok(IN, r); }} 363 + goto st22; 364 + tr118: 365 + #line 78 "parser/machine.rl" 366 + {te = p+1;{ tok(OR, r); }} 367 + goto st22; 368 + tr120: 369 + #line 70 "parser/machine.rl" 370 + {te = p;p--;{ tok(PATH, r); }} 371 + goto st22; 372 + st22: 373 + #line 1 "NONE" 374 + {ts = 0;} 375 + if ( ++p == pe ) 376 + goto _test_eof22; 377 + case 22: 378 + #line 1 "NONE" 379 + {ts = p;} 380 + #line 332 "parser/machine.c" 381 + switch( (*p) ) { 382 + case 0: goto tr31; 383 + case 9: goto st26; 384 + case 10: goto tr33; 385 + case 13: goto st26; 386 + case 32: goto st26; 387 + case 33: goto st27; 388 + case 34: goto tr35; 389 + case 35: goto st28; 390 + case 36: goto st29; 391 + case 38: goto st30; 392 + case 39: goto st31; 393 + case 40: goto tr40; 394 + case 41: goto tr41; 395 + case 43: goto tr42; 396 + case 45: goto tr43; 397 + case 46: goto tr44; 398 + case 47: goto tr45; 399 + case 48: goto tr46; 400 + case 58: goto tr48; 401 + case 60: goto tr49; 402 + case 61: goto st46; 403 + case 62: goto st47; 404 + case 64: goto tr48; 405 + case 91: goto tr53; 406 + case 93: goto tr41; 407 + case 95: goto tr54; 408 + case 97: goto tr55; 409 + case 101: goto tr56; 410 + case 105: goto tr57; 411 + case 108: goto tr58; 412 + case 111: goto tr59; 413 + case 114: goto tr60; 414 + case 116: goto tr61; 415 + case 119: goto tr62; 416 + case 123: goto tr63; 417 + case 124: goto st75; 418 + case 125: goto tr41; 419 + case 126: goto tr65; 420 + } 421 + if ( (*p) < 65 ) { 422 + if ( 49 <= (*p) && (*p) <= 57 ) 423 + goto tr47; 424 + } else if ( (*p) > 90 ) { 425 + if ( 98 <= (*p) && (*p) <= 122 ) 426 + goto tr52; 427 + } else 428 + goto tr52; 429 + goto tr30; 430 + tr31: 431 + #line 1 "NONE" 432 + {te = p+1;} 433 + goto st23; 434 + st23: 435 + if ( ++p == pe ) 436 + goto _test_eof23; 437 + case 23: 438 + #line 388 "parser/machine.c" 439 + if ( (*p) == 46 ) 440 + goto st1; 441 + goto tr66; 442 + st1: 443 + if ( ++p == pe ) 444 + goto _test_eof1; 445 + case 1: 446 + if ( 48 <= (*p) && (*p) <= 57 ) 447 + goto tr1; 448 + goto tr0; 449 + tr1: 450 + #line 1 "NONE" 451 + {te = p+1;} 452 + goto st24; 453 + st24: 454 + if ( ++p == pe ) 455 + goto _test_eof24; 456 + case 24: 457 + #line 405 "parser/machine.c" 458 + switch( (*p) ) { 459 + case 69: goto st2; 460 + case 101: goto st2; 461 + } 462 + if ( 48 <= (*p) && (*p) <= 57 ) 463 + goto tr1; 464 + goto tr68; 465 + st2: 466 + if ( ++p == pe ) 467 + goto _test_eof2; 468 + case 2: 469 + switch( (*p) ) { 470 + case 43: goto st3; 471 + case 45: goto st3; 472 + } 473 + if ( 48 <= (*p) && (*p) <= 57 ) 474 + goto st25; 475 + goto tr2; 476 + st3: 477 + if ( ++p == pe ) 478 + goto _test_eof3; 479 + case 3: 480 + if ( 48 <= (*p) && (*p) <= 57 ) 481 + goto st25; 482 + goto tr2; 483 + st25: 484 + if ( ++p == pe ) 485 + goto _test_eof25; 486 + case 25: 487 + if ( 48 <= (*p) && (*p) <= 57 ) 488 + goto st25; 489 + goto tr68; 490 + st26: 491 + if ( ++p == pe ) 492 + goto _test_eof26; 493 + case 26: 494 + switch( (*p) ) { 495 + case 9: goto st26; 496 + case 13: goto st26; 497 + case 32: goto st26; 498 + } 499 + goto tr70; 500 + st27: 501 + if ( ++p == pe ) 502 + goto _test_eof27; 503 + case 27: 504 + if ( (*p) == 61 ) 505 + goto tr71; 506 + goto tr66; 507 + st28: 508 + if ( ++p == pe ) 509 + goto _test_eof28; 510 + case 28: 511 + switch( (*p) ) { 512 + case 10: goto tr72; 513 + case 13: goto tr72; 514 + } 515 + goto st28; 516 + st29: 517 + if ( ++p == pe ) 518 + goto _test_eof29; 519 + case 29: 520 + if ( (*p) == 123 ) 521 + goto tr73; 522 + goto tr66; 523 + st30: 524 + if ( ++p == pe ) 525 + goto _test_eof30; 526 + case 30: 527 + if ( (*p) == 38 ) 528 + goto tr74; 529 + goto tr66; 530 + st31: 531 + if ( ++p == pe ) 532 + goto _test_eof31; 533 + case 31: 534 + if ( (*p) == 39 ) 535 + goto tr75; 536 + goto tr66; 537 + tr42: 538 + #line 1 "NONE" 539 + {te = p+1;} 540 + #line 98 "parser/machine.rl" 541 + {act = 48;} 542 + goto st32; 543 + st32: 544 + if ( ++p == pe ) 545 + goto _test_eof32; 546 + case 32: 547 + #line 492 "parser/machine.c" 548 + switch( (*p) ) { 549 + case 43: goto tr76; 550 + case 47: goto st5; 551 + case 95: goto st4; 552 + } 553 + if ( (*p) < 65 ) { 554 + if ( 45 <= (*p) && (*p) <= 57 ) 555 + goto st4; 556 + } else if ( (*p) > 90 ) { 557 + if ( 97 <= (*p) && (*p) <= 122 ) 558 + goto st4; 559 + } else 560 + goto st4; 561 + goto tr66; 562 + tr9: 563 + #line 1 "NONE" 564 + {te = p+1;} 565 + #line 76 "parser/machine.rl" 566 + {act = 30;} 567 + goto st33; 568 + tr76: 569 + #line 1 "NONE" 570 + {te = p+1;} 571 + #line 85 "parser/machine.rl" 572 + {act = 39;} 573 + goto st33; 574 + st33: 575 + if ( ++p == pe ) 576 + goto _test_eof33; 577 + case 33: 578 + #line 518 "parser/machine.c" 579 + switch( (*p) ) { 580 + case 43: goto st4; 581 + case 47: goto st5; 582 + case 95: goto st4; 583 + } 584 + if ( (*p) < 65 ) { 585 + if ( 45 <= (*p) && (*p) <= 57 ) 586 + goto st4; 587 + } else if ( (*p) > 90 ) { 588 + if ( 97 <= (*p) && (*p) <= 122 ) 589 + goto st4; 590 + } else 591 + goto st4; 592 + goto tr5; 593 + st4: 594 + if ( ++p == pe ) 595 + goto _test_eof4; 596 + case 4: 597 + switch( (*p) ) { 598 + case 43: goto st4; 599 + case 47: goto st5; 600 + case 95: goto st4; 601 + } 602 + if ( (*p) < 65 ) { 603 + if ( 45 <= (*p) && (*p) <= 57 ) 604 + goto st4; 605 + } else if ( (*p) > 90 ) { 606 + if ( 97 <= (*p) && (*p) <= 122 ) 607 + goto st4; 608 + } else 609 + goto st4; 610 + goto tr5; 611 + st5: 612 + if ( ++p == pe ) 613 + goto _test_eof5; 614 + case 5: 615 + switch( (*p) ) { 616 + case 43: goto st34; 617 + case 95: goto st34; 618 + } 619 + if ( (*p) < 48 ) { 620 + if ( 45 <= (*p) && (*p) <= 46 ) 621 + goto st34; 622 + } else if ( (*p) > 57 ) { 623 + if ( (*p) > 90 ) { 624 + if ( 97 <= (*p) && (*p) <= 122 ) 625 + goto st34; 626 + } else if ( (*p) >= 65 ) 627 + goto st34; 628 + } else 629 + goto st34; 630 + goto tr5; 631 + st34: 632 + if ( ++p == pe ) 633 + goto _test_eof34; 634 + case 34: 635 + switch( (*p) ) { 636 + case 43: goto st34; 637 + case 47: goto st35; 638 + case 95: goto st34; 639 + } 640 + if ( (*p) < 65 ) { 641 + if ( 45 <= (*p) && (*p) <= 57 ) 642 + goto st34; 643 + } else if ( (*p) > 90 ) { 644 + if ( 97 <= (*p) && (*p) <= 122 ) 645 + goto st34; 646 + } else 647 + goto st34; 648 + goto tr77; 649 + st35: 650 + if ( ++p == pe ) 651 + goto _test_eof35; 652 + case 35: 653 + switch( (*p) ) { 654 + case 43: goto st34; 655 + case 95: goto st34; 656 + } 657 + if ( (*p) < 48 ) { 658 + if ( 45 <= (*p) && (*p) <= 46 ) 659 + goto st34; 660 + } else if ( (*p) > 57 ) { 661 + if ( (*p) > 90 ) { 662 + if ( 97 <= (*p) && (*p) <= 122 ) 663 + goto st34; 664 + } else if ( (*p) >= 65 ) 665 + goto st34; 666 + } else 667 + goto st34; 668 + goto tr77; 669 + tr43: 670 + #line 1 "NONE" 671 + {te = p+1;} 672 + #line 98 "parser/machine.rl" 673 + {act = 48;} 674 + goto st36; 675 + st36: 676 + if ( ++p == pe ) 677 + goto _test_eof36; 678 + case 36: 679 + #line 616 "parser/machine.c" 680 + switch( (*p) ) { 681 + case 43: goto st4; 682 + case 47: goto st5; 683 + case 62: goto tr79; 684 + case 95: goto st4; 685 + } 686 + if ( (*p) < 65 ) { 687 + if ( 45 <= (*p) && (*p) <= 57 ) 688 + goto st4; 689 + } else if ( (*p) > 90 ) { 690 + if ( 97 <= (*p) && (*p) <= 122 ) 691 + goto st4; 692 + } else 693 + goto st4; 694 + goto tr66; 695 + tr44: 696 + #line 1 "NONE" 697 + {te = p+1;} 698 + #line 98 "parser/machine.rl" 699 + {act = 48;} 700 + goto st37; 701 + st37: 702 + if ( ++p == pe ) 703 + goto _test_eof37; 704 + case 37: 705 + #line 639 "parser/machine.c" 706 + switch( (*p) ) { 707 + case 43: goto st4; 708 + case 45: goto st4; 709 + case 46: goto st6; 710 + case 47: goto st5; 711 + case 95: goto st4; 712 + } 713 + if ( (*p) < 65 ) { 714 + if ( 48 <= (*p) && (*p) <= 57 ) 715 + goto tr81; 716 + } else if ( (*p) > 90 ) { 717 + if ( 97 <= (*p) && (*p) <= 122 ) 718 + goto st4; 719 + } else 720 + goto st4; 721 + goto tr66; 722 + st6: 723 + if ( ++p == pe ) 724 + goto _test_eof6; 725 + case 6: 726 + switch( (*p) ) { 727 + case 43: goto st4; 728 + case 46: goto tr9; 729 + case 47: goto st5; 730 + case 95: goto st4; 731 + } 732 + if ( (*p) < 65 ) { 733 + if ( 45 <= (*p) && (*p) <= 57 ) 734 + goto st4; 735 + } else if ( (*p) > 90 ) { 736 + if ( 97 <= (*p) && (*p) <= 122 ) 737 + goto st4; 738 + } else 739 + goto st4; 740 + goto tr0; 741 + tr81: 742 + #line 1 "NONE" 743 + {te = p+1;} 744 + #line 72 "parser/machine.rl" 745 + {act = 27;} 746 + goto st38; 747 + st38: 748 + if ( ++p == pe ) 749 + goto _test_eof38; 750 + case 38: 751 + #line 682 "parser/machine.c" 752 + switch( (*p) ) { 753 + case 43: goto st4; 754 + case 47: goto st5; 755 + case 69: goto st7; 756 + case 95: goto st4; 757 + case 101: goto st7; 758 + } 759 + if ( (*p) < 48 ) { 760 + if ( 45 <= (*p) && (*p) <= 46 ) 761 + goto st4; 762 + } else if ( (*p) > 57 ) { 763 + if ( (*p) > 90 ) { 764 + if ( 97 <= (*p) && (*p) <= 122 ) 765 + goto st4; 766 + } else if ( (*p) >= 65 ) 767 + goto st4; 768 + } else 769 + goto tr81; 770 + goto tr68; 771 + st7: 772 + if ( ++p == pe ) 773 + goto _test_eof7; 774 + case 7: 775 + switch( (*p) ) { 776 + case 43: goto st8; 777 + case 45: goto st8; 778 + case 46: goto st4; 779 + case 47: goto st5; 780 + case 95: goto st4; 781 + } 782 + if ( (*p) < 65 ) { 783 + if ( 48 <= (*p) && (*p) <= 57 ) 784 + goto tr11; 785 + } else if ( (*p) > 90 ) { 786 + if ( 97 <= (*p) && (*p) <= 122 ) 787 + goto st4; 788 + } else 789 + goto st4; 790 + goto tr2; 791 + st8: 792 + if ( ++p == pe ) 793 + goto _test_eof8; 794 + case 8: 795 + switch( (*p) ) { 796 + case 43: goto st4; 797 + case 47: goto st5; 798 + case 95: goto st4; 799 + } 800 + if ( (*p) < 48 ) { 801 + if ( 45 <= (*p) && (*p) <= 46 ) 802 + goto st4; 803 + } else if ( (*p) > 57 ) { 804 + if ( (*p) > 90 ) { 805 + if ( 97 <= (*p) && (*p) <= 122 ) 806 + goto st4; 807 + } else if ( (*p) >= 65 ) 808 + goto st4; 809 + } else 810 + goto tr11; 811 + goto tr2; 812 + tr11: 813 + #line 1 "NONE" 814 + {te = p+1;} 815 + #line 72 "parser/machine.rl" 816 + {act = 27;} 817 + goto st39; 818 + st39: 819 + if ( ++p == pe ) 820 + goto _test_eof39; 821 + case 39: 822 + #line 750 "parser/machine.c" 823 + switch( (*p) ) { 824 + case 43: goto st4; 825 + case 47: goto st5; 826 + case 95: goto st4; 827 + } 828 + if ( (*p) < 48 ) { 829 + if ( 45 <= (*p) && (*p) <= 46 ) 830 + goto st4; 831 + } else if ( (*p) > 57 ) { 832 + if ( (*p) > 90 ) { 833 + if ( 97 <= (*p) && (*p) <= 122 ) 834 + goto st4; 835 + } else if ( (*p) >= 65 ) 836 + goto st4; 837 + } else 838 + goto tr11; 839 + goto tr68; 840 + tr45: 841 + #line 1 "NONE" 842 + {te = p+1;} 843 + goto st40; 844 + st40: 845 + if ( ++p == pe ) 846 + goto _test_eof40; 847 + case 40: 848 + #line 774 "parser/machine.c" 849 + switch( (*p) ) { 850 + case 42: goto st9; 851 + case 43: goto st34; 852 + case 47: goto tr83; 853 + case 95: goto st34; 854 + } 855 + if ( (*p) < 65 ) { 856 + if ( 45 <= (*p) && (*p) <= 57 ) 857 + goto st34; 858 + } else if ( (*p) > 90 ) { 859 + if ( 97 <= (*p) && (*p) <= 122 ) 860 + goto st34; 861 + } else 862 + goto st34; 863 + goto tr66; 864 + st9: 865 + if ( ++p == pe ) 866 + goto _test_eof9; 867 + case 9: 868 + if ( (*p) == 42 ) 869 + goto st10; 870 + goto st9; 871 + st10: 872 + if ( ++p == pe ) 873 + goto _test_eof10; 874 + case 10: 875 + switch( (*p) ) { 876 + case 42: goto st10; 877 + case 47: goto tr14; 878 + } 879 + goto st9; 880 + tr46: 881 + #line 1 "NONE" 882 + {te = p+1;} 883 + #line 73 "parser/machine.rl" 884 + {act = 28;} 885 + goto st41; 886 + st41: 887 + if ( ++p == pe ) 888 + goto _test_eof41; 889 + case 41: 890 + #line 813 "parser/machine.c" 891 + switch( (*p) ) { 892 + case 39: goto st42; 893 + case 43: goto st4; 894 + case 45: goto tr54; 895 + case 46: goto st4; 896 + case 47: goto st5; 897 + case 95: goto tr54; 898 + } 899 + if ( (*p) < 65 ) { 900 + if ( 48 <= (*p) && (*p) <= 57 ) 901 + goto tr46; 902 + } else if ( (*p) > 90 ) { 903 + if ( 97 <= (*p) && (*p) <= 122 ) 904 + goto tr54; 905 + } else 906 + goto tr54; 907 + goto tr84; 908 + st42: 909 + if ( ++p == pe ) 910 + goto _test_eof42; 911 + case 42: 912 + switch( (*p) ) { 913 + case 39: goto st42; 914 + case 45: goto st42; 915 + case 95: goto st42; 916 + } 917 + if ( (*p) < 65 ) { 918 + if ( 48 <= (*p) && (*p) <= 57 ) 919 + goto st42; 920 + } else if ( (*p) > 90 ) { 921 + if ( 97 <= (*p) && (*p) <= 122 ) 922 + goto st42; 923 + } else 924 + goto st42; 925 + goto tr86; 926 + tr54: 927 + #line 1 "NONE" 928 + {te = p+1;} 929 + #line 74 "parser/machine.rl" 930 + {act = 29;} 931 + goto st43; 932 + st43: 933 + if ( ++p == pe ) 934 + goto _test_eof43; 935 + case 43: 936 + #line 856 "parser/machine.c" 937 + switch( (*p) ) { 938 + case 39: goto st42; 939 + case 43: goto st4; 940 + case 46: goto st4; 941 + case 47: goto st5; 942 + case 95: goto tr54; 943 + } 944 + if ( (*p) < 65 ) { 945 + if ( 45 <= (*p) && (*p) <= 57 ) 946 + goto tr54; 947 + } else if ( (*p) > 90 ) { 948 + if ( 97 <= (*p) && (*p) <= 122 ) 949 + goto tr54; 950 + } else 951 + goto tr54; 952 + goto tr86; 953 + tr47: 954 + #line 1 "NONE" 955 + {te = p+1;} 956 + #line 73 "parser/machine.rl" 957 + {act = 28;} 958 + goto st44; 959 + st44: 960 + if ( ++p == pe ) 961 + goto _test_eof44; 962 + case 44: 963 + #line 880 "parser/machine.c" 964 + switch( (*p) ) { 965 + case 39: goto st42; 966 + case 43: goto st4; 967 + case 45: goto tr54; 968 + case 46: goto tr81; 969 + case 47: goto st5; 970 + case 95: goto tr54; 971 + } 972 + if ( (*p) < 65 ) { 973 + if ( 48 <= (*p) && (*p) <= 57 ) 974 + goto tr47; 975 + } else if ( (*p) > 90 ) { 976 + if ( 97 <= (*p) && (*p) <= 122 ) 977 + goto tr54; 978 + } else 979 + goto tr54; 980 + goto tr84; 981 + tr49: 982 + #line 1 "NONE" 983 + {te = p+1;} 984 + goto st45; 985 + st45: 986 + if ( ++p == pe ) 987 + goto _test_eof45; 988 + case 45: 989 + #line 904 "parser/machine.c" 990 + switch( (*p) ) { 991 + case 43: goto st11; 992 + case 61: goto tr87; 993 + case 95: goto st11; 994 + } 995 + if ( (*p) < 48 ) { 996 + if ( 45 <= (*p) && (*p) <= 46 ) 997 + goto st11; 998 + } else if ( (*p) > 57 ) { 999 + if ( (*p) > 90 ) { 1000 + if ( 97 <= (*p) && (*p) <= 122 ) 1001 + goto st11; 1002 + } else if ( (*p) >= 65 ) 1003 + goto st11; 1004 + } else 1005 + goto st11; 1006 + goto tr66; 1007 + st11: 1008 + if ( ++p == pe ) 1009 + goto _test_eof11; 1010 + case 11: 1011 + switch( (*p) ) { 1012 + case 43: goto st11; 1013 + case 47: goto st12; 1014 + case 62: goto tr17; 1015 + case 95: goto st11; 1016 + } 1017 + if ( (*p) < 65 ) { 1018 + if ( 45 <= (*p) && (*p) <= 57 ) 1019 + goto st11; 1020 + } else if ( (*p) > 90 ) { 1021 + if ( 97 <= (*p) && (*p) <= 122 ) 1022 + goto st11; 1023 + } else 1024 + goto st11; 1025 + goto tr0; 1026 + st12: 1027 + if ( ++p == pe ) 1028 + goto _test_eof12; 1029 + case 12: 1030 + switch( (*p) ) { 1031 + case 43: goto st11; 1032 + case 95: goto st11; 1033 + } 1034 + if ( (*p) < 48 ) { 1035 + if ( 45 <= (*p) && (*p) <= 46 ) 1036 + goto st11; 1037 + } else if ( (*p) > 57 ) { 1038 + if ( (*p) > 90 ) { 1039 + if ( 97 <= (*p) && (*p) <= 122 ) 1040 + goto st11; 1041 + } else if ( (*p) >= 65 ) 1042 + goto st11; 1043 + } else 1044 + goto st11; 1045 + goto tr0; 1046 + st46: 1047 + if ( ++p == pe ) 1048 + goto _test_eof46; 1049 + case 46: 1050 + if ( (*p) == 61 ) 1051 + goto tr88; 1052 + goto tr66; 1053 + st47: 1054 + if ( ++p == pe ) 1055 + goto _test_eof47; 1056 + case 47: 1057 + if ( (*p) == 61 ) 1058 + goto tr89; 1059 + goto tr66; 1060 + tr52: 1061 + #line 1 "NONE" 1062 + {te = p+1;} 1063 + #line 74 "parser/machine.rl" 1064 + {act = 29;} 1065 + goto st48; 1066 + tr95: 1067 + #line 1 "NONE" 1068 + {te = p+1;} 1069 + #line 53 "parser/machine.rl" 1070 + {act = 9;} 1071 + goto st48; 1072 + tr98: 1073 + #line 1 "NONE" 1074 + {te = p+1;} 1075 + #line 54 "parser/machine.rl" 1076 + {act = 10;} 1077 + goto st48; 1078 + tr99: 1079 + #line 1 "NONE" 1080 + {te = p+1;} 1081 + #line 55 "parser/machine.rl" 1082 + {act = 11;} 1083 + goto st48; 1084 + tr106: 1085 + #line 1 "NONE" 1086 + {te = p+1;} 1087 + #line 57 "parser/machine.rl" 1088 + {act = 13;} 1089 + goto st48; 1090 + tr108: 1091 + #line 1 "NONE" 1092 + {te = p+1;} 1093 + #line 58 "parser/machine.rl" 1094 + {act = 14;} 1095 + goto st48; 1096 + tr109: 1097 + #line 1 "NONE" 1098 + {te = p+1;} 1099 + #line 59 "parser/machine.rl" 1100 + {act = 15;} 1101 + goto st48; 1102 + tr111: 1103 + #line 1 "NONE" 1104 + {te = p+1;} 1105 + #line 60 "parser/machine.rl" 1106 + {act = 16;} 1107 + goto st48; 1108 + tr114: 1109 + #line 1 "NONE" 1110 + {te = p+1;} 1111 + #line 61 "parser/machine.rl" 1112 + {act = 17;} 1113 + goto st48; 1114 + tr117: 1115 + #line 1 "NONE" 1116 + {te = p+1;} 1117 + #line 62 "parser/machine.rl" 1118 + {act = 18;} 1119 + goto st48; 1120 + st48: 1121 + if ( ++p == pe ) 1122 + goto _test_eof48; 1123 + case 48: 1124 + #line 1018 "parser/machine.c" 1125 + switch( (*p) ) { 1126 + case 39: goto st42; 1127 + case 43: goto st13; 1128 + case 46: goto st13; 1129 + case 47: goto st5; 1130 + case 58: goto st14; 1131 + case 95: goto tr54; 1132 + } 1133 + if ( (*p) < 65 ) { 1134 + if ( 45 <= (*p) && (*p) <= 57 ) 1135 + goto tr52; 1136 + } else if ( (*p) > 90 ) { 1137 + if ( 97 <= (*p) && (*p) <= 122 ) 1138 + goto tr52; 1139 + } else 1140 + goto tr52; 1141 + goto tr5; 1142 + st13: 1143 + if ( ++p == pe ) 1144 + goto _test_eof13; 1145 + case 13: 1146 + switch( (*p) ) { 1147 + case 43: goto st13; 1148 + case 47: goto st5; 1149 + case 58: goto st14; 1150 + case 95: goto st4; 1151 + } 1152 + if ( (*p) < 65 ) { 1153 + if ( 45 <= (*p) && (*p) <= 57 ) 1154 + goto st13; 1155 + } else if ( (*p) > 90 ) { 1156 + if ( 97 <= (*p) && (*p) <= 122 ) 1157 + goto st13; 1158 + } else 1159 + goto st13; 1160 + goto tr5; 1161 + st14: 1162 + if ( ++p == pe ) 1163 + goto _test_eof14; 1164 + case 14: 1165 + switch( (*p) ) { 1166 + case 33: goto st49; 1167 + case 61: goto st49; 1168 + case 95: goto st49; 1169 + case 126: goto st49; 1170 + } 1171 + if ( (*p) < 42 ) { 1172 + if ( 36 <= (*p) && (*p) <= 39 ) 1173 + goto st49; 1174 + } else if ( (*p) > 58 ) { 1175 + if ( (*p) > 90 ) { 1176 + if ( 97 <= (*p) && (*p) <= 122 ) 1177 + goto st49; 1178 + } else if ( (*p) >= 63 ) 1179 + goto st49; 1180 + } else 1181 + goto st49; 1182 + goto tr5; 1183 + st49: 1184 + if ( ++p == pe ) 1185 + goto _test_eof49; 1186 + case 49: 1187 + switch( (*p) ) { 1188 + case 33: goto st49; 1189 + case 61: goto st49; 1190 + case 95: goto st49; 1191 + case 126: goto st49; 1192 + } 1193 + if ( (*p) < 42 ) { 1194 + if ( 36 <= (*p) && (*p) <= 39 ) 1195 + goto st49; 1196 + } else if ( (*p) > 58 ) { 1197 + if ( (*p) > 90 ) { 1198 + if ( 97 <= (*p) && (*p) <= 122 ) 1199 + goto st49; 1200 + } else if ( (*p) >= 63 ) 1201 + goto st49; 1202 + } else 1203 + goto st49; 1204 + goto tr90; 1205 + tr55: 1206 + #line 1 "NONE" 1207 + {te = p+1;} 1208 + #line 74 "parser/machine.rl" 1209 + {act = 29;} 1210 + goto st50; 1211 + st50: 1212 + if ( ++p == pe ) 1213 + goto _test_eof50; 1214 + case 50: 1215 + #line 1106 "parser/machine.c" 1216 + switch( (*p) ) { 1217 + case 39: goto st42; 1218 + case 43: goto st13; 1219 + case 46: goto st13; 1220 + case 47: goto st5; 1221 + case 58: goto st14; 1222 + case 95: goto tr54; 1223 + case 115: goto tr91; 1224 + } 1225 + if ( (*p) < 65 ) { 1226 + if ( 45 <= (*p) && (*p) <= 57 ) 1227 + goto tr52; 1228 + } else if ( (*p) > 90 ) { 1229 + if ( 97 <= (*p) && (*p) <= 122 ) 1230 + goto tr52; 1231 + } else 1232 + goto tr52; 1233 + goto tr86; 1234 + tr91: 1235 + #line 1 "NONE" 1236 + {te = p+1;} 1237 + #line 74 "parser/machine.rl" 1238 + {act = 29;} 1239 + goto st51; 1240 + st51: 1241 + if ( ++p == pe ) 1242 + goto _test_eof51; 1243 + case 51: 1244 + #line 1132 "parser/machine.c" 1245 + switch( (*p) ) { 1246 + case 39: goto st42; 1247 + case 43: goto st13; 1248 + case 46: goto st13; 1249 + case 47: goto st5; 1250 + case 58: goto st14; 1251 + case 95: goto tr54; 1252 + case 115: goto tr92; 1253 + } 1254 + if ( (*p) < 65 ) { 1255 + if ( 45 <= (*p) && (*p) <= 57 ) 1256 + goto tr52; 1257 + } else if ( (*p) > 90 ) { 1258 + if ( 97 <= (*p) && (*p) <= 122 ) 1259 + goto tr52; 1260 + } else 1261 + goto tr52; 1262 + goto tr86; 1263 + tr92: 1264 + #line 1 "NONE" 1265 + {te = p+1;} 1266 + #line 74 "parser/machine.rl" 1267 + {act = 29;} 1268 + goto st52; 1269 + st52: 1270 + if ( ++p == pe ) 1271 + goto _test_eof52; 1272 + case 52: 1273 + #line 1158 "parser/machine.c" 1274 + switch( (*p) ) { 1275 + case 39: goto st42; 1276 + case 43: goto st13; 1277 + case 46: goto st13; 1278 + case 47: goto st5; 1279 + case 58: goto st14; 1280 + case 95: goto tr54; 1281 + case 101: goto tr93; 1282 + } 1283 + if ( (*p) < 65 ) { 1284 + if ( 45 <= (*p) && (*p) <= 57 ) 1285 + goto tr52; 1286 + } else if ( (*p) > 90 ) { 1287 + if ( 97 <= (*p) && (*p) <= 122 ) 1288 + goto tr52; 1289 + } else 1290 + goto tr52; 1291 + goto tr86; 1292 + tr93: 1293 + #line 1 "NONE" 1294 + {te = p+1;} 1295 + #line 74 "parser/machine.rl" 1296 + {act = 29;} 1297 + goto st53; 1298 + st53: 1299 + if ( ++p == pe ) 1300 + goto _test_eof53; 1301 + case 53: 1302 + #line 1184 "parser/machine.c" 1303 + switch( (*p) ) { 1304 + case 39: goto st42; 1305 + case 43: goto st13; 1306 + case 46: goto st13; 1307 + case 47: goto st5; 1308 + case 58: goto st14; 1309 + case 95: goto tr54; 1310 + case 114: goto tr94; 1311 + } 1312 + if ( (*p) < 65 ) { 1313 + if ( 45 <= (*p) && (*p) <= 57 ) 1314 + goto tr52; 1315 + } else if ( (*p) > 90 ) { 1316 + if ( 97 <= (*p) && (*p) <= 122 ) 1317 + goto tr52; 1318 + } else 1319 + goto tr52; 1320 + goto tr86; 1321 + tr94: 1322 + #line 1 "NONE" 1323 + {te = p+1;} 1324 + #line 74 "parser/machine.rl" 1325 + {act = 29;} 1326 + goto st54; 1327 + st54: 1328 + if ( ++p == pe ) 1329 + goto _test_eof54; 1330 + case 54: 1331 + #line 1210 "parser/machine.c" 1332 + switch( (*p) ) { 1333 + case 39: goto st42; 1334 + case 43: goto st13; 1335 + case 46: goto st13; 1336 + case 47: goto st5; 1337 + case 58: goto st14; 1338 + case 95: goto tr54; 1339 + case 116: goto tr95; 1340 + } 1341 + if ( (*p) < 65 ) { 1342 + if ( 45 <= (*p) && (*p) <= 57 ) 1343 + goto tr52; 1344 + } else if ( (*p) > 90 ) { 1345 + if ( 97 <= (*p) && (*p) <= 122 ) 1346 + goto tr52; 1347 + } else 1348 + goto tr52; 1349 + goto tr86; 1350 + tr56: 1351 + #line 1 "NONE" 1352 + {te = p+1;} 1353 + #line 74 "parser/machine.rl" 1354 + {act = 29;} 1355 + goto st55; 1356 + st55: 1357 + if ( ++p == pe ) 1358 + goto _test_eof55; 1359 + case 55: 1360 + #line 1236 "parser/machine.c" 1361 + switch( (*p) ) { 1362 + case 39: goto st42; 1363 + case 43: goto st13; 1364 + case 46: goto st13; 1365 + case 47: goto st5; 1366 + case 58: goto st14; 1367 + case 95: goto tr54; 1368 + case 108: goto tr96; 1369 + } 1370 + if ( (*p) < 65 ) { 1371 + if ( 45 <= (*p) && (*p) <= 57 ) 1372 + goto tr52; 1373 + } else if ( (*p) > 90 ) { 1374 + if ( 97 <= (*p) && (*p) <= 122 ) 1375 + goto tr52; 1376 + } else 1377 + goto tr52; 1378 + goto tr86; 1379 + tr96: 1380 + #line 1 "NONE" 1381 + {te = p+1;} 1382 + #line 74 "parser/machine.rl" 1383 + {act = 29;} 1384 + goto st56; 1385 + st56: 1386 + if ( ++p == pe ) 1387 + goto _test_eof56; 1388 + case 56: 1389 + #line 1262 "parser/machine.c" 1390 + switch( (*p) ) { 1391 + case 39: goto st42; 1392 + case 43: goto st13; 1393 + case 46: goto st13; 1394 + case 47: goto st5; 1395 + case 58: goto st14; 1396 + case 95: goto tr54; 1397 + case 115: goto tr97; 1398 + } 1399 + if ( (*p) < 65 ) { 1400 + if ( 45 <= (*p) && (*p) <= 57 ) 1401 + goto tr52; 1402 + } else if ( (*p) > 90 ) { 1403 + if ( 97 <= (*p) && (*p) <= 122 ) 1404 + goto tr52; 1405 + } else 1406 + goto tr52; 1407 + goto tr86; 1408 + tr97: 1409 + #line 1 "NONE" 1410 + {te = p+1;} 1411 + #line 74 "parser/machine.rl" 1412 + {act = 29;} 1413 + goto st57; 1414 + st57: 1415 + if ( ++p == pe ) 1416 + goto _test_eof57; 1417 + case 57: 1418 + #line 1288 "parser/machine.c" 1419 + switch( (*p) ) { 1420 + case 39: goto st42; 1421 + case 43: goto st13; 1422 + case 46: goto st13; 1423 + case 47: goto st5; 1424 + case 58: goto st14; 1425 + case 95: goto tr54; 1426 + case 101: goto tr98; 1427 + } 1428 + if ( (*p) < 65 ) { 1429 + if ( 45 <= (*p) && (*p) <= 57 ) 1430 + goto tr52; 1431 + } else if ( (*p) > 90 ) { 1432 + if ( 97 <= (*p) && (*p) <= 122 ) 1433 + goto tr52; 1434 + } else 1435 + goto tr52; 1436 + goto tr86; 1437 + tr57: 1438 + #line 1 "NONE" 1439 + {te = p+1;} 1440 + #line 74 "parser/machine.rl" 1441 + {act = 29;} 1442 + goto st58; 1443 + st58: 1444 + if ( ++p == pe ) 1445 + goto _test_eof58; 1446 + case 58: 1447 + #line 1314 "parser/machine.c" 1448 + switch( (*p) ) { 1449 + case 39: goto st42; 1450 + case 43: goto st13; 1451 + case 46: goto st13; 1452 + case 47: goto st5; 1453 + case 58: goto st14; 1454 + case 95: goto tr54; 1455 + case 102: goto tr99; 1456 + case 110: goto tr100; 1457 + } 1458 + if ( (*p) < 65 ) { 1459 + if ( 45 <= (*p) && (*p) <= 57 ) 1460 + goto tr52; 1461 + } else if ( (*p) > 90 ) { 1462 + if ( 97 <= (*p) && (*p) <= 122 ) 1463 + goto tr52; 1464 + } else 1465 + goto tr52; 1466 + goto tr86; 1467 + tr100: 1468 + #line 1 "NONE" 1469 + {te = p+1;} 1470 + #line 56 "parser/machine.rl" 1471 + {act = 12;} 1472 + goto st59; 1473 + st59: 1474 + if ( ++p == pe ) 1475 + goto _test_eof59; 1476 + case 59: 1477 + #line 1341 "parser/machine.c" 1478 + switch( (*p) ) { 1479 + case 39: goto st42; 1480 + case 43: goto st13; 1481 + case 46: goto st13; 1482 + case 47: goto st5; 1483 + case 58: goto st14; 1484 + case 95: goto tr54; 1485 + case 104: goto tr102; 1486 + } 1487 + if ( (*p) < 65 ) { 1488 + if ( 45 <= (*p) && (*p) <= 57 ) 1489 + goto tr52; 1490 + } else if ( (*p) > 90 ) { 1491 + if ( 97 <= (*p) && (*p) <= 122 ) 1492 + goto tr52; 1493 + } else 1494 + goto tr52; 1495 + goto tr101; 1496 + tr102: 1497 + #line 1 "NONE" 1498 + {te = p+1;} 1499 + #line 74 "parser/machine.rl" 1500 + {act = 29;} 1501 + goto st60; 1502 + st60: 1503 + if ( ++p == pe ) 1504 + goto _test_eof60; 1505 + case 60: 1506 + #line 1367 "parser/machine.c" 1507 + switch( (*p) ) { 1508 + case 39: goto st42; 1509 + case 43: goto st13; 1510 + case 46: goto st13; 1511 + case 47: goto st5; 1512 + case 58: goto st14; 1513 + case 95: goto tr54; 1514 + case 101: goto tr103; 1515 + } 1516 + if ( (*p) < 65 ) { 1517 + if ( 45 <= (*p) && (*p) <= 57 ) 1518 + goto tr52; 1519 + } else if ( (*p) > 90 ) { 1520 + if ( 97 <= (*p) && (*p) <= 122 ) 1521 + goto tr52; 1522 + } else 1523 + goto tr52; 1524 + goto tr86; 1525 + tr103: 1526 + #line 1 "NONE" 1527 + {te = p+1;} 1528 + #line 74 "parser/machine.rl" 1529 + {act = 29;} 1530 + goto st61; 1531 + st61: 1532 + if ( ++p == pe ) 1533 + goto _test_eof61; 1534 + case 61: 1535 + #line 1393 "parser/machine.c" 1536 + switch( (*p) ) { 1537 + case 39: goto st42; 1538 + case 43: goto st13; 1539 + case 46: goto st13; 1540 + case 47: goto st5; 1541 + case 58: goto st14; 1542 + case 95: goto tr54; 1543 + case 114: goto tr104; 1544 + } 1545 + if ( (*p) < 65 ) { 1546 + if ( 45 <= (*p) && (*p) <= 57 ) 1547 + goto tr52; 1548 + } else if ( (*p) > 90 ) { 1549 + if ( 97 <= (*p) && (*p) <= 122 ) 1550 + goto tr52; 1551 + } else 1552 + goto tr52; 1553 + goto tr86; 1554 + tr104: 1555 + #line 1 "NONE" 1556 + {te = p+1;} 1557 + #line 74 "parser/machine.rl" 1558 + {act = 29;} 1559 + goto st62; 1560 + st62: 1561 + if ( ++p == pe ) 1562 + goto _test_eof62; 1563 + case 62: 1564 + #line 1419 "parser/machine.c" 1565 + switch( (*p) ) { 1566 + case 39: goto st42; 1567 + case 43: goto st13; 1568 + case 46: goto st13; 1569 + case 47: goto st5; 1570 + case 58: goto st14; 1571 + case 95: goto tr54; 1572 + case 105: goto tr105; 1573 + } 1574 + if ( (*p) < 65 ) { 1575 + if ( 45 <= (*p) && (*p) <= 57 ) 1576 + goto tr52; 1577 + } else if ( (*p) > 90 ) { 1578 + if ( 97 <= (*p) && (*p) <= 122 ) 1579 + goto tr52; 1580 + } else 1581 + goto tr52; 1582 + goto tr86; 1583 + tr105: 1584 + #line 1 "NONE" 1585 + {te = p+1;} 1586 + #line 74 "parser/machine.rl" 1587 + {act = 29;} 1588 + goto st63; 1589 + st63: 1590 + if ( ++p == pe ) 1591 + goto _test_eof63; 1592 + case 63: 1593 + #line 1445 "parser/machine.c" 1594 + switch( (*p) ) { 1595 + case 39: goto st42; 1596 + case 43: goto st13; 1597 + case 46: goto st13; 1598 + case 47: goto st5; 1599 + case 58: goto st14; 1600 + case 95: goto tr54; 1601 + case 116: goto tr106; 1602 + } 1603 + if ( (*p) < 65 ) { 1604 + if ( 45 <= (*p) && (*p) <= 57 ) 1605 + goto tr52; 1606 + } else if ( (*p) > 90 ) { 1607 + if ( 97 <= (*p) && (*p) <= 122 ) 1608 + goto tr52; 1609 + } else 1610 + goto tr52; 1611 + goto tr86; 1612 + tr58: 1613 + #line 1 "NONE" 1614 + {te = p+1;} 1615 + #line 74 "parser/machine.rl" 1616 + {act = 29;} 1617 + goto st64; 1618 + st64: 1619 + if ( ++p == pe ) 1620 + goto _test_eof64; 1621 + case 64: 1622 + #line 1471 "parser/machine.c" 1623 + switch( (*p) ) { 1624 + case 39: goto st42; 1625 + case 43: goto st13; 1626 + case 46: goto st13; 1627 + case 47: goto st5; 1628 + case 58: goto st14; 1629 + case 95: goto tr54; 1630 + case 101: goto tr107; 1631 + } 1632 + if ( (*p) < 65 ) { 1633 + if ( 45 <= (*p) && (*p) <= 57 ) 1634 + goto tr52; 1635 + } else if ( (*p) > 90 ) { 1636 + if ( 97 <= (*p) && (*p) <= 122 ) 1637 + goto tr52; 1638 + } else 1639 + goto tr52; 1640 + goto tr86; 1641 + tr107: 1642 + #line 1 "NONE" 1643 + {te = p+1;} 1644 + #line 74 "parser/machine.rl" 1645 + {act = 29;} 1646 + goto st65; 1647 + st65: 1648 + if ( ++p == pe ) 1649 + goto _test_eof65; 1650 + case 65: 1651 + #line 1497 "parser/machine.c" 1652 + switch( (*p) ) { 1653 + case 39: goto st42; 1654 + case 43: goto st13; 1655 + case 46: goto st13; 1656 + case 47: goto st5; 1657 + case 58: goto st14; 1658 + case 95: goto tr54; 1659 + case 116: goto tr108; 1660 + } 1661 + if ( (*p) < 65 ) { 1662 + if ( 45 <= (*p) && (*p) <= 57 ) 1663 + goto tr52; 1664 + } else if ( (*p) > 90 ) { 1665 + if ( 97 <= (*p) && (*p) <= 122 ) 1666 + goto tr52; 1667 + } else 1668 + goto tr52; 1669 + goto tr86; 1670 + tr59: 1671 + #line 1 "NONE" 1672 + {te = p+1;} 1673 + #line 74 "parser/machine.rl" 1674 + {act = 29;} 1675 + goto st66; 1676 + st66: 1677 + if ( ++p == pe ) 1678 + goto _test_eof66; 1679 + case 66: 1680 + #line 1523 "parser/machine.c" 1681 + switch( (*p) ) { 1682 + case 39: goto st42; 1683 + case 43: goto st13; 1684 + case 46: goto st13; 1685 + case 47: goto st5; 1686 + case 58: goto st14; 1687 + case 95: goto tr54; 1688 + case 114: goto tr109; 1689 + } 1690 + if ( (*p) < 65 ) { 1691 + if ( 45 <= (*p) && (*p) <= 57 ) 1692 + goto tr52; 1693 + } else if ( (*p) > 90 ) { 1694 + if ( 97 <= (*p) && (*p) <= 122 ) 1695 + goto tr52; 1696 + } else 1697 + goto tr52; 1698 + goto tr86; 1699 + tr60: 1700 + #line 1 "NONE" 1701 + {te = p+1;} 1702 + #line 74 "parser/machine.rl" 1703 + {act = 29;} 1704 + goto st67; 1705 + st67: 1706 + if ( ++p == pe ) 1707 + goto _test_eof67; 1708 + case 67: 1709 + #line 1549 "parser/machine.c" 1710 + switch( (*p) ) { 1711 + case 39: goto st42; 1712 + case 43: goto st13; 1713 + case 46: goto st13; 1714 + case 47: goto st5; 1715 + case 58: goto st14; 1716 + case 95: goto tr54; 1717 + case 101: goto tr110; 1718 + } 1719 + if ( (*p) < 65 ) { 1720 + if ( 45 <= (*p) && (*p) <= 57 ) 1721 + goto tr52; 1722 + } else if ( (*p) > 90 ) { 1723 + if ( 97 <= (*p) && (*p) <= 122 ) 1724 + goto tr52; 1725 + } else 1726 + goto tr52; 1727 + goto tr86; 1728 + tr110: 1729 + #line 1 "NONE" 1730 + {te = p+1;} 1731 + #line 74 "parser/machine.rl" 1732 + {act = 29;} 1733 + goto st68; 1734 + st68: 1735 + if ( ++p == pe ) 1736 + goto _test_eof68; 1737 + case 68: 1738 + #line 1575 "parser/machine.c" 1739 + switch( (*p) ) { 1740 + case 39: goto st42; 1741 + case 43: goto st13; 1742 + case 46: goto st13; 1743 + case 47: goto st5; 1744 + case 58: goto st14; 1745 + case 95: goto tr54; 1746 + case 99: goto tr111; 1747 + } 1748 + if ( (*p) < 65 ) { 1749 + if ( 45 <= (*p) && (*p) <= 57 ) 1750 + goto tr52; 1751 + } else if ( (*p) > 90 ) { 1752 + if ( 97 <= (*p) && (*p) <= 122 ) 1753 + goto tr52; 1754 + } else 1755 + goto tr52; 1756 + goto tr86; 1757 + tr61: 1758 + #line 1 "NONE" 1759 + {te = p+1;} 1760 + #line 74 "parser/machine.rl" 1761 + {act = 29;} 1762 + goto st69; 1763 + st69: 1764 + if ( ++p == pe ) 1765 + goto _test_eof69; 1766 + case 69: 1767 + #line 1601 "parser/machine.c" 1768 + switch( (*p) ) { 1769 + case 39: goto st42; 1770 + case 43: goto st13; 1771 + case 46: goto st13; 1772 + case 47: goto st5; 1773 + case 58: goto st14; 1774 + case 95: goto tr54; 1775 + case 104: goto tr112; 1776 + } 1777 + if ( (*p) < 65 ) { 1778 + if ( 45 <= (*p) && (*p) <= 57 ) 1779 + goto tr52; 1780 + } else if ( (*p) > 90 ) { 1781 + if ( 97 <= (*p) && (*p) <= 122 ) 1782 + goto tr52; 1783 + } else 1784 + goto tr52; 1785 + goto tr86; 1786 + tr112: 1787 + #line 1 "NONE" 1788 + {te = p+1;} 1789 + #line 74 "parser/machine.rl" 1790 + {act = 29;} 1791 + goto st70; 1792 + st70: 1793 + if ( ++p == pe ) 1794 + goto _test_eof70; 1795 + case 70: 1796 + #line 1627 "parser/machine.c" 1797 + switch( (*p) ) { 1798 + case 39: goto st42; 1799 + case 43: goto st13; 1800 + case 46: goto st13; 1801 + case 47: goto st5; 1802 + case 58: goto st14; 1803 + case 95: goto tr54; 1804 + case 101: goto tr113; 1805 + } 1806 + if ( (*p) < 65 ) { 1807 + if ( 45 <= (*p) && (*p) <= 57 ) 1808 + goto tr52; 1809 + } else if ( (*p) > 90 ) { 1810 + if ( 97 <= (*p) && (*p) <= 122 ) 1811 + goto tr52; 1812 + } else 1813 + goto tr52; 1814 + goto tr86; 1815 + tr113: 1816 + #line 1 "NONE" 1817 + {te = p+1;} 1818 + #line 74 "parser/machine.rl" 1819 + {act = 29;} 1820 + goto st71; 1821 + st71: 1822 + if ( ++p == pe ) 1823 + goto _test_eof71; 1824 + case 71: 1825 + #line 1653 "parser/machine.c" 1826 + switch( (*p) ) { 1827 + case 39: goto st42; 1828 + case 43: goto st13; 1829 + case 46: goto st13; 1830 + case 47: goto st5; 1831 + case 58: goto st14; 1832 + case 95: goto tr54; 1833 + case 110: goto tr114; 1834 + } 1835 + if ( (*p) < 65 ) { 1836 + if ( 45 <= (*p) && (*p) <= 57 ) 1837 + goto tr52; 1838 + } else if ( (*p) > 90 ) { 1839 + if ( 97 <= (*p) && (*p) <= 122 ) 1840 + goto tr52; 1841 + } else 1842 + goto tr52; 1843 + goto tr86; 1844 + tr62: 1845 + #line 1 "NONE" 1846 + {te = p+1;} 1847 + #line 74 "parser/machine.rl" 1848 + {act = 29;} 1849 + goto st72; 1850 + st72: 1851 + if ( ++p == pe ) 1852 + goto _test_eof72; 1853 + case 72: 1854 + #line 1679 "parser/machine.c" 1855 + switch( (*p) ) { 1856 + case 39: goto st42; 1857 + case 43: goto st13; 1858 + case 46: goto st13; 1859 + case 47: goto st5; 1860 + case 58: goto st14; 1861 + case 95: goto tr54; 1862 + case 105: goto tr115; 1863 + } 1864 + if ( (*p) < 65 ) { 1865 + if ( 45 <= (*p) && (*p) <= 57 ) 1866 + goto tr52; 1867 + } else if ( (*p) > 90 ) { 1868 + if ( 97 <= (*p) && (*p) <= 122 ) 1869 + goto tr52; 1870 + } else 1871 + goto tr52; 1872 + goto tr86; 1873 + tr115: 1874 + #line 1 "NONE" 1875 + {te = p+1;} 1876 + #line 74 "parser/machine.rl" 1877 + {act = 29;} 1878 + goto st73; 1879 + st73: 1880 + if ( ++p == pe ) 1881 + goto _test_eof73; 1882 + case 73: 1883 + #line 1705 "parser/machine.c" 1884 + switch( (*p) ) { 1885 + case 39: goto st42; 1886 + case 43: goto st13; 1887 + case 46: goto st13; 1888 + case 47: goto st5; 1889 + case 58: goto st14; 1890 + case 95: goto tr54; 1891 + case 116: goto tr116; 1892 + } 1893 + if ( (*p) < 65 ) { 1894 + if ( 45 <= (*p) && (*p) <= 57 ) 1895 + goto tr52; 1896 + } else if ( (*p) > 90 ) { 1897 + if ( 97 <= (*p) && (*p) <= 122 ) 1898 + goto tr52; 1899 + } else 1900 + goto tr52; 1901 + goto tr86; 1902 + tr116: 1903 + #line 1 "NONE" 1904 + {te = p+1;} 1905 + #line 74 "parser/machine.rl" 1906 + {act = 29;} 1907 + goto st74; 1908 + st74: 1909 + if ( ++p == pe ) 1910 + goto _test_eof74; 1911 + case 74: 1912 + #line 1731 "parser/machine.c" 1913 + switch( (*p) ) { 1914 + case 39: goto st42; 1915 + case 43: goto st13; 1916 + case 46: goto st13; 1917 + case 47: goto st5; 1918 + case 58: goto st14; 1919 + case 95: goto tr54; 1920 + case 104: goto tr117; 1921 + } 1922 + if ( (*p) < 65 ) { 1923 + if ( 45 <= (*p) && (*p) <= 57 ) 1924 + goto tr52; 1925 + } else if ( (*p) > 90 ) { 1926 + if ( 97 <= (*p) && (*p) <= 122 ) 1927 + goto tr52; 1928 + } else 1929 + goto tr52; 1930 + goto tr86; 1931 + st75: 1932 + if ( ++p == pe ) 1933 + goto _test_eof75; 1934 + case 75: 1935 + if ( (*p) == 124 ) 1936 + goto tr118; 1937 + goto tr66; 1938 + tr65: 1939 + #line 1 "NONE" 1940 + {te = p+1;} 1941 + goto st76; 1942 + st76: 1943 + if ( ++p == pe ) 1944 + goto _test_eof76; 1945 + case 76: 1946 + #line 1763 "parser/machine.c" 1947 + if ( (*p) == 47 ) 1948 + goto st15; 1949 + goto tr66; 1950 + st15: 1951 + if ( ++p == pe ) 1952 + goto _test_eof15; 1953 + case 15: 1954 + switch( (*p) ) { 1955 + case 43: goto st77; 1956 + case 95: goto st77; 1957 + } 1958 + if ( (*p) < 48 ) { 1959 + if ( 45 <= (*p) && (*p) <= 46 ) 1960 + goto st77; 1961 + } else if ( (*p) > 57 ) { 1962 + if ( (*p) > 90 ) { 1963 + if ( 97 <= (*p) && (*p) <= 122 ) 1964 + goto st77; 1965 + } else if ( (*p) >= 65 ) 1966 + goto st77; 1967 + } else 1968 + goto st77; 1969 + goto tr0; 1970 + st77: 1971 + if ( ++p == pe ) 1972 + goto _test_eof77; 1973 + case 77: 1974 + switch( (*p) ) { 1975 + case 43: goto st77; 1976 + case 47: goto st78; 1977 + case 95: goto st77; 1978 + } 1979 + if ( (*p) < 65 ) { 1980 + if ( 45 <= (*p) && (*p) <= 57 ) 1981 + goto st77; 1982 + } else if ( (*p) > 90 ) { 1983 + if ( 97 <= (*p) && (*p) <= 122 ) 1984 + goto st77; 1985 + } else 1986 + goto st77; 1987 + goto tr120; 1988 + st78: 1989 + if ( ++p == pe ) 1990 + goto _test_eof78; 1991 + case 78: 1992 + switch( (*p) ) { 1993 + case 43: goto st77; 1994 + case 95: goto st77; 1995 + } 1996 + if ( (*p) < 48 ) { 1997 + if ( 45 <= (*p) && (*p) <= 46 ) 1998 + goto st77; 1999 + } else if ( (*p) > 57 ) { 2000 + if ( (*p) > 90 ) { 2001 + if ( 97 <= (*p) && (*p) <= 122 ) 2002 + goto st77; 2003 + } else if ( (*p) >= 65 ) 2004 + goto st77; 2005 + } else 2006 + goto st77; 2007 + goto tr120; 2008 + tr22: 2009 + #line 35 "parser/machine.rl" 2010 + {{p = ((te))-1;}{ tok(TEXT, r); add_lines(r, ts, te); }} 2011 + goto st79; 2012 + tr24: 2013 + #line 1 "NONE" 2014 + { switch( act ) { 2015 + case 0: 2016 + {{goto st0;}} 2017 + break; 2018 + case 3: 2019 + {{p = ((te))-1;} tok(TEXT, r); add_lines(r, ts, te); } 2020 + break; 2021 + } 2022 + } 2023 + goto st79; 2024 + tr122: 2025 + #line 33 "parser/machine.rl" 2026 + {te = p+1;{ if (!tokleave('"', r)) return 1; {cs = stack[--top];goto _again;} }} 2027 + goto st79; 2028 + tr125: 2029 + #line 35 "parser/machine.rl" 2030 + {te = p;p--;{ tok(TEXT, r); add_lines(r, ts, te); }} 2031 + goto st79; 2032 + tr127: 2033 + #line 36 "parser/machine.rl" 2034 + {te = p;p--;{ tok(TEXT, r); }} 2035 + goto st79; 2036 + tr128: 2037 + #line 34 "parser/machine.rl" 2038 + {te = p+1;{ tokenter(INTERP, '}', r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 79;goto st22;}} }} 2039 + goto st79; 2040 + st79: 2041 + #line 1 "NONE" 2042 + {ts = 0;} 2043 + #line 1 "NONE" 2044 + {act = 0;} 2045 + if ( ++p == pe ) 2046 + goto _test_eof79; 2047 + case 79: 2048 + #line 1 "NONE" 2049 + {ts = p;} 2050 + #line 1857 "parser/machine.c" 2051 + switch( (*p) ) { 2052 + case 34: goto tr122; 2053 + case 36: goto st81; 2054 + case 92: goto st17; 2055 + } 2056 + goto tr23; 2057 + tr23: 2058 + #line 1 "NONE" 2059 + {te = p+1;} 2060 + #line 35 "parser/machine.rl" 2061 + {act = 3;} 2062 + goto st80; 2063 + st80: 2064 + if ( ++p == pe ) 2065 + goto _test_eof80; 2066 + case 80: 2067 + #line 1871 "parser/machine.c" 2068 + switch( (*p) ) { 2069 + case 34: goto tr125; 2070 + case 36: goto st16; 2071 + case 92: goto st17; 2072 + } 2073 + goto tr23; 2074 + st16: 2075 + if ( ++p == pe ) 2076 + goto _test_eof16; 2077 + case 16: 2078 + switch( (*p) ) { 2079 + case 34: goto tr22; 2080 + case 123: goto tr22; 2081 + } 2082 + goto tr23; 2083 + st17: 2084 + if ( ++p == pe ) 2085 + goto _test_eof17; 2086 + case 17: 2087 + goto tr23; 2088 + st81: 2089 + if ( ++p == pe ) 2090 + goto _test_eof81; 2091 + case 81: 2092 + switch( (*p) ) { 2093 + case 34: goto tr127; 2094 + case 123: goto tr128; 2095 + } 2096 + goto tr23; 2097 + tr25: 2098 + #line 45 "parser/machine.rl" 2099 + {{p = ((te))-1;}{ tok(TEXT, r); add_lines(r, ts, te); }} 2100 + goto st82; 2101 + tr29: 2102 + #line 1 "NONE" 2103 + { switch( act ) { 2104 + case 5: 2105 + {{p = ((te))-1;} if (!tokleave(II, r)) return 1; {cs = stack[--top];goto _again;} } 2106 + break; 2107 + case 7: 2108 + {{p = ((te))-1;} tok(TEXT, r); add_lines(r, ts, te); } 2109 + break; 2110 + } 2111 + } 2112 + goto st82; 2113 + tr131: 2114 + #line 45 "parser/machine.rl" 2115 + {te = p;p--;{ tok(TEXT, r); add_lines(r, ts, te); }} 2116 + goto st82; 2117 + tr134: 2118 + #line 46 "parser/machine.rl" 2119 + {te = p;p--;{ tok(TEXT, r); }} 2120 + goto st82; 2121 + tr135: 2122 + #line 44 "parser/machine.rl" 2123 + {te = p+1;{ tokenter(INTERP, '}', r); { /* replaced nostack-return to return non-zero error */ {stack[top++] = 82;goto st22;}} }} 2124 + goto st82; 2125 + tr137: 2126 + #line 43 "parser/machine.rl" 2127 + {te = p;p--;{ if (!tokleave(II, r)) return 1; {cs = stack[--top];goto _again;} }} 2128 + goto st82; 2129 + st82: 2130 + #line 1 "NONE" 2131 + {ts = 0;} 2132 + if ( ++p == pe ) 2133 + goto _test_eof82; 2134 + case 82: 2135 + #line 1 "NONE" 2136 + {ts = p;} 2137 + #line 1932 "parser/machine.c" 2138 + switch( (*p) ) { 2139 + case 36: goto st84; 2140 + case 39: goto st85; 2141 + } 2142 + goto tr26; 2143 + tr26: 2144 + #line 1 "NONE" 2145 + {te = p+1;} 2146 + #line 45 "parser/machine.rl" 2147 + {act = 7;} 2148 + goto st83; 2149 + st83: 2150 + if ( ++p == pe ) 2151 + goto _test_eof83; 2152 + case 83: 2153 + #line 1945 "parser/machine.c" 2154 + switch( (*p) ) { 2155 + case 36: goto st18; 2156 + case 39: goto st19; 2157 + } 2158 + goto tr26; 2159 + st18: 2160 + if ( ++p == pe ) 2161 + goto _test_eof18; 2162 + case 18: 2163 + switch( (*p) ) { 2164 + case 39: goto tr25; 2165 + case 123: goto tr25; 2166 + } 2167 + goto tr26; 2168 + st19: 2169 + if ( ++p == pe ) 2170 + goto _test_eof19; 2171 + case 19: 2172 + switch( (*p) ) { 2173 + case 36: goto tr25; 2174 + case 39: goto st20; 2175 + } 2176 + goto tr26; 2177 + st20: 2178 + if ( ++p == pe ) 2179 + goto _test_eof20; 2180 + case 20: 2181 + switch( (*p) ) { 2182 + case 36: goto tr26; 2183 + case 39: goto tr26; 2184 + case 92: goto st21; 2185 + } 2186 + goto tr25; 2187 + st21: 2188 + if ( ++p == pe ) 2189 + goto _test_eof21; 2190 + case 21: 2191 + goto tr26; 2192 + st84: 2193 + if ( ++p == pe ) 2194 + goto _test_eof84; 2195 + case 84: 2196 + switch( (*p) ) { 2197 + case 39: goto tr134; 2198 + case 123: goto tr135; 2199 + } 2200 + goto tr26; 2201 + st85: 2202 + if ( ++p == pe ) 2203 + goto _test_eof85; 2204 + case 85: 2205 + switch( (*p) ) { 2206 + case 36: goto tr134; 2207 + case 39: goto tr136; 2208 + } 2209 + goto tr26; 2210 + tr136: 2211 + #line 1 "NONE" 2212 + {te = p+1;} 2213 + #line 43 "parser/machine.rl" 2214 + {act = 5;} 2215 + goto st86; 2216 + st86: 2217 + if ( ++p == pe ) 2218 + goto _test_eof86; 2219 + case 86: 2220 + #line 2009 "parser/machine.c" 2221 + switch( (*p) ) { 2222 + case 36: goto tr26; 2223 + case 39: goto tr26; 2224 + case 92: goto st21; 2225 + } 2226 + goto tr137; 2227 + st0: 2228 + cs = 0; 2229 + goto _out; 2230 + } 2231 + _test_eof22: cs = 22; goto _test_eof; 2232 + _test_eof23: cs = 23; goto _test_eof; 2233 + _test_eof1: cs = 1; goto _test_eof; 2234 + _test_eof24: cs = 24; goto _test_eof; 2235 + _test_eof2: cs = 2; goto _test_eof; 2236 + _test_eof3: cs = 3; goto _test_eof; 2237 + _test_eof25: cs = 25; goto _test_eof; 2238 + _test_eof26: cs = 26; goto _test_eof; 2239 + _test_eof27: cs = 27; goto _test_eof; 2240 + _test_eof28: cs = 28; goto _test_eof; 2241 + _test_eof29: cs = 29; goto _test_eof; 2242 + _test_eof30: cs = 30; goto _test_eof; 2243 + _test_eof31: cs = 31; goto _test_eof; 2244 + _test_eof32: cs = 32; goto _test_eof; 2245 + _test_eof33: cs = 33; goto _test_eof; 2246 + _test_eof4: cs = 4; goto _test_eof; 2247 + _test_eof5: cs = 5; goto _test_eof; 2248 + _test_eof34: cs = 34; goto _test_eof; 2249 + _test_eof35: cs = 35; goto _test_eof; 2250 + _test_eof36: cs = 36; goto _test_eof; 2251 + _test_eof37: cs = 37; goto _test_eof; 2252 + _test_eof6: cs = 6; goto _test_eof; 2253 + _test_eof38: cs = 38; goto _test_eof; 2254 + _test_eof7: cs = 7; goto _test_eof; 2255 + _test_eof8: cs = 8; goto _test_eof; 2256 + _test_eof39: cs = 39; goto _test_eof; 2257 + _test_eof40: cs = 40; goto _test_eof; 2258 + _test_eof9: cs = 9; goto _test_eof; 2259 + _test_eof10: cs = 10; goto _test_eof; 2260 + _test_eof41: cs = 41; goto _test_eof; 2261 + _test_eof42: cs = 42; goto _test_eof; 2262 + _test_eof43: cs = 43; goto _test_eof; 2263 + _test_eof44: cs = 44; goto _test_eof; 2264 + _test_eof45: cs = 45; goto _test_eof; 2265 + _test_eof11: cs = 11; goto _test_eof; 2266 + _test_eof12: cs = 12; goto _test_eof; 2267 + _test_eof46: cs = 46; goto _test_eof; 2268 + _test_eof47: cs = 47; goto _test_eof; 2269 + _test_eof48: cs = 48; goto _test_eof; 2270 + _test_eof13: cs = 13; goto _test_eof; 2271 + _test_eof14: cs = 14; goto _test_eof; 2272 + _test_eof49: cs = 49; goto _test_eof; 2273 + _test_eof50: cs = 50; goto _test_eof; 2274 + _test_eof51: cs = 51; goto _test_eof; 2275 + _test_eof52: cs = 52; goto _test_eof; 2276 + _test_eof53: cs = 53; goto _test_eof; 2277 + _test_eof54: cs = 54; goto _test_eof; 2278 + _test_eof55: cs = 55; goto _test_eof; 2279 + _test_eof56: cs = 56; goto _test_eof; 2280 + _test_eof57: cs = 57; goto _test_eof; 2281 + _test_eof58: cs = 58; goto _test_eof; 2282 + _test_eof59: cs = 59; goto _test_eof; 2283 + _test_eof60: cs = 60; goto _test_eof; 2284 + _test_eof61: cs = 61; goto _test_eof; 2285 + _test_eof62: cs = 62; goto _test_eof; 2286 + _test_eof63: cs = 63; goto _test_eof; 2287 + _test_eof64: cs = 64; goto _test_eof; 2288 + _test_eof65: cs = 65; goto _test_eof; 2289 + _test_eof66: cs = 66; goto _test_eof; 2290 + _test_eof67: cs = 67; goto _test_eof; 2291 + _test_eof68: cs = 68; goto _test_eof; 2292 + _test_eof69: cs = 69; goto _test_eof; 2293 + _test_eof70: cs = 70; goto _test_eof; 2294 + _test_eof71: cs = 71; goto _test_eof; 2295 + _test_eof72: cs = 72; goto _test_eof; 2296 + _test_eof73: cs = 73; goto _test_eof; 2297 + _test_eof74: cs = 74; goto _test_eof; 2298 + _test_eof75: cs = 75; goto _test_eof; 2299 + _test_eof76: cs = 76; goto _test_eof; 2300 + _test_eof15: cs = 15; goto _test_eof; 2301 + _test_eof77: cs = 77; goto _test_eof; 2302 + _test_eof78: cs = 78; goto _test_eof; 2303 + _test_eof79: cs = 79; goto _test_eof; 2304 + _test_eof80: cs = 80; goto _test_eof; 2305 + _test_eof16: cs = 16; goto _test_eof; 2306 + _test_eof17: cs = 17; goto _test_eof; 2307 + _test_eof81: cs = 81; goto _test_eof; 2308 + _test_eof82: cs = 82; goto _test_eof; 2309 + _test_eof83: cs = 83; goto _test_eof; 2310 + _test_eof18: cs = 18; goto _test_eof; 2311 + _test_eof19: cs = 19; goto _test_eof; 2312 + _test_eof20: cs = 20; goto _test_eof; 2313 + _test_eof21: cs = 21; goto _test_eof; 2314 + _test_eof84: cs = 84; goto _test_eof; 2315 + _test_eof85: cs = 85; goto _test_eof; 2316 + _test_eof86: cs = 86; goto _test_eof; 2317 + 2318 + _test_eof: {} 2319 + if ( p == eof ) 2320 + { 2321 + switch ( cs ) { 2322 + case 23: goto tr66; 2323 + case 1: goto tr0; 2324 + case 24: goto tr68; 2325 + case 2: goto tr2; 2326 + case 3: goto tr2; 2327 + case 25: goto tr68; 2328 + case 26: goto tr70; 2329 + case 27: goto tr66; 2330 + case 28: goto tr72; 2331 + case 29: goto tr66; 2332 + case 30: goto tr66; 2333 + case 31: goto tr66; 2334 + case 32: goto tr66; 2335 + case 33: goto tr5; 2336 + case 4: goto tr5; 2337 + case 5: goto tr5; 2338 + case 34: goto tr77; 2339 + case 35: goto tr77; 2340 + case 36: goto tr66; 2341 + case 37: goto tr66; 2342 + case 6: goto tr0; 2343 + case 38: goto tr68; 2344 + case 7: goto tr2; 2345 + case 8: goto tr2; 2346 + case 39: goto tr68; 2347 + case 40: goto tr66; 2348 + case 9: goto tr0; 2349 + case 10: goto tr0; 2350 + case 41: goto tr84; 2351 + case 42: goto tr86; 2352 + case 43: goto tr86; 2353 + case 44: goto tr84; 2354 + case 45: goto tr66; 2355 + case 11: goto tr0; 2356 + case 12: goto tr0; 2357 + case 46: goto tr66; 2358 + case 47: goto tr66; 2359 + case 48: goto tr5; 2360 + case 13: goto tr5; 2361 + case 14: goto tr5; 2362 + case 49: goto tr90; 2363 + case 50: goto tr86; 2364 + case 51: goto tr86; 2365 + case 52: goto tr86; 2366 + case 53: goto tr86; 2367 + case 54: goto tr86; 2368 + case 55: goto tr86; 2369 + case 56: goto tr86; 2370 + case 57: goto tr86; 2371 + case 58: goto tr86; 2372 + case 59: goto tr101; 2373 + case 60: goto tr86; 2374 + case 61: goto tr86; 2375 + case 62: goto tr86; 2376 + case 63: goto tr86; 2377 + case 64: goto tr86; 2378 + case 65: goto tr86; 2379 + case 66: goto tr86; 2380 + case 67: goto tr86; 2381 + case 68: goto tr86; 2382 + case 69: goto tr86; 2383 + case 70: goto tr86; 2384 + case 71: goto tr86; 2385 + case 72: goto tr86; 2386 + case 73: goto tr86; 2387 + case 74: goto tr86; 2388 + case 75: goto tr66; 2389 + case 76: goto tr66; 2390 + case 15: goto tr0; 2391 + case 77: goto tr120; 2392 + case 78: goto tr120; 2393 + case 80: goto tr125; 2394 + case 16: goto tr22; 2395 + case 17: goto tr24; 2396 + case 81: goto tr127; 2397 + case 83: goto tr131; 2398 + case 18: goto tr25; 2399 + case 19: goto tr25; 2400 + case 20: goto tr25; 2401 + case 21: goto tr29; 2402 + case 84: goto tr134; 2403 + case 85: goto tr134; 2404 + case 86: goto tr137; 2405 + } 2406 + } 2407 + 2408 + _out: {} 2409 + } 2410 + 2411 + #line 151 "parser/machine.rl" 2412 + 2413 + if (p != eof) { 2414 + set_err("precedes the token that failed to lex"); 2415 + return 1; 2416 + } else if (backrefs_len(&backrefs) != 0) { 2417 + /* unterminated construct */ 2418 + set_err("is not terminated"); 2419 + free(backrefs.v); 2420 + return 1; 2421 + } 2422 + free(backrefs.v); 2423 + return 0; 2424 + }
+163
parser/machine.rl
··· 1 + // compile-command: "ragel -Z -G2 machine.rl" 2 + 3 + /* C port of the Ragel lexer (ported from legacy Go). This file is pure C and 4 + uses the helpers declared in parser/lexer.h. */ 5 + 6 + #include <stdlib.h> 7 + #include <string.h> 8 + #include "lexer.h" 9 + #include "tokens.h" 10 + 11 + #define maxstack 64 12 + 13 + %%{ 14 + 15 + machine expr; 16 + 17 + prepush { /* replaced nostack-return to return non-zero error */ } 18 + 19 + Space = [ \t\r\n]+; 20 + Comment1 = "#" [^\r\n]*; 21 + Comment2 = "/*" any* :>> "*/"; 22 + URI = [a-zA-Z] [a-zA-Z0-9.+\-]* ":" [a-zA-Z0-9%/?:@&=+$,_.!~*'\-]+; 23 + Path = [a-zA-Z0-9._+\-]* ([/] [a-zA-Z0-9._+\-]+)+ [/]?; 24 + HPath = "~" ([/] [a-zA-Z0-9._+\-]+)+ [/]?; 25 + SPath = "<" [a-zA-Z0-9._+\-]+ ([/] [a-zA-Z0-9._+\-]+)* ">"; 26 + ID = [a-zA-Z0-9_] [a-zA-Z0-9_'\-]*; 27 + Float = (([1-9] [0-9]* [.] [0-9]*) | (0? [.] [0-9]+)) ([Ee] [+\-]? [0-9]+)?; 28 + Int = [0-9]+; 29 + 30 + 31 + qstring := |* 32 + 33 + [\"] => { if (!tokleave('"', r)) return 1; fret; }; 34 + "${" => { tokenter(INTERP, '}', r); fcall expr; }; 35 + ( [^$"\\] | /[$][^{"]/ | /\\./ )+ => { tok(TEXT, r); add_lines(r, ts, te); }; 36 + "$" => { tok(TEXT, r); }; 37 + 38 + *|; 39 + 40 + 41 + istring := |* 42 + 43 + "''" => { if (!tokleave(II, r)) return 1; fret; }; 44 + "${" => { tokenter(INTERP, '}', r); fcall expr; }; 45 + ( [^'$] | "'''" | "''$" | /''\\./ | /'[^'$]/ | /[$][^{']/ )+ => { tok(TEXT, r); add_lines(r, ts, te); }; 46 + ['$] => { tok(TEXT, r); }; 47 + 48 + *|; 49 + 50 + 51 + expr := |* 52 + 53 + "assert" => { tok(ASSERT_, r); }; 54 + "else" => { tok(ELSE_, r); }; 55 + "if" => { tok(IF_, r); }; 56 + "in" => { tok(IN, r); }; 57 + "inherit" => { tok(INHERIT, r); }; 58 + "let" => { tok(LET, r); }; 59 + "or" => { tok(OR_, r); }; 60 + "rec" => { tok(REC, r); }; 61 + "then" => { tok(THEN, r); }; 62 + "with" => { tok(WITH, r); }; 63 + 64 + [ \t\r]+; 65 + "\n" => { add_line(r, ts); }; 66 + Comment1 => { tokcomment(COMMENT, r); }; 67 + Comment2 => { tokcomment(COMMENT, r); add_lines(r, ts, te); }; 68 + URI => { tok(URI, r); }; 69 + Path => { tok(PATH, r); }; 70 + HPath => { tok(PATH, r); }; 71 + SPath => { tok(PATH, r); }; 72 + Float => { tok(FLOAT, r); }; 73 + Int => { tok(INT_, r); }; 74 + ID => { tok(ID, r); }; 75 + 76 + "..." => { tok(ELLIPSIS, r); }; 77 + "->" => { tok(IMPL, r); }; 78 + "||" => { tok(OR, r); }; 79 + "&&" => { tok(AND, r); }; 80 + "==" => { tok(EQ, r); }; 81 + "!=" => { tok(NEQ, r); }; 82 + "<=" => { tok(LEQ, r); }; 83 + ">=" => { tok(GEQ, r); }; 84 + "//" => { tok(UPDATE, r); }; 85 + "++" => { tok(CONCAT, r); }; 86 + 87 + [\"] => { tokenter('"', '"', r); fcall qstring; }; 88 + "''" => { tokenter(II, II, r); fcall istring; }; 89 + 90 + "${" => { tokenter(INTERP, '}', r); fcall expr; }; 91 + "(" => { tokenter('(', ')', r); fcall expr; }; 92 + "[" => { tokenter('[', ']', r); fcall expr; }; 93 + "{" => { tokenter('{', '}', r); fcall expr; }; 94 + [}\])] => { if (!tokleave((int)(*ts), r)) return 1; fret; }; 95 + 96 + [@:] => { if (!tokarg(r)) return 1; }; 97 + 98 + any => { tok((int)(*ts), r); }; 99 + 100 + *|; 101 + 102 + }%% 103 + 104 + %% write data; 105 + 106 + /* C lexical wrapper generated by Ragel */ 107 + 108 + int lexData(const char *data, int len, LexResult *r) { 109 + int cs = 0, act = 0; 110 + const char *p = data; 111 + const char *pe = data + len; 112 + const char *eof = pe; 113 + const char *ts = NULL, *te = NULL; 114 + int top = 0; 115 + int stack[maxstack]; 116 + Backrefs backrefs = { NULL, 0, 0 }; 117 + 118 + /* helper to set an error message (allocated) */ 119 + void set_err(const char *msg) { 120 + if (r->errmsg) { free(r->errmsg); r->errmsg = NULL; } 121 + size_t m = strlen(msg) + 1; 122 + r->errmsg = malloc(m); 123 + if (r->errmsg) memcpy(r->errmsg, msg, m); 124 + } 125 + 126 + /* nostack check used by actions; returns 1 on error (and sets r->errmsg) */ 127 + #define nostack() ( (top) >= maxstack ? (set_err("exceeds recursion limit"), 1) : 0 ) 128 + 129 + /* append or set r->data */ 130 + if (r->data == NULL) { 131 + r->data = malloc(len); 132 + if (!r->data) { set_err("out of memory"); return 1; } 133 + memcpy(r->data, data, len); 134 + r->len = len; 135 + } else { 136 + char *nd = realloc(r->data, r->len + len); 137 + if (!nd) { set_err("out of memory"); return 1; } 138 + r->data = nd; 139 + memcpy(r->data + r->len, data, len); 140 + r->len += len; 141 + } 142 + 143 + %% write init; 144 + (void)expr_first_final; (void)expr_error; (void)expr_en_qstring; (void)expr_en_istring; (void)expr_en_expr; 145 + 146 + /* Ragel exec block will use the macros (tok, tokenter, tokleave, tokarg, add_lines, add_line) 147 + declared in parser/lexer.h and expect local variables ts, te, top, backrefs, data, p, pe, cs. */ 148 + 149 + 150 + %% write exec; 151 + 152 + if (p != eof) { 153 + set_err("precedes the token that failed to lex"); 154 + return 1; 155 + } else if (backrefs_len(&backrefs) != 0) { 156 + /* unterminated construct */ 157 + set_err("is not terminated"); 158 + free(backrefs.v); 159 + return 1; 160 + } 161 + free(backrefs.v); 162 + return 0; 163 + }
+105
parser/main.c
··· 1 + #include <stdio.h> 2 + #include <stdlib.h> 3 + #include <string.h> 4 + #include "lexer.h" 5 + #include "node.h" 6 + #include "parser.h" 7 + #include "lexer_adapter.h" 8 + /* enable parser debug trace when built with -DYYDEBUG=1 */ 9 + extern int yydebug; 10 + 11 + static char *token_text(const LexResult *lr, int idx) { 12 + if (!lr || idx < 0 || idx >= (int)lr->ntokens) return NULL; 13 + int s = lr->tokens[idx].Pos; 14 + int e = lr->tokens[idx].End; 15 + int n = e - s; 16 + char *t = malloc(n + 1); 17 + if (!t) return NULL; 18 + memcpy(t, lr->data + s, n); 19 + t[n] = '\0'; 20 + return t; 21 + } 22 + 23 + int main(int argc, char **argv) { 24 + if (argc < 2) { 25 + fprintf(stderr, "usage: %s <file>\n", argv[0]); 26 + return 2; 27 + } 28 + 29 + int dump_tokens = 0; 30 + const char *path = NULL; 31 + if (argc >= 2 && strcmp(argv[1], "--dump-tokens") == 0) { 32 + if (argc < 3) { 33 + fprintf(stderr, "usage: %s --dump-tokens <file>\n", argv[0]); 34 + return 2; 35 + } 36 + dump_tokens = 1; 37 + path = argv[2]; 38 + } else { 39 + path = argv[1]; 40 + } 41 + 42 + FILE *f = fopen(path, "rb"); 43 + if (!f) { perror("open"); return 2; } 44 + if (fseek(f, 0, SEEK_END) != 0) { perror("seek"); fclose(f); return 2; } 45 + long sz = ftell(f); 46 + if (sz < 0) { perror("tell"); fclose(f); return 2; } 47 + if (fseek(f, 0, SEEK_SET) != 0) { perror("seek"); fclose(f); return 2; } 48 + char *buf = malloc((size_t)sz); 49 + if (!buf) { fclose(f); return 2; } 50 + if (fread(buf, 1, (size_t)sz, f) != (size_t)sz) { perror("read"); fclose(f); free(buf); return 2; } 51 + fclose(f); 52 + 53 + void *scanner = create_scanner(buf, (int)sz, path); 54 + if (!scanner) { fprintf(stderr, "failed to create scanner\n"); free(buf); return 2; } 55 + 56 + void *ast = NULL; 57 + /* enable runtime parser tracing */ 58 + yydebug = 0; 59 + int perr = yyparse(&ast, scanner); 60 + LexResult *lr = scanner_lexresult(scanner); 61 + 62 + /* If user requested token dump, print tokens in the legacy dump format to stdout 63 + so external comparison scripts can parse them. */ 64 + if (dump_tokens && lr) { 65 + /* header line (optional) */ 66 + printf("tokens: %zu comments: %zu lines: %zu\n", lr->ntokens, lr->ncomments, lr->nlines); 67 + for (size_t i = 0; i < lr->ntokens; ++i) { 68 + char *txt = token_text(lr, (int)i); 69 + printf("%4zu: sym=%s(%d) pos=%d end=%d txt='%s' prev=%d\n", i, symString(lr->tokens[i].Sym), lr->tokens[i].Sym, lr->tokens[i].Pos, lr->tokens[i].End, txt ? txt : "", lr->tokens[i].Prev); 70 + free(txt); 71 + } 72 + } 73 + 74 + if (perr) { 75 + fprintf(stderr, "parse failed\n"); 76 + if (lr && lr->errmsg) fprintf(stderr, "lexing failed: %s\n", lr->errmsg); 77 + if (lr) { 78 + fprintf(stderr, "tokens: %zu comments: %zu lines: %zu\n", lr->ntokens, lr->ncomments, lr->nlines); 79 + /* print all tokens for full comparison with legacy lexer */ 80 + for (size_t i = 0; i < lr->ntokens; ++i) { 81 + char *txt = token_text(lr, (int)i); 82 + fprintf(stderr, "%4zu: sym=%s(%d) pos=%d end=%d txt='%s' prev=%d\n", i, symString(lr->tokens[i].Sym), lr->tokens[i].Sym, lr->tokens[i].Pos, lr->tokens[i].End, txt ? txt : "", lr->tokens[i].Prev); 83 + free(txt); 84 + } 85 + } 86 + free_scanner(scanner); 87 + free(buf); 88 + return 1; 89 + } 90 + 91 + if (ast && lr) { 92 + char *s = node_lisp_format((Node*)ast, lr); 93 + if (s) { 94 + puts(s); 95 + free(s); 96 + } 97 + } else if (lr && !dump_tokens) { 98 + /* only print summary to stdout when not in dump mode */ 99 + printf("got %zu tokens, %zu comments, %zu lines\n", lr->ntokens, lr->ncomments, lr->nlines); 100 + } 101 + 102 + free_scanner(scanner); 103 + free(buf); 104 + return 0; 105 + }
+57
parser/node.h
··· 1 + #ifndef PARSER_NODE_H 2 + #define PARSER_NODE_H 3 + 4 + #include <stddef.h> 5 + #include "lexer.h" 6 + 7 + typedef enum { 8 + APPLY_NODE, 9 + ARG_NODE, 10 + ARG_SET_NODE, 11 + ASSERT_NODE, 12 + ATTR_PATH_NODE, 13 + BIND_NODE, 14 + BINDS_NODE, 15 + FLOAT_NODE, 16 + FUNCTION_NODE, 17 + ID_NODE, 18 + I_STRING_NODE, 19 + IF_NODE, 20 + INHERIT_FROM_NODE, 21 + INHERIT_LIST_NODE, 22 + INHERIT_NODE, 23 + INT_NODE, 24 + INTERP_NODE, 25 + LET_NODE, 26 + LIST_NODE, 27 + PARENS_NODE, 28 + PATH_NODE, 29 + REC_SET_NODE, 30 + SELECT_NODE, 31 + SELECT_OR_NODE, 32 + SET_NODE, 33 + STRING_NODE, 34 + TEXT_NODE, 35 + URI_NODE, 36 + WITH_NODE, 37 + OP_NODE 38 + } NodeType; 39 + 40 + typedef struct Node { 41 + NodeType type; 42 + int token_start; 43 + int token_end; 44 + int op; /* operator code for OP_NODE (ASCII or token id) */ 45 + struct Node **children; 46 + size_t nchildren; 47 + size_t cchildren; 48 + } Node; 49 + 50 + /* Produce a lisp-format string representation of the node using the 51 + provided LexResult (for token text lookup). Caller must free result. */ 52 + char *node_lisp_format(Node *n, LexResult *lr); 53 + 54 + /* Return canonical node type name used in legacy lisp format. */ 55 + const char *node_type_name(NodeType t); 56 + 57 + #endif /* PARSER_NODE_H */
+257
parser/nodetype.c
··· 1 + #include "node.h" 2 + #include "parser.h" 3 + #include <stdlib.h> 4 + #include <string.h> 5 + #include <stdio.h> 6 + #include <stdarg.h> 7 + 8 + /* forward declaration to satisfy calls before definition */ 9 + void add_child(Node* parent, Node* child); 10 + 11 + Node* new_node(NodeType type, int token_start) { 12 + Node *n = calloc(1, sizeof(Node)); 13 + n->type = type; 14 + n->token_start = token_start; 15 + n->token_end = 0; 16 + n->op = 0; 17 + n->children = NULL; 18 + n->nchildren = n->cchildren = 0; 19 + return n; 20 + } 21 + 22 + Node* new_node1(NodeType type, int token_start, Node* n1) { 23 + Node *n = new_node(type, token_start); 24 + add_child(n, n1); 25 + return n; 26 + } 27 + 28 + Node* new_node2(NodeType type, int token_start, Node* n1, Node* n2) { 29 + Node *n = new_node(type, token_start); 30 + add_child(n, n1); 31 + add_child(n, n2); 32 + return n; 33 + } 34 + 35 + Node* new_node3(NodeType type, int token_start, Node* n1, Node* n2, Node* n3) { 36 + Node *n = new_node(type, token_start); 37 + add_child(n, n1); 38 + add_child(n, n2); 39 + add_child(n, n3); 40 + return n; 41 + } 42 + 43 + void set_node_type(Node* node, NodeType type) { 44 + if (!node) return; 45 + node->type = type; 46 + } 47 + 48 + void add_child(Node* parent, Node* child) { 49 + if (!parent || !child) return; 50 + if (parent->nchildren >= parent->cchildren) { 51 + size_t nc = parent->cchildren ? parent->cchildren * 2 : 4; 52 + parent->children = realloc(parent->children, nc * sizeof(Node*)); 53 + parent->cchildren = nc; 54 + } 55 + parent->children[parent->nchildren++] = child; 56 + } 57 + 58 + void set_token_end(Node* node, int token_end) { 59 + if (!node) return; 60 + node->token_end = token_end; 61 + } 62 + 63 + /* Operator node helpers required by the generated parser */ 64 + Node* op_node1(int op, int token_start, Node* n1) { 65 + Node *n = new_node(OP_NODE, token_start); 66 + n->op = op; 67 + add_child(n, n1); 68 + return n; 69 + } 70 + 71 + Node* op_node2(int op, int token_start, Node* n1, Node* n2) { 72 + Node *n = new_node(OP_NODE, token_start); 73 + n->op = op; 74 + add_child(n, n1); 75 + add_child(n, n2); 76 + return n; 77 + } 78 + 79 + /* Node type names mapping (partial; mirror legacy names) */ 80 + static const char *node_names[] = { 81 + "apply", 82 + "arg", 83 + "argset", 84 + "assert", 85 + "attrpath", 86 + "bind", 87 + "binds", 88 + "float", 89 + "function", 90 + "id", 91 + "istring", 92 + "if", 93 + "inheritfrom", 94 + "inheritlist", 95 + "inherit", 96 + "int", 97 + "interp", 98 + "let", 99 + "list", 100 + "parens", 101 + "path", 102 + "recset", 103 + "select", 104 + "selector", 105 + "set", 106 + "string", 107 + "text", 108 + "uri", 109 + "with", 110 + "op", 111 + }; 112 + 113 + const char *node_type_name(NodeType t) { 114 + if ((size_t)t < sizeof(node_names)/sizeof(node_names[0])) return node_names[t]; 115 + return "unknown"; 116 + } 117 + 118 + /* Helper to get token text from LexResult */ 119 + static char *token_text(LexResult *lr, int token_index) { 120 + if (!lr || token_index < 0 || token_index >= (int)lr->ntokens) { 121 + char *empty = malloc(1); 122 + if (empty) empty[0] = '\0'; 123 + return empty; 124 + } 125 + int s = lr->tokens[token_index].Pos; 126 + int e = lr->tokens[token_index].End; 127 + size_t n = (size_t)(e - s); 128 + char *tmp = malloc(n+1); 129 + if (!tmp) return NULL; 130 + memcpy(tmp, lr->data + s, n); 131 + tmp[n] = '\0'; 132 + return tmp; /* caller must free */ 133 + } 134 + 135 + static void appendf(char **outp, size_t *lenp, size_t *capp, const char *fmt, ...) { 136 + va_list ap; 137 + va_start(ap, fmt); 138 + va_list ap2; 139 + va_copy(ap2, ap); 140 + int need = vsnprintf(NULL, 0, fmt, ap2); 141 + va_end(ap2); 142 + if (need < 0) { va_end(ap); return; } 143 + if (*lenp + (size_t)need + 1 > *capp) { 144 + *capp = (*lenp + (size_t)need + 1) * 2; 145 + *outp = realloc(*outp, *capp); 146 + } 147 + vsnprintf(*outp + *lenp, (size_t)need + 1, fmt, ap); 148 + *lenp += (size_t)need; 149 + va_end(ap); 150 + } 151 + 152 + char *node_lisp_format(Node *n, LexResult *lr) { 153 + if (!n) return NULL; 154 + size_t cap = 256; 155 + char *out = malloc(cap); 156 + if (!out) return NULL; 157 + size_t len = 0; 158 + 159 + /* For OP_NODE emit the operator symbol as the node name to match legacy 160 + output: e.g. '(? <left> <right>)' or '(// <a> <b>)'. If op is 0 use 161 + the '//' token; if op is a printable ASCII char use that char. */ 162 + if (n->type == OP_NODE) { 163 + char opname_buf[4] = {0}; 164 + char *optext = NULL; 165 + const char *oname = NULL; 166 + if (n->op == 0) { 167 + oname = "//"; 168 + } else { 169 + /* Prefer the original token text from the lexer if available 170 + (covers multi-char tokens like '++', '>=', '!=', etc.). */ 171 + optext = token_text(lr, n->token_start); 172 + if (optext && optext[0] != '\0') { 173 + oname = optext; 174 + } else if (n->op >= 32 && n->op <= 126) { 175 + opname_buf[0] = (char)n->op; 176 + opname_buf[1] = '\0'; 177 + oname = opname_buf; 178 + } else { 179 + oname = node_type_name(n->type); 180 + } 181 + } 182 + appendf(&out, &len, &cap, "(%s", oname); 183 + if (optext) free(optext); 184 + } else { 185 + appendf(&out, &len, &cap, "(%s", node_type_name(n->type)); 186 + } 187 + 188 + /* Coalesce adjacent TEXT children to preserve original string pieces 189 + (legacy keeps things like "$CXX" as a single text token). */ 190 + size_t i = 0; 191 + while (i < n->nchildren) { 192 + Node *child = n->children[i]; 193 + if (child->type == TEXT_NODE) { 194 + char *t = token_text(lr, child->token_start); 195 + if (t) { 196 + appendf(&out, &len, &cap, " (text \"%s\")", t); 197 + } else { 198 + appendf(&out, &len, &cap, " (text \"\")"); 199 + } 200 + free(t); 201 + i++; 202 + } else { 203 + char *c = node_lisp_format(child, lr); 204 + appendf(&out, &len, &cap, " %s", c ? c : ""); 205 + free(c); 206 + i++; 207 + } 208 + } 209 + switch (n->type) { 210 + case URI_NODE: 211 + case PATH_NODE: 212 + case FLOAT_NODE: 213 + case INT_NODE: { 214 + char *t = token_text(lr, n->token_start); 215 + appendf(&out, &len, &cap, " %s", t ? t : ""); 216 + free(t); 217 + break; 218 + } 219 + case ID_NODE: { 220 + char *t = token_text(lr, n->token_start); 221 + appendf(&out, &len, &cap, " |%s|", t ? t : ""); 222 + free(t); 223 + break; 224 + } 225 + case TEXT_NODE: { 226 + char *t = token_text(lr, n->token_start); 227 + if (t) { 228 + size_t lt = strlen(t); 229 + /* If the lexer included surrounding double-quotes, strip them so 230 + the emitted value matches the legacy TokenString (which returns 231 + the inner text). */ 232 + if (lt >= 2 && t[0] == '"' && t[lt-1] == '"') { 233 + t[lt-1] = '\0'; 234 + appendf(&out, &len, &cap, " \"%s\"", t + 1); 235 + } else if (lt >= 1 && t[0] == '"') { 236 + /* strip leading quote only */ 237 + appendf(&out, &len, &cap, " \"%s\"", t + 1); 238 + } else { 239 + appendf(&out, &len, &cap, " \"%s\"", t); 240 + } 241 + } else { 242 + appendf(&out, &len, &cap, " \"\""); 243 + } 244 + free(t); 245 + break; 246 + } 247 + case OP_NODE: { 248 + /* operator already used as node name; do not append trailing op 249 + character after the children (legacy prints operator as the 250 + node name). */ 251 + break; 252 + } 253 + default: break; 254 + } 255 + appendf(&out, &len, &cap, ")"); 256 + return out; 257 + }
+1866
parser/parser.c
··· 1 + /* A Bison parser, made by GNU Bison 3.8.2. */ 2 + 3 + /* Bison implementation for Yacc-like parsers in C 4 + 5 + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, 6 + Inc. 7 + 8 + This program is free software: you can redistribute it and/or modify 9 + it under the terms of the GNU General Public License as published by 10 + the Free Software Foundation, either version 3 of the License, or 11 + (at your option) any later version. 12 + 13 + This program is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + GNU General Public License for more details. 17 + 18 + You should have received a copy of the GNU General Public License 19 + along with this program. If not, see <https://www.gnu.org/licenses/>. */ 20 + 21 + /* As a special exception, you may create a larger work that contains 22 + part or all of the Bison parser skeleton and distribute that work 23 + under terms of your choice, so long as that work isn't itself a 24 + parser generator using the skeleton or a modified version thereof 25 + as a parser skeleton. Alternatively, if you modify or redistribute 26 + the parser skeleton itself, you may (at your option) remove this 27 + special exception, which will cause the skeleton and the resulting 28 + Bison output files to be licensed under the GNU General Public 29 + License without this special exception. 30 + 31 + This special exception was added by the Free Software Foundation in 32 + version 2.2 of Bison. */ 33 + 34 + /* C LALR(1) parser skeleton written by Richard Stallman, by 35 + simplifying the original so-called "semantic" parser. */ 36 + 37 + /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, 38 + especially those whose name start with YY_ or yy_. They are 39 + private implementation details that can be changed or removed. */ 40 + 41 + /* All symbols defined below should begin with yy or YY, to avoid 42 + infringing on user name space. This should be done even for local 43 + variables, as they might otherwise be expanded by user macros. 44 + There are some unavoidable exceptions within include files to 45 + define necessary library symbols; they are noted "INFRINGES ON 46 + USER NAME SPACE" below. */ 47 + 48 + /* Identify Bison output, and Bison version. */ 49 + #define YYBISON 30802 50 + 51 + /* Bison version string. */ 52 + #define YYBISON_VERSION "3.8.2" 53 + 54 + /* Skeleton name. */ 55 + #define YYSKELETON_NAME "yacc.c" 56 + 57 + /* Pure parsers. */ 58 + #define YYPURE 2 59 + 60 + /* Push parsers. */ 61 + #define YYPUSH 0 62 + 63 + /* Pull parsers. */ 64 + #define YYPULL 1 65 + 66 + 67 + 68 + 69 + /* First part of user prologue. */ 70 + #line 1 "parser/parser.y" 71 + 72 + #include "node.h" 73 + #include "lexer.h" 74 + #include <stdio.h> 75 + #include <stdlib.h> 76 + 77 + /* Forward declarations of node helpers implemented in parser/nodetype.c */ 78 + Node* new_node(NodeType type, int token_start); 79 + Node* new_node1(NodeType type, int token_start, Node* n1); 80 + Node* new_node2(NodeType type, int token_start, Node* n1, Node* n2); 81 + Node* new_node3(NodeType type, int token_start, Node* n1, Node* n2, Node* n3); 82 + Node* op_node1(int op, int token_start, Node* n1); 83 + Node* op_node2(int op, int token_start, Node* n1, Node* n2); 84 + void set_node_type(Node* node, NodeType type); 85 + void add_child(Node* parent, Node* child); 86 + void set_token_end(Node* node, int token_end); 87 + 88 + /* yyerror matching the generated parser expectations */ 89 + void yyerror(void **ast_root, void *scanner, const char *s) { 90 + (void)ast_root; (void)scanner; 91 + fprintf(stderr, "parse error: %s\n", s); 92 + } 93 + 94 + /* yylex prototype using void* so it's visible before YYSTYPE is defined in the generated file */ 95 + int yylex(void *yylval_param, void *scanner); 96 + 97 + 98 + #line 99 "parser/parser.c" 99 + 100 + # ifndef YY_CAST 101 + # ifdef __cplusplus 102 + # define YY_CAST(Type, Val) static_cast<Type> (Val) 103 + # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val) 104 + # else 105 + # define YY_CAST(Type, Val) ((Type) (Val)) 106 + # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val)) 107 + # endif 108 + # endif 109 + # ifndef YY_NULLPTR 110 + # if defined __cplusplus 111 + # if 201103L <= __cplusplus 112 + # define YY_NULLPTR nullptr 113 + # else 114 + # define YY_NULLPTR 0 115 + # endif 116 + # else 117 + # define YY_NULLPTR ((void*)0) 118 + # endif 119 + # endif 120 + 121 + #include "parser.h" 122 + /* Symbol kind. */ 123 + enum yysymbol_kind_t 124 + { 125 + YYSYMBOL_YYEMPTY = -2, 126 + YYSYMBOL_YYEOF = 0, /* "end of file" */ 127 + YYSYMBOL_YYerror = 1, /* error */ 128 + YYSYMBOL_YYUNDEF = 2, /* "invalid token" */ 129 + YYSYMBOL_ASSERT_ = 3, /* ASSERT_ */ 130 + YYSYMBOL_IF_ = 4, /* IF_ */ 131 + YYSYMBOL_THEN = 5, /* THEN */ 132 + YYSYMBOL_ELSE_ = 6, /* ELSE_ */ 133 + YYSYMBOL_LET = 7, /* LET */ 134 + YYSYMBOL_IN = 8, /* IN */ 135 + YYSYMBOL_WITH = 9, /* WITH */ 136 + YYSYMBOL_OR_ = 10, /* OR_ */ 137 + YYSYMBOL_REC = 11, /* REC */ 138 + YYSYMBOL_INHERIT = 12, /* INHERIT */ 139 + YYSYMBOL_ELLIPSIS = 13, /* ELLIPSIS */ 140 + YYSYMBOL_INTERP = 14, /* INTERP */ 141 + YYSYMBOL_SPACE = 15, /* SPACE */ 142 + YYSYMBOL_COMMENT = 16, /* COMMENT */ 143 + YYSYMBOL_II = 17, /* II */ 144 + YYSYMBOL_URI = 18, /* URI */ 145 + YYSYMBOL_PATH = 19, /* PATH */ 146 + YYSYMBOL_FLOAT = 20, /* FLOAT */ 147 + YYSYMBOL_INT_ = 21, /* INT_ */ 148 + YYSYMBOL_T_ID = 22, /* T_ID */ 149 + YYSYMBOL_TEXT = 23, /* TEXT */ 150 + YYSYMBOL_ARG_ID = 24, /* ARG_ID */ 151 + YYSYMBOL_ARG_BRACKET = 25, /* ARG_BRACKET */ 152 + YYSYMBOL_26_ = 26, /* ':' */ 153 + YYSYMBOL_27_ = 27, /* '@' */ 154 + YYSYMBOL_28_ = 28, /* ',' */ 155 + YYSYMBOL_29_ = 29, /* ';' */ 156 + YYSYMBOL_30_ = 30, /* '"' */ 157 + YYSYMBOL_31_ = 31, /* '.' */ 158 + YYSYMBOL_32_ = 32, /* '(' */ 159 + YYSYMBOL_33_ = 33, /* ')' */ 160 + YYSYMBOL_34_ = 34, /* '[' */ 161 + YYSYMBOL_35_ = 35, /* ']' */ 162 + YYSYMBOL_36_ = 36, /* '{' */ 163 + YYSYMBOL_37_ = 37, /* '}' */ 164 + YYSYMBOL_38_ = 38, /* '=' */ 165 + YYSYMBOL_IMPL = 39, /* IMPL */ 166 + YYSYMBOL_OR = 40, /* OR */ 167 + YYSYMBOL_AND = 41, /* AND */ 168 + YYSYMBOL_EQ = 42, /* EQ */ 169 + YYSYMBOL_NEQ = 43, /* NEQ */ 170 + YYSYMBOL_44_ = 44, /* '<' */ 171 + YYSYMBOL_45_ = 45, /* '>' */ 172 + YYSYMBOL_LEQ = 46, /* LEQ */ 173 + YYSYMBOL_GEQ = 47, /* GEQ */ 174 + YYSYMBOL_UPDATE = 48, /* UPDATE */ 175 + YYSYMBOL_49_ = 49, /* '!' */ 176 + YYSYMBOL_50_ = 50, /* '+' */ 177 + YYSYMBOL_51_ = 51, /* '-' */ 178 + YYSYMBOL_52_ = 52, /* '*' */ 179 + YYSYMBOL_53_ = 53, /* '/' */ 180 + YYSYMBOL_CONCAT = 54, /* CONCAT */ 181 + YYSYMBOL_55_ = 55, /* '?' */ 182 + YYSYMBOL_NEGATE = 56, /* NEGATE */ 183 + YYSYMBOL_YYACCEPT = 57, /* $accept */ 184 + YYSYMBOL_Main = 58, /* Main */ 185 + YYSYMBOL_Expression = 59, /* Expression */ 186 + YYSYMBOL_Interp = 60, /* Interp */ 187 + YYSYMBOL_String = 61, /* String */ 188 + YYSYMBOL_ID = 62, /* ID */ 189 + YYSYMBOL_Atom = 63, /* Atom */ 190 + YYSYMBOL_Select = 64, /* Select */ 191 + YYSYMBOL_Apply = 65, /* Apply */ 192 + YYSYMBOL_Op = 66, /* Op */ 193 + YYSYMBOL_InterpID = 67, /* InterpID */ 194 + YYSYMBOL_AttrPath = 68, /* AttrPath */ 195 + YYSYMBOL_List = 69, /* List */ 196 + YYSYMBOL_Binds = 70, /* Binds */ 197 + YYSYMBOL_InheritList = 71, /* InheritList */ 198 + YYSYMBOL_Function = 72, /* Function */ 199 + YYSYMBOL_ArgSet = 73, /* ArgSet */ 200 + YYSYMBOL_Arg = 74 /* Arg */ 201 + }; 202 + typedef enum yysymbol_kind_t yysymbol_kind_t; 203 + 204 + 205 + 206 + 207 + #ifdef short 208 + # undef short 209 + #endif 210 + 211 + /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure 212 + <limits.h> and (if available) <stdint.h> are included 213 + so that the code can choose integer types of a good width. */ 214 + 215 + #ifndef __PTRDIFF_MAX__ 216 + # include <limits.h> /* INFRINGES ON USER NAME SPACE */ 217 + # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ 218 + # include <stdint.h> /* INFRINGES ON USER NAME SPACE */ 219 + # define YY_STDINT_H 220 + # endif 221 + #endif 222 + 223 + /* Narrow types that promote to a signed type and that can represent a 224 + signed or unsigned integer of at least N bits. In tables they can 225 + save space and decrease cache pressure. Promoting to a signed type 226 + helps avoid bugs in integer arithmetic. */ 227 + 228 + #ifdef __INT_LEAST8_MAX__ 229 + typedef __INT_LEAST8_TYPE__ yytype_int8; 230 + #elif defined YY_STDINT_H 231 + typedef int_least8_t yytype_int8; 232 + #else 233 + typedef signed char yytype_int8; 234 + #endif 235 + 236 + #ifdef __INT_LEAST16_MAX__ 237 + typedef __INT_LEAST16_TYPE__ yytype_int16; 238 + #elif defined YY_STDINT_H 239 + typedef int_least16_t yytype_int16; 240 + #else 241 + typedef short yytype_int16; 242 + #endif 243 + 244 + /* Work around bug in HP-UX 11.23, which defines these macros 245 + incorrectly for preprocessor constants. This workaround can likely 246 + be removed in 2023, as HPE has promised support for HP-UX 11.23 247 + (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of 248 + <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */ 249 + #ifdef __hpux 250 + # undef UINT_LEAST8_MAX 251 + # undef UINT_LEAST16_MAX 252 + # define UINT_LEAST8_MAX 255 253 + # define UINT_LEAST16_MAX 65535 254 + #endif 255 + 256 + #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__ 257 + typedef __UINT_LEAST8_TYPE__ yytype_uint8; 258 + #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \ 259 + && UINT_LEAST8_MAX <= INT_MAX) 260 + typedef uint_least8_t yytype_uint8; 261 + #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX 262 + typedef unsigned char yytype_uint8; 263 + #else 264 + typedef short yytype_uint8; 265 + #endif 266 + 267 + #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__ 268 + typedef __UINT_LEAST16_TYPE__ yytype_uint16; 269 + #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \ 270 + && UINT_LEAST16_MAX <= INT_MAX) 271 + typedef uint_least16_t yytype_uint16; 272 + #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX 273 + typedef unsigned short yytype_uint16; 274 + #else 275 + typedef int yytype_uint16; 276 + #endif 277 + 278 + #ifndef YYPTRDIFF_T 279 + # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__ 280 + # define YYPTRDIFF_T __PTRDIFF_TYPE__ 281 + # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__ 282 + # elif defined PTRDIFF_MAX 283 + # ifndef ptrdiff_t 284 + # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 285 + # endif 286 + # define YYPTRDIFF_T ptrdiff_t 287 + # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX 288 + # else 289 + # define YYPTRDIFF_T long 290 + # define YYPTRDIFF_MAXIMUM LONG_MAX 291 + # endif 292 + #endif 293 + 294 + #ifndef YYSIZE_T 295 + # ifdef __SIZE_TYPE__ 296 + # define YYSIZE_T __SIZE_TYPE__ 297 + # elif defined size_t 298 + # define YYSIZE_T size_t 299 + # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__ 300 + # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 301 + # define YYSIZE_T size_t 302 + # else 303 + # define YYSIZE_T unsigned 304 + # endif 305 + #endif 306 + 307 + #define YYSIZE_MAXIMUM \ 308 + YY_CAST (YYPTRDIFF_T, \ 309 + (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \ 310 + ? YYPTRDIFF_MAXIMUM \ 311 + : YY_CAST (YYSIZE_T, -1))) 312 + 313 + #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X)) 314 + 315 + 316 + /* Stored state numbers (used for stacks). */ 317 + typedef yytype_uint8 yy_state_t; 318 + 319 + /* State numbers in computations. */ 320 + typedef int yy_state_fast_t; 321 + 322 + #ifndef YY_ 323 + # if defined YYENABLE_NLS && YYENABLE_NLS 324 + # if ENABLE_NLS 325 + # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 326 + # define YY_(Msgid) dgettext ("bison-runtime", Msgid) 327 + # endif 328 + # endif 329 + # ifndef YY_ 330 + # define YY_(Msgid) Msgid 331 + # endif 332 + #endif 333 + 334 + 335 + #ifndef YY_ATTRIBUTE_PURE 336 + # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__) 337 + # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__)) 338 + # else 339 + # define YY_ATTRIBUTE_PURE 340 + # endif 341 + #endif 342 + 343 + #ifndef YY_ATTRIBUTE_UNUSED 344 + # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__) 345 + # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) 346 + # else 347 + # define YY_ATTRIBUTE_UNUSED 348 + # endif 349 + #endif 350 + 351 + /* Suppress unused-variable warnings by "using" E. */ 352 + #if ! defined lint || defined __GNUC__ 353 + # define YY_USE(E) ((void) (E)) 354 + #else 355 + # define YY_USE(E) /* empty */ 356 + #endif 357 + 358 + /* Suppress an incorrect diagnostic about yylval being uninitialized. */ 359 + #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__ 360 + # if __GNUC__ * 100 + __GNUC_MINOR__ < 407 361 + # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 362 + _Pragma ("GCC diagnostic push") \ 363 + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") 364 + # else 365 + # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ 366 + _Pragma ("GCC diagnostic push") \ 367 + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \ 368 + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") 369 + # endif 370 + # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ 371 + _Pragma ("GCC diagnostic pop") 372 + #else 373 + # define YY_INITIAL_VALUE(Value) Value 374 + #endif 375 + #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 376 + # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 377 + # define YY_IGNORE_MAYBE_UNINITIALIZED_END 378 + #endif 379 + #ifndef YY_INITIAL_VALUE 380 + # define YY_INITIAL_VALUE(Value) /* Nothing. */ 381 + #endif 382 + 383 + #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__ 384 + # define YY_IGNORE_USELESS_CAST_BEGIN \ 385 + _Pragma ("GCC diagnostic push") \ 386 + _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"") 387 + # define YY_IGNORE_USELESS_CAST_END \ 388 + _Pragma ("GCC diagnostic pop") 389 + #endif 390 + #ifndef YY_IGNORE_USELESS_CAST_BEGIN 391 + # define YY_IGNORE_USELESS_CAST_BEGIN 392 + # define YY_IGNORE_USELESS_CAST_END 393 + #endif 394 + 395 + 396 + #define YY_ASSERT(E) ((void) (0 && (E))) 397 + 398 + #if !defined yyoverflow 399 + 400 + /* The parser invokes alloca or malloc; define the necessary symbols. */ 401 + 402 + # ifdef YYSTACK_USE_ALLOCA 403 + # if YYSTACK_USE_ALLOCA 404 + # ifdef __GNUC__ 405 + # define YYSTACK_ALLOC __builtin_alloca 406 + # elif defined __BUILTIN_VA_ARG_INCR 407 + # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ 408 + # elif defined _AIX 409 + # define YYSTACK_ALLOC __alloca 410 + # elif defined _MSC_VER 411 + # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ 412 + # define alloca _alloca 413 + # else 414 + # define YYSTACK_ALLOC alloca 415 + # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS 416 + # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 417 + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ 418 + # ifndef EXIT_SUCCESS 419 + # define EXIT_SUCCESS 0 420 + # endif 421 + # endif 422 + # endif 423 + # endif 424 + # endif 425 + 426 + # ifdef YYSTACK_ALLOC 427 + /* Pacify GCC's 'empty if-body' warning. */ 428 + # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 429 + # ifndef YYSTACK_ALLOC_MAXIMUM 430 + /* The OS might guarantee only one guard page at the bottom of the stack, 431 + and a page size can be as small as 4096 bytes. So we cannot safely 432 + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number 433 + to allow for a few compiler-allocated temporary stack slots. */ 434 + # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ 435 + # endif 436 + # else 437 + # define YYSTACK_ALLOC YYMALLOC 438 + # define YYSTACK_FREE YYFREE 439 + # ifndef YYSTACK_ALLOC_MAXIMUM 440 + # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 441 + # endif 442 + # if (defined __cplusplus && ! defined EXIT_SUCCESS \ 443 + && ! ((defined YYMALLOC || defined malloc) \ 444 + && (defined YYFREE || defined free))) 445 + # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 446 + # ifndef EXIT_SUCCESS 447 + # define EXIT_SUCCESS 0 448 + # endif 449 + # endif 450 + # ifndef YYMALLOC 451 + # define YYMALLOC malloc 452 + # if ! defined malloc && ! defined EXIT_SUCCESS 453 + void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 454 + # endif 455 + # endif 456 + # ifndef YYFREE 457 + # define YYFREE free 458 + # if ! defined free && ! defined EXIT_SUCCESS 459 + void free (void *); /* INFRINGES ON USER NAME SPACE */ 460 + # endif 461 + # endif 462 + # endif 463 + #endif /* !defined yyoverflow */ 464 + 465 + #if (! defined yyoverflow \ 466 + && (! defined __cplusplus \ 467 + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) 468 + 469 + /* A type that is properly aligned for any stack member. */ 470 + union yyalloc 471 + { 472 + yy_state_t yyss_alloc; 473 + YYSTYPE yyvs_alloc; 474 + }; 475 + 476 + /* The size of the maximum gap between one aligned stack and the next. */ 477 + # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1) 478 + 479 + /* The size of an array large to enough to hold all stacks, each with 480 + N elements. */ 481 + # define YYSTACK_BYTES(N) \ 482 + ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \ 483 + + YYSTACK_GAP_MAXIMUM) 484 + 485 + # define YYCOPY_NEEDED 1 486 + 487 + /* Relocate STACK from its old location to the new one. The 488 + local variables YYSIZE and YYSTACKSIZE give the old and new number of 489 + elements in the stack, and YYPTR gives the new location of the 490 + stack. Advance YYPTR to a properly aligned location for the next 491 + stack. */ 492 + # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ 493 + do \ 494 + { \ 495 + YYPTRDIFF_T yynewbytes; \ 496 + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ 497 + Stack = &yyptr->Stack_alloc; \ 498 + yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \ 499 + yyptr += yynewbytes / YYSIZEOF (*yyptr); \ 500 + } \ 501 + while (0) 502 + 503 + #endif 504 + 505 + #if defined YYCOPY_NEEDED && YYCOPY_NEEDED 506 + /* Copy COUNT objects from SRC to DST. The source and destination do 507 + not overlap. */ 508 + # ifndef YYCOPY 509 + # if defined __GNUC__ && 1 < __GNUC__ 510 + # define YYCOPY(Dst, Src, Count) \ 511 + __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src))) 512 + # else 513 + # define YYCOPY(Dst, Src, Count) \ 514 + do \ 515 + { \ 516 + YYPTRDIFF_T yyi; \ 517 + for (yyi = 0; yyi < (Count); yyi++) \ 518 + (Dst)[yyi] = (Src)[yyi]; \ 519 + } \ 520 + while (0) 521 + # endif 522 + # endif 523 + #endif /* !YYCOPY_NEEDED */ 524 + 525 + /* YYFINAL -- State number of the termination state. */ 526 + #define YYFINAL 46 527 + /* YYLAST -- Last index in YYTABLE. */ 528 + #define YYLAST 293 529 + 530 + /* YYNTOKENS -- Number of terminals. */ 531 + #define YYNTOKENS 57 532 + /* YYNNTS -- Number of nonterminals. */ 533 + #define YYNNTS 18 534 + /* YYNRULES -- Number of rules. */ 535 + #define YYNRULES 73 536 + /* YYNSTATES -- Number of states. */ 537 + #define YYNSTATES 149 538 + 539 + /* YYMAXUTOK -- Last valid token kind. */ 540 + #define YYMAXUTOK 290 541 + 542 + 543 + /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM 544 + as returned by yylex, with out-of-bounds checking. */ 545 + #define YYTRANSLATE(YYX) \ 546 + (0 <= (YYX) && (YYX) <= YYMAXUTOK \ 547 + ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \ 548 + : YYSYMBOL_YYUNDEF) 549 + 550 + /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM 551 + as returned by yylex. */ 552 + static const yytype_int8 yytranslate[] = 553 + { 554 + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 555 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 556 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 557 + 2, 2, 2, 49, 30, 2, 2, 2, 2, 2, 558 + 32, 33, 52, 50, 28, 51, 31, 53, 2, 2, 559 + 2, 2, 2, 2, 2, 2, 2, 2, 26, 29, 560 + 44, 38, 45, 55, 27, 2, 2, 2, 2, 2, 561 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 562 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 563 + 2, 34, 2, 35, 2, 2, 2, 2, 2, 2, 564 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 565 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 566 + 2, 2, 2, 36, 2, 37, 2, 2, 2, 2, 567 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 568 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 569 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 570 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 571 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 572 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 573 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 574 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 575 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 576 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 577 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 578 + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 579 + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 580 + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 581 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 582 + 25, 39, 40, 41, 42, 43, 46, 47, 48, 54, 583 + 56 584 + }; 585 + 586 + #if YYDEBUG 587 + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ 588 + static const yytype_uint8 yyrline[] = 589 + { 590 + 0, 66, 66, 71, 72, 74, 76, 78, 80, 84, 591 + 90, 91, 93, 98, 103, 105, 107, 109, 111, 112, 592 + 114, 116, 118, 120, 122, 127, 128, 130, 135, 136, 593 + 141, 142, 144, 146, 148, 150, 152, 154, 156, 158, 594 + 160, 162, 164, 166, 168, 170, 172, 174, 176, 181, 595 + 182, 184, 185, 190, 192, 198, 199, 205, 206, 208, 596 + 210, 216, 217, 222, 224, 226, 228, 230, 236, 237, 597 + 239, 241, 246, 248 598 + }; 599 + #endif 600 + 601 + /** Accessing symbol of state STATE. */ 602 + #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State]) 603 + 604 + #if YYDEBUG || 0 605 + /* The user-facing name of the symbol whose (internal) number is 606 + YYSYMBOL. No bounds checking. */ 607 + static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED; 608 + 609 + /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 610 + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 611 + static const char *const yytname[] = 612 + { 613 + "\"end of file\"", "error", "\"invalid token\"", "ASSERT_", "IF_", 614 + "THEN", "ELSE_", "LET", "IN", "WITH", "OR_", "REC", "INHERIT", 615 + "ELLIPSIS", "INTERP", "SPACE", "COMMENT", "II", "URI", "PATH", "FLOAT", 616 + "INT_", "T_ID", "TEXT", "ARG_ID", "ARG_BRACKET", "':'", "'@'", "','", 617 + "';'", "'\"'", "'.'", "'('", "')'", "'['", "']'", "'{'", "'}'", "'='", 618 + "IMPL", "OR", "AND", "EQ", "NEQ", "'<'", "'>'", "LEQ", "GEQ", "UPDATE", 619 + "'!'", "'+'", "'-'", "'*'", "'/'", "CONCAT", "'?'", "NEGATE", "$accept", 620 + "Main", "Expression", "Interp", "String", "ID", "Atom", "Select", 621 + "Apply", "Op", "InterpID", "AttrPath", "List", "Binds", "InheritList", 622 + "Function", "ArgSet", "Arg", YY_NULLPTR 623 + }; 624 + 625 + static const char * 626 + yysymbol_name (yysymbol_kind_t yysymbol) 627 + { 628 + return yytname[yysymbol]; 629 + } 630 + #endif 631 + 632 + #define YYPACT_NINF (-91) 633 + 634 + #define yypact_value_is_default(Yyn) \ 635 + ((Yyn) == YYPACT_NINF) 636 + 637 + #define YYTABLE_NINF (-1) 638 + 639 + #define yytable_value_is_error(Yyn) \ 640 + ((Yyn) == YYTABLE_NINF) 641 + 642 + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 643 + STATE-NUM. */ 644 + static const yytype_int16 yypact[] = 645 + { 646 + 127, 127, 127, -91, 127, -18, -91, -91, -91, -91, 647 + -91, -91, 65, 13, -91, 127, -91, -91, 147, 147, 648 + 24, -91, -91, 25, -91, 189, 187, -91, 8, 56, 649 + 86, 43, -91, 76, 127, 63, -91, 40, 75, 74, 650 + 6, 81, 169, 48, 120, -91, -91, 95, -91, 147, 651 + 147, 147, 147, 147, 147, 147, 147, 147, 147, 147, 652 + 147, 147, 147, 147, 95, 127, 127, 127, -91, 89, 653 + 127, -91, -91, -91, -91, 36, 127, 67, -91, -91, 654 + -91, -91, 13, 127, 96, 13, -91, -91, -91, -91, 655 + -91, -3, 187, 202, 216, 230, 230, 238, 238, 238, 656 + 238, 238, 101, 101, 29, 29, 29, 87, -91, 122, 657 + -91, 127, 1, 92, 57, 95, 127, -91, -91, 100, 658 + -91, 127, 35, -91, 189, 127, 99, -91, -91, -91, 659 + -91, -91, 104, 113, -91, 117, 124, -91, -91, -91, 660 + -91, 127, 127, 127, 97, -91, -91, -91, -91 661 + }; 662 + 663 + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. 664 + Performed when YYTABLE does not specify something else to do. Zero 665 + means the default is an error. */ 666 + static const yytype_int8 yydefact[] = 667 + { 668 + 0, 0, 0, 57, 0, 0, 10, 14, 15, 16, 669 + 17, 13, 0, 68, 10, 0, 55, 57, 0, 0, 670 + 0, 2, 18, 25, 28, 30, 3, 8, 0, 0, 671 + 0, 0, 57, 0, 0, 0, 70, 72, 0, 69, 672 + 0, 0, 0, 0, 38, 31, 1, 0, 29, 0, 673 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 674 + 0, 0, 0, 0, 0, 0, 0, 0, 50, 61, 675 + 0, 10, 51, 49, 53, 0, 0, 0, 20, 11, 676 + 12, 63, 68, 0, 0, 68, 19, 21, 22, 56, 677 + 23, 26, 48, 47, 46, 45, 44, 43, 42, 41, 678 + 40, 39, 37, 36, 35, 34, 33, 32, 4, 0, 679 + 6, 0, 0, 0, 0, 0, 0, 7, 24, 0, 680 + 73, 0, 0, 71, 0, 0, 0, 59, 62, 9, 681 + 52, 54, 0, 0, 64, 0, 0, 27, 5, 61, 682 + 58, 0, 0, 0, 0, 65, 67, 66, 60 683 + }; 684 + 685 + /* YYPGOTO[NTERM-NUM]. */ 686 + static const yytype_int8 yypgoto[] = 687 + { 688 + -91, -91, -1, -28, -8, -9, -91, -23, -91, -10, 689 + -90, -37, -91, 0, 21, -91, -69, -91 690 + }; 691 + 692 + /* YYDEFGOTO[NTERM-NUM]. */ 693 + static const yytype_int8 yydefgoto[] = 694 + { 695 + 0, 20, 21, 72, 33, 22, 23, 24, 25, 26, 696 + 74, 75, 42, 30, 112, 27, 38, 39 697 + }; 698 + 699 + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If 700 + positive, shift that token. If negative, reduce the rule whose 701 + number is the opposite. If YYTABLE_NINF, syntax error. */ 702 + static const yytype_int16 yytable[] = 703 + { 704 + 28, 29, 48, 31, 37, 80, 40, 124, 44, 45, 705 + 91, 68, 80, 119, 41, 70, 123, 43, 32, 89, 706 + 70, 73, 128, 11, 46, 131, 36, 107, 115, 79, 707 + 127, 71, 77, 81, 73, 11, 86, 65, 73, 92, 708 + 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 709 + 103, 104, 105, 106, 128, 73, 47, 11, 68, 135, 710 + 69, 66, 70, 114, 108, 109, 110, 115, 73, 113, 711 + 11, 70, 76, 37, 116, 117, 37, 68, 71, 69, 712 + 79, 70, 120, 63, 64, 90, 80, 130, 82, 11, 713 + 70, 34, 35, 78, 67, 83, 68, 71, 69, 79, 714 + 70, 137, 85, 73, 118, 68, 73, 68, 11, 70, 715 + 126, 70, 84, 136, 87, 132, 71, 11, 115, 11, 716 + 134, 111, 121, 122, 138, 71, 148, 71, 125, 129, 717 + 1, 2, 139, 140, 3, 73, 4, 133, 5, 141, 718 + 145, 146, 147, 142, 6, 7, 8, 9, 10, 11, 719 + 143, 12, 13, 61, 62, 63, 64, 14, 5, 15, 720 + 144, 16, 0, 17, 6, 7, 8, 9, 10, 11, 721 + 59, 60, 61, 62, 63, 64, 18, 14, 19, 15, 722 + 5, 16, 0, 17, 0, 0, 6, 7, 8, 9, 723 + 10, 11, 0, 0, 0, 0, 18, 0, 19, 14, 724 + 5, 15, 0, 16, 88, 17, 6, 7, 8, 9, 725 + 10, 11, 0, 0, 0, 0, 0, 0, 0, 14, 726 + 0, 15, 0, 16, 0, 17, 49, 50, 51, 52, 727 + 53, 54, 55, 56, 57, 58, 0, 59, 60, 61, 728 + 62, 63, 64, 51, 52, 53, 54, 55, 56, 57, 729 + 58, 0, 59, 60, 61, 62, 63, 64, 52, 53, 730 + 54, 55, 56, 57, 58, 0, 59, 60, 61, 62, 731 + 63, 64, -1, -1, 54, 55, 56, 57, 58, 0, 732 + 59, 60, 61, 62, 63, 64, 58, 0, 59, 60, 733 + 61, 62, 63, 64 734 + }; 735 + 736 + static const yytype_int16 yycheck[] = 737 + { 738 + 1, 2, 25, 4, 13, 33, 14, 10, 18, 19, 739 + 47, 10, 40, 82, 15, 14, 85, 17, 36, 42, 740 + 14, 30, 112, 22, 0, 115, 13, 64, 31, 23, 741 + 29, 30, 32, 34, 43, 22, 30, 29, 47, 49, 742 + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 743 + 60, 61, 62, 63, 144, 64, 31, 22, 10, 24, 744 + 12, 5, 14, 71, 65, 66, 67, 31, 77, 70, 745 + 22, 14, 29, 82, 38, 76, 85, 10, 30, 12, 746 + 23, 14, 83, 54, 55, 37, 114, 30, 25, 22, 747 + 14, 26, 27, 17, 8, 55, 10, 30, 12, 23, 748 + 14, 124, 28, 112, 37, 10, 115, 10, 22, 14, 749 + 111, 14, 37, 122, 33, 116, 30, 22, 31, 22, 750 + 121, 32, 26, 27, 125, 30, 29, 30, 6, 37, 751 + 3, 4, 33, 29, 7, 144, 9, 37, 11, 26, 752 + 141, 142, 143, 26, 17, 18, 19, 20, 21, 22, 753 + 26, 24, 25, 52, 53, 54, 55, 30, 11, 32, 754 + 139, 34, -1, 36, 17, 18, 19, 20, 21, 22, 755 + 50, 51, 52, 53, 54, 55, 49, 30, 51, 32, 756 + 11, 34, -1, 36, -1, -1, 17, 18, 19, 20, 757 + 21, 22, -1, -1, -1, -1, 49, -1, 51, 30, 758 + 11, 32, -1, 34, 35, 36, 17, 18, 19, 20, 759 + 21, 22, -1, -1, -1, -1, -1, -1, -1, 30, 760 + -1, 32, -1, 34, -1, 36, 39, 40, 41, 42, 761 + 43, 44, 45, 46, 47, 48, -1, 50, 51, 52, 762 + 53, 54, 55, 41, 42, 43, 44, 45, 46, 47, 763 + 48, -1, 50, 51, 52, 53, 54, 55, 42, 43, 764 + 44, 45, 46, 47, 48, -1, 50, 51, 52, 53, 765 + 54, 55, 42, 43, 44, 45, 46, 47, 48, -1, 766 + 50, 51, 52, 53, 54, 55, 48, -1, 50, 51, 767 + 52, 53, 54, 55 768 + }; 769 + 770 + /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of 771 + state STATE-NUM. */ 772 + static const yytype_int8 yystos[] = 773 + { 774 + 0, 3, 4, 7, 9, 11, 17, 18, 19, 20, 775 + 21, 22, 24, 25, 30, 32, 34, 36, 49, 51, 776 + 58, 59, 62, 63, 64, 65, 66, 72, 59, 59, 777 + 70, 59, 36, 61, 26, 27, 13, 62, 73, 74, 778 + 61, 59, 69, 70, 66, 66, 0, 31, 64, 39, 779 + 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 780 + 51, 52, 53, 54, 55, 29, 5, 8, 10, 12, 781 + 14, 30, 60, 62, 67, 68, 29, 70, 17, 23, 782 + 60, 59, 25, 55, 37, 28, 30, 33, 35, 64, 783 + 37, 68, 66, 66, 66, 66, 66, 66, 66, 66, 784 + 66, 66, 66, 66, 66, 66, 66, 68, 59, 59, 785 + 59, 32, 71, 59, 61, 31, 38, 59, 37, 73, 786 + 59, 26, 27, 73, 10, 6, 59, 29, 67, 37, 787 + 30, 67, 59, 37, 59, 24, 62, 64, 59, 33, 788 + 29, 26, 26, 26, 71, 59, 59, 59, 29 789 + }; 790 + 791 + /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ 792 + static const yytype_int8 yyr1[] = 793 + { 794 + 0, 57, 58, 59, 59, 59, 59, 59, 59, 60, 795 + 61, 61, 61, 62, 63, 63, 63, 63, 63, 63, 796 + 63, 63, 63, 63, 63, 64, 64, 64, 65, 65, 797 + 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 798 + 66, 66, 66, 66, 66, 66, 66, 66, 66, 67, 799 + 67, 67, 67, 68, 68, 69, 69, 70, 70, 70, 800 + 70, 71, 71, 72, 72, 72, 72, 72, 73, 73, 801 + 73, 73, 74, 74 802 + }; 803 + 804 + /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ 805 + static const yytype_int8 yyr2[] = 806 + { 807 + 0, 2, 1, 1, 4, 6, 4, 4, 1, 3, 808 + 0, 2, 2, 1, 1, 1, 1, 1, 1, 3, 809 + 3, 3, 3, 3, 4, 1, 3, 5, 1, 2, 810 + 1, 2, 3, 3, 3, 3, 3, 3, 2, 3, 811 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 812 + 1, 1, 3, 1, 3, 0, 2, 0, 5, 4, 813 + 7, 0, 2, 3, 5, 7, 7, 7, 0, 1, 814 + 1, 3, 1, 3 815 + }; 816 + 817 + 818 + enum { YYENOMEM = -2 }; 819 + 820 + #define yyerrok (yyerrstatus = 0) 821 + #define yyclearin (yychar = YYEMPTY) 822 + 823 + #define YYACCEPT goto yyacceptlab 824 + #define YYABORT goto yyabortlab 825 + #define YYERROR goto yyerrorlab 826 + #define YYNOMEM goto yyexhaustedlab 827 + 828 + 829 + #define YYRECOVERING() (!!yyerrstatus) 830 + 831 + #define YYBACKUP(Token, Value) \ 832 + do \ 833 + if (yychar == YYEMPTY) \ 834 + { \ 835 + yychar = (Token); \ 836 + yylval = (Value); \ 837 + YYPOPSTACK (yylen); \ 838 + yystate = *yyssp; \ 839 + goto yybackup; \ 840 + } \ 841 + else \ 842 + { \ 843 + yyerror (ast_root, scanner, YY_("syntax error: cannot back up")); \ 844 + YYERROR; \ 845 + } \ 846 + while (0) 847 + 848 + /* Backward compatibility with an undocumented macro. 849 + Use YYerror or YYUNDEF. */ 850 + #define YYERRCODE YYUNDEF 851 + 852 + 853 + /* Enable debugging if requested. */ 854 + #if YYDEBUG 855 + 856 + # ifndef YYFPRINTF 857 + # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 858 + # define YYFPRINTF fprintf 859 + # endif 860 + 861 + # define YYDPRINTF(Args) \ 862 + do { \ 863 + if (yydebug) \ 864 + YYFPRINTF Args; \ 865 + } while (0) 866 + 867 + 868 + 869 + 870 + # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \ 871 + do { \ 872 + if (yydebug) \ 873 + { \ 874 + YYFPRINTF (stderr, "%s ", Title); \ 875 + yy_symbol_print (stderr, \ 876 + Kind, Value, ast_root, scanner); \ 877 + YYFPRINTF (stderr, "\n"); \ 878 + } \ 879 + } while (0) 880 + 881 + 882 + /*-----------------------------------. 883 + | Print this symbol's value on YYO. | 884 + `-----------------------------------*/ 885 + 886 + static void 887 + yy_symbol_value_print (FILE *yyo, 888 + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void** ast_root, void* scanner) 889 + { 890 + FILE *yyoutput = yyo; 891 + YY_USE (yyoutput); 892 + YY_USE (ast_root); 893 + YY_USE (scanner); 894 + if (!yyvaluep) 895 + return; 896 + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 897 + YY_USE (yykind); 898 + YY_IGNORE_MAYBE_UNINITIALIZED_END 899 + } 900 + 901 + 902 + /*---------------------------. 903 + | Print this symbol on YYO. | 904 + `---------------------------*/ 905 + 906 + static void 907 + yy_symbol_print (FILE *yyo, 908 + yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, void** ast_root, void* scanner) 909 + { 910 + YYFPRINTF (yyo, "%s %s (", 911 + yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind)); 912 + 913 + yy_symbol_value_print (yyo, yykind, yyvaluep, ast_root, scanner); 914 + YYFPRINTF (yyo, ")"); 915 + } 916 + 917 + /*------------------------------------------------------------------. 918 + | yy_stack_print -- Print the state stack from its BOTTOM up to its | 919 + | TOP (included). | 920 + `------------------------------------------------------------------*/ 921 + 922 + static void 923 + yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop) 924 + { 925 + YYFPRINTF (stderr, "Stack now"); 926 + for (; yybottom <= yytop; yybottom++) 927 + { 928 + int yybot = *yybottom; 929 + YYFPRINTF (stderr, " %d", yybot); 930 + } 931 + YYFPRINTF (stderr, "\n"); 932 + } 933 + 934 + # define YY_STACK_PRINT(Bottom, Top) \ 935 + do { \ 936 + if (yydebug) \ 937 + yy_stack_print ((Bottom), (Top)); \ 938 + } while (0) 939 + 940 + 941 + /*------------------------------------------------. 942 + | Report that the YYRULE is going to be reduced. | 943 + `------------------------------------------------*/ 944 + 945 + static void 946 + yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp, 947 + int yyrule, void** ast_root, void* scanner) 948 + { 949 + int yylno = yyrline[yyrule]; 950 + int yynrhs = yyr2[yyrule]; 951 + int yyi; 952 + YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n", 953 + yyrule - 1, yylno); 954 + /* The symbols being reduced. */ 955 + for (yyi = 0; yyi < yynrhs; yyi++) 956 + { 957 + YYFPRINTF (stderr, " $%d = ", yyi + 1); 958 + yy_symbol_print (stderr, 959 + YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]), 960 + &yyvsp[(yyi + 1) - (yynrhs)], ast_root, scanner); 961 + YYFPRINTF (stderr, "\n"); 962 + } 963 + } 964 + 965 + # define YY_REDUCE_PRINT(Rule) \ 966 + do { \ 967 + if (yydebug) \ 968 + yy_reduce_print (yyssp, yyvsp, Rule, ast_root, scanner); \ 969 + } while (0) 970 + 971 + /* Nonzero means print parse trace. It is left uninitialized so that 972 + multiple parsers can coexist. */ 973 + int yydebug; 974 + #else /* !YYDEBUG */ 975 + # define YYDPRINTF(Args) ((void) 0) 976 + # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) 977 + # define YY_STACK_PRINT(Bottom, Top) 978 + # define YY_REDUCE_PRINT(Rule) 979 + #endif /* !YYDEBUG */ 980 + 981 + 982 + /* YYINITDEPTH -- initial size of the parser's stacks. */ 983 + #ifndef YYINITDEPTH 984 + # define YYINITDEPTH 200 985 + #endif 986 + 987 + /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 988 + if the built-in stack extension method is used). 989 + 990 + Do not make this value too large; the results are undefined if 991 + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) 992 + evaluated with infinite-precision integer arithmetic. */ 993 + 994 + #ifndef YYMAXDEPTH 995 + # define YYMAXDEPTH 10000 996 + #endif 997 + 998 + 999 + 1000 + 1001 + 1002 + 1003 + /*-----------------------------------------------. 1004 + | Release the memory associated to this symbol. | 1005 + `-----------------------------------------------*/ 1006 + 1007 + static void 1008 + yydestruct (const char *yymsg, 1009 + yysymbol_kind_t yykind, YYSTYPE *yyvaluep, void** ast_root, void* scanner) 1010 + { 1011 + YY_USE (yyvaluep); 1012 + YY_USE (ast_root); 1013 + YY_USE (scanner); 1014 + if (!yymsg) 1015 + yymsg = "Deleting"; 1016 + YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp); 1017 + 1018 + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1019 + YY_USE (yykind); 1020 + YY_IGNORE_MAYBE_UNINITIALIZED_END 1021 + } 1022 + 1023 + 1024 + 1025 + 1026 + 1027 + 1028 + /*----------. 1029 + | yyparse. | 1030 + `----------*/ 1031 + 1032 + int 1033 + yyparse (void** ast_root, void* scanner) 1034 + { 1035 + /* Lookahead token kind. */ 1036 + int yychar; 1037 + 1038 + 1039 + /* The semantic value of the lookahead symbol. */ 1040 + /* Default value used for initialization, for pacifying older GCCs 1041 + or non-GCC compilers. */ 1042 + YY_INITIAL_VALUE (static YYSTYPE yyval_default;) 1043 + YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); 1044 + 1045 + /* Number of syntax errors so far. */ 1046 + int yynerrs = 0; 1047 + 1048 + yy_state_fast_t yystate = 0; 1049 + /* Number of tokens to shift before error messages enabled. */ 1050 + int yyerrstatus = 0; 1051 + 1052 + /* Refer to the stacks through separate pointers, to allow yyoverflow 1053 + to reallocate them elsewhere. */ 1054 + 1055 + /* Their size. */ 1056 + YYPTRDIFF_T yystacksize = YYINITDEPTH; 1057 + 1058 + /* The state stack: array, bottom, top. */ 1059 + yy_state_t yyssa[YYINITDEPTH]; 1060 + yy_state_t *yyss = yyssa; 1061 + yy_state_t *yyssp = yyss; 1062 + 1063 + /* The semantic value stack: array, bottom, top. */ 1064 + YYSTYPE yyvsa[YYINITDEPTH]; 1065 + YYSTYPE *yyvs = yyvsa; 1066 + YYSTYPE *yyvsp = yyvs; 1067 + 1068 + int yyn; 1069 + /* The return value of yyparse. */ 1070 + int yyresult; 1071 + /* Lookahead symbol kind. */ 1072 + yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY; 1073 + /* The variables used to return semantic value and location from the 1074 + action routines. */ 1075 + YYSTYPE yyval; 1076 + 1077 + 1078 + 1079 + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1080 + 1081 + /* The number of symbols on the RHS of the reduced rule. 1082 + Keep to zero when no symbol should be popped. */ 1083 + int yylen = 0; 1084 + 1085 + YYDPRINTF ((stderr, "Starting parse\n")); 1086 + 1087 + yychar = YYEMPTY; /* Cause a token to be read. */ 1088 + 1089 + goto yysetstate; 1090 + 1091 + 1092 + /*------------------------------------------------------------. 1093 + | yynewstate -- push a new state, which is found in yystate. | 1094 + `------------------------------------------------------------*/ 1095 + yynewstate: 1096 + /* In all cases, when you get here, the value and location stacks 1097 + have just been pushed. So pushing a state here evens the stacks. */ 1098 + yyssp++; 1099 + 1100 + 1101 + /*--------------------------------------------------------------------. 1102 + | yysetstate -- set current state (the top of the stack) to yystate. | 1103 + `--------------------------------------------------------------------*/ 1104 + yysetstate: 1105 + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1106 + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); 1107 + YY_IGNORE_USELESS_CAST_BEGIN 1108 + *yyssp = YY_CAST (yy_state_t, yystate); 1109 + YY_IGNORE_USELESS_CAST_END 1110 + YY_STACK_PRINT (yyss, yyssp); 1111 + 1112 + if (yyss + yystacksize - 1 <= yyssp) 1113 + #if !defined yyoverflow && !defined YYSTACK_RELOCATE 1114 + YYNOMEM; 1115 + #else 1116 + { 1117 + /* Get the current used size of the three stacks, in elements. */ 1118 + YYPTRDIFF_T yysize = yyssp - yyss + 1; 1119 + 1120 + # if defined yyoverflow 1121 + { 1122 + /* Give user a chance to reallocate the stack. Use copies of 1123 + these so that the &'s don't force the real ones into 1124 + memory. */ 1125 + yy_state_t *yyss1 = yyss; 1126 + YYSTYPE *yyvs1 = yyvs; 1127 + 1128 + /* Each stack pointer address is followed by the size of the 1129 + data in use in that stack, in bytes. This used to be a 1130 + conditional around just the two extra args, but that might 1131 + be undefined if yyoverflow is a macro. */ 1132 + yyoverflow (YY_("memory exhausted"), 1133 + &yyss1, yysize * YYSIZEOF (*yyssp), 1134 + &yyvs1, yysize * YYSIZEOF (*yyvsp), 1135 + &yystacksize); 1136 + yyss = yyss1; 1137 + yyvs = yyvs1; 1138 + } 1139 + # else /* defined YYSTACK_RELOCATE */ 1140 + /* Extend the stack our own way. */ 1141 + if (YYMAXDEPTH <= yystacksize) 1142 + YYNOMEM; 1143 + yystacksize *= 2; 1144 + if (YYMAXDEPTH < yystacksize) 1145 + yystacksize = YYMAXDEPTH; 1146 + 1147 + { 1148 + yy_state_t *yyss1 = yyss; 1149 + union yyalloc *yyptr = 1150 + YY_CAST (union yyalloc *, 1151 + YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize)))); 1152 + if (! yyptr) 1153 + YYNOMEM; 1154 + YYSTACK_RELOCATE (yyss_alloc, yyss); 1155 + YYSTACK_RELOCATE (yyvs_alloc, yyvs); 1156 + # undef YYSTACK_RELOCATE 1157 + if (yyss1 != yyssa) 1158 + YYSTACK_FREE (yyss1); 1159 + } 1160 + # endif 1161 + 1162 + yyssp = yyss + yysize - 1; 1163 + yyvsp = yyvs + yysize - 1; 1164 + 1165 + YY_IGNORE_USELESS_CAST_BEGIN 1166 + YYDPRINTF ((stderr, "Stack size increased to %ld\n", 1167 + YY_CAST (long, yystacksize))); 1168 + YY_IGNORE_USELESS_CAST_END 1169 + 1170 + if (yyss + yystacksize - 1 <= yyssp) 1171 + YYABORT; 1172 + } 1173 + #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ 1174 + 1175 + 1176 + if (yystate == YYFINAL) 1177 + YYACCEPT; 1178 + 1179 + goto yybackup; 1180 + 1181 + 1182 + /*-----------. 1183 + | yybackup. | 1184 + `-----------*/ 1185 + yybackup: 1186 + /* Do appropriate processing given the current state. Read a 1187 + lookahead token if we need one and don't already have one. */ 1188 + 1189 + /* First try to decide what to do without reference to lookahead token. */ 1190 + yyn = yypact[yystate]; 1191 + if (yypact_value_is_default (yyn)) 1192 + goto yydefault; 1193 + 1194 + /* Not known => get a lookahead token if don't already have one. */ 1195 + 1196 + /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */ 1197 + if (yychar == YYEMPTY) 1198 + { 1199 + YYDPRINTF ((stderr, "Reading a token\n")); 1200 + yychar = yylex (&yylval, scanner); 1201 + } 1202 + 1203 + if (yychar <= YYEOF) 1204 + { 1205 + yychar = YYEOF; 1206 + yytoken = YYSYMBOL_YYEOF; 1207 + YYDPRINTF ((stderr, "Now at end of input.\n")); 1208 + } 1209 + else if (yychar == YYerror) 1210 + { 1211 + /* The scanner already issued an error message, process directly 1212 + to error recovery. But do not keep the error token as 1213 + lookahead, it is too special and may lead us to an endless 1214 + loop in error recovery. */ 1215 + yychar = YYUNDEF; 1216 + yytoken = YYSYMBOL_YYerror; 1217 + goto yyerrlab1; 1218 + } 1219 + else 1220 + { 1221 + yytoken = YYTRANSLATE (yychar); 1222 + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1223 + } 1224 + 1225 + /* If the proper action on seeing token YYTOKEN is to reduce or to 1226 + detect an error, take that action. */ 1227 + yyn += yytoken; 1228 + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1229 + goto yydefault; 1230 + yyn = yytable[yyn]; 1231 + if (yyn <= 0) 1232 + { 1233 + if (yytable_value_is_error (yyn)) 1234 + goto yyerrlab; 1235 + yyn = -yyn; 1236 + goto yyreduce; 1237 + } 1238 + 1239 + /* Count tokens shifted since error; after three, turn off error 1240 + status. */ 1241 + if (yyerrstatus) 1242 + yyerrstatus--; 1243 + 1244 + /* Shift the lookahead token. */ 1245 + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1246 + yystate = yyn; 1247 + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1248 + *++yyvsp = yylval; 1249 + YY_IGNORE_MAYBE_UNINITIALIZED_END 1250 + 1251 + /* Discard the shifted token. */ 1252 + yychar = YYEMPTY; 1253 + goto yynewstate; 1254 + 1255 + 1256 + /*-----------------------------------------------------------. 1257 + | yydefault -- do the default action for the current state. | 1258 + `-----------------------------------------------------------*/ 1259 + yydefault: 1260 + yyn = yydefact[yystate]; 1261 + if (yyn == 0) 1262 + goto yyerrlab; 1263 + goto yyreduce; 1264 + 1265 + 1266 + /*-----------------------------. 1267 + | yyreduce -- do a reduction. | 1268 + `-----------------------------*/ 1269 + yyreduce: 1270 + /* yyn is the number of a rule to reduce with. */ 1271 + yylen = yyr2[yyn]; 1272 + 1273 + /* If YYLEN is nonzero, implement the default value of the action: 1274 + '$$ = $1'. 1275 + 1276 + Otherwise, the following line sets YYVAL to garbage. 1277 + This behavior is undocumented and Bison 1278 + users should not rely upon it. Assigning to YYVAL 1279 + unconditionally makes the parser a bit smaller, and it avoids a 1280 + GCC warning that YYVAL may be used uninitialized. */ 1281 + yyval = yyvsp[1-yylen]; 1282 + 1283 + 1284 + YY_REDUCE_PRINT (yyn); 1285 + switch (yyn) 1286 + { 1287 + case 2: /* Main: Expression */ 1288 + #line 67 "parser/parser.y" 1289 + { *ast_root = (yyvsp[0].node); } 1290 + #line 1291 "parser/parser.c" 1291 + break; 1292 + 1293 + case 4: /* Expression: ASSERT_ Expression ';' Expression */ 1294 + #line 73 "parser/parser.y" 1295 + { (yyval.node) = new_node2(ASSERT_NODE, (yyvsp[-3].token), (yyvsp[-2].node), (yyvsp[0].node)); set_token_end((yyval.node), (yyvsp[-1].token)); } 1296 + #line 1297 "parser/parser.c" 1297 + break; 1298 + 1299 + case 5: /* Expression: IF_ Expression THEN Expression ELSE_ Expression */ 1300 + #line 75 "parser/parser.y" 1301 + { (yyval.node) = new_node3(IF_NODE, (yyvsp[-5].token), (yyvsp[-4].node), (yyvsp[-2].node), (yyvsp[0].node)); set_token_end((yyval.node), (yyvsp[-3].token)); } 1302 + #line 1303 "parser/parser.c" 1303 + break; 1304 + 1305 + case 6: /* Expression: LET Binds IN Expression */ 1306 + #line 77 "parser/parser.y" 1307 + { (yyval.node) = new_node2(LET_NODE, (yyvsp[-3].token), (yyvsp[-2].node), (yyvsp[0].node)); set_token_end((yyval.node), (yyvsp[-1].token)); } 1308 + #line 1309 "parser/parser.c" 1309 + break; 1310 + 1311 + case 7: /* Expression: WITH Expression ';' Expression */ 1312 + #line 79 "parser/parser.y" 1313 + { (yyval.node) = new_node2(WITH_NODE, (yyvsp[-3].token), (yyvsp[-2].node), (yyvsp[0].node)); set_token_end((yyval.node), (yyvsp[-1].token)); } 1314 + #line 1315 "parser/parser.c" 1315 + break; 1316 + 1317 + case 9: /* Interp: INTERP Expression '}' */ 1318 + #line 85 "parser/parser.y" 1319 + { (yyval.node) = new_node1(INTERP_NODE, (yyvsp[-2].token), (yyvsp[-1].node)); set_token_end((yyval.node), (yyvsp[0].token)); } 1320 + #line 1321 "parser/parser.c" 1321 + break; 1322 + 1323 + case 10: /* String: %empty */ 1324 + #line 90 "parser/parser.y" 1325 + { (yyval.node) = new_node(STRING_NODE, 0); } 1326 + #line 1327 "parser/parser.c" 1327 + break; 1328 + 1329 + case 11: /* String: String TEXT */ 1330 + #line 92 "parser/parser.y" 1331 + { add_child((yyvsp[-1].node), new_node(TEXT_NODE, (yyvsp[0].token))); (yyval.node) = (yyvsp[-1].node); } 1332 + #line 1333 "parser/parser.c" 1333 + break; 1334 + 1335 + case 12: /* String: String Interp */ 1336 + #line 94 "parser/parser.y" 1337 + { add_child((yyvsp[-1].node), (yyvsp[0].node)); (yyval.node) = (yyvsp[-1].node); } 1338 + #line 1339 "parser/parser.c" 1339 + break; 1340 + 1341 + case 13: /* ID: T_ID */ 1342 + #line 99 "parser/parser.y" 1343 + { (yyval.node) = new_node(ID_NODE, (yyvsp[0].token)); } 1344 + #line 1345 "parser/parser.c" 1345 + break; 1346 + 1347 + case 14: /* Atom: URI */ 1348 + #line 104 "parser/parser.y" 1349 + { (yyval.node) = new_node(URI_NODE, (yyvsp[0].token)); } 1350 + #line 1351 "parser/parser.c" 1351 + break; 1352 + 1353 + case 15: /* Atom: PATH */ 1354 + #line 106 "parser/parser.y" 1355 + { (yyval.node) = new_node(PATH_NODE, (yyvsp[0].token)); } 1356 + #line 1357 "parser/parser.c" 1357 + break; 1358 + 1359 + case 16: /* Atom: FLOAT */ 1360 + #line 108 "parser/parser.y" 1361 + { (yyval.node) = new_node(FLOAT_NODE, (yyvsp[0].token)); } 1362 + #line 1363 "parser/parser.c" 1363 + break; 1364 + 1365 + case 17: /* Atom: INT_ */ 1366 + #line 110 "parser/parser.y" 1367 + { (yyval.node) = new_node(INT_NODE, (yyvsp[0].token)); } 1368 + #line 1369 "parser/parser.c" 1369 + break; 1370 + 1371 + case 19: /* Atom: '"' String '"' */ 1372 + #line 113 "parser/parser.y" 1373 + { set_token_end((yyvsp[-1].node), (yyvsp[0].token)); (yyval.node) = (yyvsp[-1].node); } 1374 + #line 1375 "parser/parser.c" 1375 + break; 1376 + 1377 + case 20: /* Atom: II String II */ 1378 + #line 115 "parser/parser.y" 1379 + { set_node_type((yyvsp[-1].node), I_STRING_NODE); set_token_end((yyvsp[-1].node), (yyvsp[0].token)); (yyval.node) = (yyvsp[-1].node); } 1380 + #line 1381 "parser/parser.c" 1381 + break; 1382 + 1383 + case 21: /* Atom: '(' Expression ')' */ 1384 + #line 117 "parser/parser.y" 1385 + { (yyval.node) = new_node1(PARENS_NODE, (yyvsp[-2].token), (yyvsp[-1].node)); set_token_end((yyval.node), (yyvsp[0].token)); } 1386 + #line 1387 "parser/parser.c" 1387 + break; 1388 + 1389 + case 22: /* Atom: '[' List ']' */ 1390 + #line 119 "parser/parser.y" 1391 + { set_token_end((yyvsp[-1].node), (yyvsp[0].token)); (yyval.node) = (yyvsp[-1].node); } 1392 + #line 1393 "parser/parser.c" 1393 + break; 1394 + 1395 + case 23: /* Atom: '{' Binds '}' */ 1396 + #line 121 "parser/parser.y" 1397 + { set_node_type((yyvsp[-1].node), SET_NODE); set_token_end((yyvsp[-1].node), (yyvsp[0].token)); (yyval.node) = (yyvsp[-1].node); } 1398 + #line 1399 "parser/parser.c" 1399 + break; 1400 + 1401 + case 24: /* Atom: REC '{' Binds '}' */ 1402 + #line 123 "parser/parser.y" 1403 + { set_node_type((yyvsp[-1].node), REC_SET_NODE); set_token_end((yyvsp[-1].node), (yyvsp[0].token)); (yyval.node) = (yyvsp[-1].node); } 1404 + #line 1405 "parser/parser.c" 1405 + break; 1406 + 1407 + case 26: /* Select: Atom '.' AttrPath */ 1408 + #line 129 "parser/parser.y" 1409 + { (yyval.node) = new_node2(SELECT_NODE, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1410 + #line 1411 "parser/parser.c" 1411 + break; 1412 + 1413 + case 27: /* Select: Atom '.' AttrPath OR_ Select */ 1414 + #line 131 "parser/parser.y" 1415 + { (yyval.node) = new_node3(SELECT_OR_NODE, (yyvsp[-3].token), (yyvsp[-4].node), (yyvsp[-2].node), (yyvsp[0].node)); set_token_end((yyval.node), (yyvsp[-1].token)); } 1416 + #line 1417 "parser/parser.c" 1417 + break; 1418 + 1419 + case 29: /* Apply: Apply Select */ 1420 + #line 137 "parser/parser.y" 1421 + { (yyval.node) = new_node2(APPLY_NODE, 0, (yyvsp[-1].node), (yyvsp[0].node)); } 1422 + #line 1423 "parser/parser.c" 1423 + break; 1424 + 1425 + case 31: /* Op: '-' Op */ 1426 + #line 143 "parser/parser.y" 1427 + { (yyval.node) = op_node1('-', (yyvsp[-1].token), (yyvsp[0].node)); } 1428 + #line 1429 "parser/parser.c" 1429 + break; 1430 + 1431 + case 32: /* Op: Op '?' AttrPath */ 1432 + #line 145 "parser/parser.y" 1433 + { (yyval.node) = op_node2('?', (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1434 + #line 1435 "parser/parser.c" 1435 + break; 1436 + 1437 + case 33: /* Op: Op CONCAT Op */ 1438 + #line 147 "parser/parser.y" 1439 + { (yyval.node) = op_node2(CONCAT, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1440 + #line 1441 "parser/parser.c" 1441 + break; 1442 + 1443 + case 34: /* Op: Op '/' Op */ 1444 + #line 149 "parser/parser.y" 1445 + { (yyval.node) = op_node2('/', (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1446 + #line 1447 "parser/parser.c" 1447 + break; 1448 + 1449 + case 35: /* Op: Op '*' Op */ 1450 + #line 151 "parser/parser.y" 1451 + { (yyval.node) = op_node2('*', (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1452 + #line 1453 "parser/parser.c" 1453 + break; 1454 + 1455 + case 36: /* Op: Op '-' Op */ 1456 + #line 153 "parser/parser.y" 1457 + { (yyval.node) = op_node2('-', (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1458 + #line 1459 "parser/parser.c" 1459 + break; 1460 + 1461 + case 37: /* Op: Op '+' Op */ 1462 + #line 155 "parser/parser.y" 1463 + { (yyval.node) = op_node2('+', (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1464 + #line 1465 "parser/parser.c" 1465 + break; 1466 + 1467 + case 38: /* Op: '!' Op */ 1468 + #line 157 "parser/parser.y" 1469 + { (yyval.node) = op_node1('!', (yyvsp[-1].token), (yyvsp[0].node)); } 1470 + #line 1471 "parser/parser.c" 1471 + break; 1472 + 1473 + case 39: /* Op: Op UPDATE Op */ 1474 + #line 159 "parser/parser.y" 1475 + { (yyval.node) = op_node2(UPDATE, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1476 + #line 1477 "parser/parser.c" 1477 + break; 1478 + 1479 + case 40: /* Op: Op GEQ Op */ 1480 + #line 161 "parser/parser.y" 1481 + { (yyval.node) = op_node2(GEQ, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1482 + #line 1483 "parser/parser.c" 1483 + break; 1484 + 1485 + case 41: /* Op: Op LEQ Op */ 1486 + #line 163 "parser/parser.y" 1487 + { (yyval.node) = op_node2(LEQ, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1488 + #line 1489 "parser/parser.c" 1489 + break; 1490 + 1491 + case 42: /* Op: Op '>' Op */ 1492 + #line 165 "parser/parser.y" 1493 + { (yyval.node) = op_node2('>', (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1494 + #line 1495 "parser/parser.c" 1495 + break; 1496 + 1497 + case 43: /* Op: Op '<' Op */ 1498 + #line 167 "parser/parser.y" 1499 + { (yyval.node) = op_node2('<', (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1500 + #line 1501 "parser/parser.c" 1501 + break; 1502 + 1503 + case 44: /* Op: Op NEQ Op */ 1504 + #line 169 "parser/parser.y" 1505 + { (yyval.node) = op_node2(NEQ, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1506 + #line 1507 "parser/parser.c" 1507 + break; 1508 + 1509 + case 45: /* Op: Op EQ Op */ 1510 + #line 171 "parser/parser.y" 1511 + { (yyval.node) = op_node2(EQ, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1512 + #line 1513 "parser/parser.c" 1513 + break; 1514 + 1515 + case 46: /* Op: Op AND Op */ 1516 + #line 173 "parser/parser.y" 1517 + { (yyval.node) = op_node2(AND, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1518 + #line 1519 "parser/parser.c" 1519 + break; 1520 + 1521 + case 47: /* Op: Op OR Op */ 1522 + #line 175 "parser/parser.y" 1523 + { (yyval.node) = op_node2(OR, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1524 + #line 1525 "parser/parser.c" 1525 + break; 1526 + 1527 + case 48: /* Op: Op IMPL Op */ 1528 + #line 177 "parser/parser.y" 1529 + { (yyval.node) = op_node2(IMPL, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1530 + #line 1531 "parser/parser.c" 1531 + break; 1532 + 1533 + case 50: /* InterpID: OR_ */ 1534 + #line 183 "parser/parser.y" 1535 + { (yyval.node) = new_node(ID_NODE, (yyvsp[0].token)); } 1536 + #line 1537 "parser/parser.c" 1537 + break; 1538 + 1539 + case 52: /* InterpID: '"' String '"' */ 1540 + #line 186 "parser/parser.y" 1541 + { set_token_end((yyvsp[-1].node), (yyvsp[0].token)); (yyval.node) = (yyvsp[-1].node); } 1542 + #line 1543 "parser/parser.c" 1543 + break; 1544 + 1545 + case 53: /* AttrPath: InterpID */ 1546 + #line 191 "parser/parser.y" 1547 + { (yyval.node) = new_node1(ATTR_PATH_NODE, 0, (yyvsp[0].node)); } 1548 + #line 1549 "parser/parser.c" 1549 + break; 1550 + 1551 + case 54: /* AttrPath: AttrPath '.' InterpID */ 1552 + #line 193 "parser/parser.y" 1553 + { add_child((yyvsp[-2].node), (yyvsp[0].node)); set_token_end((yyvsp[-2].node), 0); (yyval.node) = (yyvsp[-2].node); } 1554 + #line 1555 "parser/parser.c" 1555 + break; 1556 + 1557 + case 55: /* List: %empty */ 1558 + #line 198 "parser/parser.y" 1559 + { (yyval.node) = new_node(LIST_NODE, 0); } 1560 + #line 1561 "parser/parser.c" 1561 + break; 1562 + 1563 + case 56: /* List: List Select */ 1564 + #line 200 "parser/parser.y" 1565 + { add_child((yyvsp[-1].node), (yyvsp[0].node)); (yyval.node) = (yyvsp[-1].node); } 1566 + #line 1567 "parser/parser.c" 1567 + break; 1568 + 1569 + case 57: /* Binds: %empty */ 1570 + #line 205 "parser/parser.y" 1571 + { (yyval.node) = new_node(BINDS_NODE, 0); } 1572 + #line 1573 "parser/parser.c" 1573 + break; 1574 + 1575 + case 58: /* Binds: Binds AttrPath '=' Expression ';' */ 1576 + #line 207 "parser/parser.y" 1577 + { add_child((yyvsp[-4].node), new_node2(BIND_NODE, (yyvsp[-2].token), (yyvsp[-3].node), (yyvsp[-1].node))); (yyval.node) = (yyvsp[-4].node); } 1578 + #line 1579 "parser/parser.c" 1579 + break; 1580 + 1581 + case 59: /* Binds: Binds INHERIT InheritList ';' */ 1582 + #line 209 "parser/parser.y" 1583 + { add_child((yyvsp[-3].node), new_node1(INHERIT_NODE, (yyvsp[-2].token), (yyvsp[-1].node))); (yyval.node) = (yyvsp[-3].node); } 1584 + #line 1585 "parser/parser.c" 1585 + break; 1586 + 1587 + case 60: /* Binds: Binds INHERIT '(' Expression ')' InheritList ';' */ 1588 + #line 211 "parser/parser.y" 1589 + { add_child((yyvsp[-6].node), new_node2(INHERIT_FROM_NODE, (yyvsp[-5].token), (yyvsp[-3].node), (yyvsp[-1].node))); (yyval.node) = (yyvsp[-6].node); } 1590 + #line 1591 "parser/parser.c" 1591 + break; 1592 + 1593 + case 61: /* InheritList: %empty */ 1594 + #line 216 "parser/parser.y" 1595 + { (yyval.node) = new_node(INHERIT_LIST_NODE, 0); } 1596 + #line 1597 "parser/parser.c" 1597 + break; 1598 + 1599 + case 62: /* InheritList: InheritList InterpID */ 1600 + #line 218 "parser/parser.y" 1601 + { add_child((yyvsp[-1].node), (yyvsp[0].node)); (yyval.node) = (yyvsp[-1].node); } 1602 + #line 1603 "parser/parser.c" 1603 + break; 1604 + 1605 + case 63: /* Function: ARG_ID ':' Expression */ 1606 + #line 223 "parser/parser.y" 1607 + { (yyval.node) = new_node2(FUNCTION_NODE, (yyvsp[-1].token), new_node(ID_NODE, (yyvsp[-2].token)), (yyvsp[0].node)); } 1608 + #line 1609 "parser/parser.c" 1609 + break; 1610 + 1611 + case 64: /* Function: ARG_BRACKET ArgSet '}' ':' Expression */ 1612 + #line 225 "parser/parser.y" 1613 + { (yyval.node) = new_node2(FUNCTION_NODE, (yyvsp[-1].token), (yyvsp[-3].node), (yyvsp[0].node)); set_token_end((yyvsp[-3].node), (yyvsp[-2].token)); } 1614 + #line 1615 "parser/parser.c" 1615 + break; 1616 + 1617 + case 65: /* Function: ARG_ID '@' ARG_BRACKET ArgSet '}' ':' Expression */ 1618 + #line 227 "parser/parser.y" 1619 + { (yyval.node) = new_node3(FUNCTION_NODE, (yyvsp[-5].token), new_node(ID_NODE, (yyvsp[-6].token)), (yyvsp[-3].node), (yyvsp[0].node)); set_token_end((yyvsp[-3].node), (yyvsp[-2].token)); } 1620 + #line 1621 "parser/parser.c" 1621 + break; 1622 + 1623 + case 66: /* Function: ARG_BRACKET ArgSet '}' '@' ID ':' Expression */ 1624 + #line 229 "parser/parser.y" 1625 + { (yyval.node) = new_node3(FUNCTION_NODE, (yyvsp[-3].token), (yyvsp[-2].node), (yyvsp[-5].node), (yyvsp[0].node)); set_token_end((yyvsp[-5].node), (yyvsp[-4].token)); } 1626 + #line 1627 "parser/parser.c" 1627 + break; 1628 + 1629 + case 67: /* Function: ARG_BRACKET ArgSet '}' '@' ARG_ID ':' Expression */ 1630 + #line 231 "parser/parser.y" 1631 + { (yyval.node) = new_node3(FUNCTION_NODE, (yyvsp[-3].token), new_node(ID_NODE, (yyvsp[-2].token)), (yyvsp[-5].node), (yyvsp[0].node)); set_token_end((yyvsp[-5].node), (yyvsp[-4].token)); } 1632 + #line 1633 "parser/parser.c" 1633 + break; 1634 + 1635 + case 68: /* ArgSet: %empty */ 1636 + #line 236 "parser/parser.y" 1637 + { (yyval.node) = new_node(ARG_SET_NODE, 0); } 1638 + #line 1639 "parser/parser.c" 1639 + break; 1640 + 1641 + case 69: /* ArgSet: Arg */ 1642 + #line 238 "parser/parser.y" 1643 + { (yyval.node) = new_node1(ARG_SET_NODE, 0, (yyvsp[0].node)); } 1644 + #line 1645 "parser/parser.c" 1645 + break; 1646 + 1647 + case 70: /* ArgSet: ELLIPSIS */ 1648 + #line 240 "parser/parser.y" 1649 + { (yyval.node) = new_node1(ARG_SET_NODE, 0, new_node(ARG_NODE, (yyvsp[0].token))); } 1650 + #line 1651 "parser/parser.c" 1651 + break; 1652 + 1653 + case 71: /* ArgSet: Arg ',' ArgSet */ 1654 + #line 242 "parser/parser.y" 1655 + { add_child((yyvsp[0].node), (yyvsp[-2].node)); (yyval.node) = (yyvsp[0].node); } 1656 + #line 1657 "parser/parser.c" 1657 + break; 1658 + 1659 + case 72: /* Arg: ID */ 1660 + #line 247 "parser/parser.y" 1661 + { (yyval.node) = new_node1(ARG_NODE, 0, (yyvsp[0].node)); } 1662 + #line 1663 "parser/parser.c" 1663 + break; 1664 + 1665 + case 73: /* Arg: ID '?' Expression */ 1666 + #line 249 "parser/parser.y" 1667 + { (yyval.node) = new_node2(ARG_NODE, (yyvsp[-1].token), (yyvsp[-2].node), (yyvsp[0].node)); } 1668 + #line 1669 "parser/parser.c" 1669 + break; 1670 + 1671 + 1672 + #line 1673 "parser/parser.c" 1673 + 1674 + default: break; 1675 + } 1676 + /* User semantic actions sometimes alter yychar, and that requires 1677 + that yytoken be updated with the new translation. We take the 1678 + approach of translating immediately before every use of yytoken. 1679 + One alternative is translating here after every semantic action, 1680 + but that translation would be missed if the semantic action invokes 1681 + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or 1682 + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an 1683 + incorrect destructor might then be invoked immediately. In the 1684 + case of YYERROR or YYBACKUP, subsequent parser actions might lead 1685 + to an incorrect destructor call or verbose syntax error message 1686 + before the lookahead is translated. */ 1687 + YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc); 1688 + 1689 + YYPOPSTACK (yylen); 1690 + yylen = 0; 1691 + 1692 + *++yyvsp = yyval; 1693 + 1694 + /* Now 'shift' the result of the reduction. Determine what state 1695 + that goes to, based on the state we popped back to and the rule 1696 + number reduced by. */ 1697 + { 1698 + const int yylhs = yyr1[yyn] - YYNTOKENS; 1699 + const int yyi = yypgoto[yylhs] + *yyssp; 1700 + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp 1701 + ? yytable[yyi] 1702 + : yydefgoto[yylhs]); 1703 + } 1704 + 1705 + goto yynewstate; 1706 + 1707 + 1708 + /*--------------------------------------. 1709 + | yyerrlab -- here on detecting error. | 1710 + `--------------------------------------*/ 1711 + yyerrlab: 1712 + /* Make sure we have latest lookahead translation. See comments at 1713 + user semantic actions for why this is necessary. */ 1714 + yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar); 1715 + /* If not already recovering from an error, report this error. */ 1716 + if (!yyerrstatus) 1717 + { 1718 + ++yynerrs; 1719 + yyerror (ast_root, scanner, YY_("syntax error")); 1720 + } 1721 + 1722 + if (yyerrstatus == 3) 1723 + { 1724 + /* If just tried and failed to reuse lookahead token after an 1725 + error, discard it. */ 1726 + 1727 + if (yychar <= YYEOF) 1728 + { 1729 + /* Return failure if at end of input. */ 1730 + if (yychar == YYEOF) 1731 + YYABORT; 1732 + } 1733 + else 1734 + { 1735 + yydestruct ("Error: discarding", 1736 + yytoken, &yylval, ast_root, scanner); 1737 + yychar = YYEMPTY; 1738 + } 1739 + } 1740 + 1741 + /* Else will try to reuse lookahead token after shifting the error 1742 + token. */ 1743 + goto yyerrlab1; 1744 + 1745 + 1746 + /*---------------------------------------------------. 1747 + | yyerrorlab -- error raised explicitly by YYERROR. | 1748 + `---------------------------------------------------*/ 1749 + yyerrorlab: 1750 + /* Pacify compilers when the user code never invokes YYERROR and the 1751 + label yyerrorlab therefore never appears in user code. */ 1752 + if (0) 1753 + YYERROR; 1754 + ++yynerrs; 1755 + 1756 + /* Do not reclaim the symbols of the rule whose action triggered 1757 + this YYERROR. */ 1758 + YYPOPSTACK (yylen); 1759 + yylen = 0; 1760 + YY_STACK_PRINT (yyss, yyssp); 1761 + yystate = *yyssp; 1762 + goto yyerrlab1; 1763 + 1764 + 1765 + /*-------------------------------------------------------------. 1766 + | yyerrlab1 -- common code for both syntax error and YYERROR. | 1767 + `-------------------------------------------------------------*/ 1768 + yyerrlab1: 1769 + yyerrstatus = 3; /* Each real token shifted decrements this. */ 1770 + 1771 + /* Pop stack until we find a state that shifts the error token. */ 1772 + for (;;) 1773 + { 1774 + yyn = yypact[yystate]; 1775 + if (!yypact_value_is_default (yyn)) 1776 + { 1777 + yyn += YYSYMBOL_YYerror; 1778 + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror) 1779 + { 1780 + yyn = yytable[yyn]; 1781 + if (0 < yyn) 1782 + break; 1783 + } 1784 + } 1785 + 1786 + /* Pop the current state because it cannot handle the error token. */ 1787 + if (yyssp == yyss) 1788 + YYABORT; 1789 + 1790 + 1791 + yydestruct ("Error: popping", 1792 + YY_ACCESSING_SYMBOL (yystate), yyvsp, ast_root, scanner); 1793 + YYPOPSTACK (1); 1794 + yystate = *yyssp; 1795 + YY_STACK_PRINT (yyss, yyssp); 1796 + } 1797 + 1798 + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1799 + *++yyvsp = yylval; 1800 + YY_IGNORE_MAYBE_UNINITIALIZED_END 1801 + 1802 + 1803 + /* Shift the error token. */ 1804 + YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp); 1805 + 1806 + yystate = yyn; 1807 + goto yynewstate; 1808 + 1809 + 1810 + /*-------------------------------------. 1811 + | yyacceptlab -- YYACCEPT comes here. | 1812 + `-------------------------------------*/ 1813 + yyacceptlab: 1814 + yyresult = 0; 1815 + goto yyreturnlab; 1816 + 1817 + 1818 + /*-----------------------------------. 1819 + | yyabortlab -- YYABORT comes here. | 1820 + `-----------------------------------*/ 1821 + yyabortlab: 1822 + yyresult = 1; 1823 + goto yyreturnlab; 1824 + 1825 + 1826 + /*-----------------------------------------------------------. 1827 + | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. | 1828 + `-----------------------------------------------------------*/ 1829 + yyexhaustedlab: 1830 + yyerror (ast_root, scanner, YY_("memory exhausted")); 1831 + yyresult = 2; 1832 + goto yyreturnlab; 1833 + 1834 + 1835 + /*----------------------------------------------------------. 1836 + | yyreturnlab -- parsing is finished, clean up and return. | 1837 + `----------------------------------------------------------*/ 1838 + yyreturnlab: 1839 + if (yychar != YYEMPTY) 1840 + { 1841 + /* Make sure we have latest lookahead translation. See comments at 1842 + user semantic actions for why this is necessary. */ 1843 + yytoken = YYTRANSLATE (yychar); 1844 + yydestruct ("Cleanup: discarding lookahead", 1845 + yytoken, &yylval, ast_root, scanner); 1846 + } 1847 + /* Do not reclaim the symbols of the rule whose action triggered 1848 + this YYABORT or YYACCEPT. */ 1849 + YYPOPSTACK (yylen); 1850 + YY_STACK_PRINT (yyss, yyssp); 1851 + while (yyssp != yyss) 1852 + { 1853 + yydestruct ("Cleanup: popping", 1854 + YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, ast_root, scanner); 1855 + YYPOPSTACK (1); 1856 + } 1857 + #ifndef yyoverflow 1858 + if (yyss != yyssa) 1859 + YYSTACK_FREE (yyss); 1860 + #endif 1861 + 1862 + return yyresult; 1863 + } 1864 + 1865 + #line 252 "parser/parser.y" 1866 +
+117
parser/parser.h
··· 1 + /* A Bison parser, made by GNU Bison 3.8.2. */ 2 + 3 + /* Bison interface for Yacc-like parsers in C 4 + 5 + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation, 6 + Inc. 7 + 8 + This program is free software: you can redistribute it and/or modify 9 + it under the terms of the GNU General Public License as published by 10 + the Free Software Foundation, either version 3 of the License, or 11 + (at your option) any later version. 12 + 13 + This program is distributed in the hope that it will be useful, 14 + but WITHOUT ANY WARRANTY; without even the implied warranty of 15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 + GNU General Public License for more details. 17 + 18 + You should have received a copy of the GNU General Public License 19 + along with this program. If not, see <https://www.gnu.org/licenses/>. */ 20 + 21 + /* As a special exception, you may create a larger work that contains 22 + part or all of the Bison parser skeleton and distribute that work 23 + under terms of your choice, so long as that work isn't itself a 24 + parser generator using the skeleton or a modified version thereof 25 + as a parser skeleton. Alternatively, if you modify or redistribute 26 + the parser skeleton itself, you may (at your option) remove this 27 + special exception, which will cause the skeleton and the resulting 28 + Bison output files to be licensed under the GNU General Public 29 + License without this special exception. 30 + 31 + This special exception was added by the Free Software Foundation in 32 + version 2.2 of Bison. */ 33 + 34 + /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual, 35 + especially those whose name start with YY_ or yy_. They are 36 + private implementation details that can be changed or removed. */ 37 + 38 + #ifndef YY_YY_PARSER_PARSER_H_INCLUDED 39 + # define YY_YY_PARSER_PARSER_H_INCLUDED 40 + /* Debug traces. */ 41 + #ifndef YYDEBUG 42 + # define YYDEBUG 1 43 + #endif 44 + #if YYDEBUG 45 + extern int yydebug; 46 + #endif 47 + 48 + /* Token kinds. */ 49 + #ifndef YYTOKENTYPE 50 + # define YYTOKENTYPE 51 + enum yytokentype 52 + { 53 + YYEMPTY = -2, 54 + YYEOF = 0, /* "end of file" */ 55 + YYerror = 256, /* error */ 56 + YYUNDEF = 257, /* "invalid token" */ 57 + ASSERT_ = 258, /* ASSERT_ */ 58 + IF_ = 259, /* IF_ */ 59 + THEN = 260, /* THEN */ 60 + ELSE_ = 261, /* ELSE_ */ 61 + LET = 262, /* LET */ 62 + IN = 263, /* IN */ 63 + WITH = 264, /* WITH */ 64 + OR_ = 265, /* OR_ */ 65 + REC = 266, /* REC */ 66 + INHERIT = 267, /* INHERIT */ 67 + ELLIPSIS = 268, /* ELLIPSIS */ 68 + INTERP = 269, /* INTERP */ 69 + SPACE = 270, /* SPACE */ 70 + COMMENT = 271, /* COMMENT */ 71 + II = 272, /* II */ 72 + URI = 273, /* URI */ 73 + PATH = 274, /* PATH */ 74 + FLOAT = 275, /* FLOAT */ 75 + INT_ = 276, /* INT_ */ 76 + T_ID = 277, /* T_ID */ 77 + TEXT = 278, /* TEXT */ 78 + ARG_ID = 279, /* ARG_ID */ 79 + ARG_BRACKET = 280, /* ARG_BRACKET */ 80 + IMPL = 281, /* IMPL */ 81 + OR = 282, /* OR */ 82 + AND = 283, /* AND */ 83 + EQ = 284, /* EQ */ 84 + NEQ = 285, /* NEQ */ 85 + LEQ = 286, /* LEQ */ 86 + GEQ = 287, /* GEQ */ 87 + UPDATE = 288, /* UPDATE */ 88 + CONCAT = 289, /* CONCAT */ 89 + NEGATE = 290 /* NEGATE */ 90 + }; 91 + typedef enum yytokentype yytoken_kind_t; 92 + #endif 93 + 94 + /* Value type. */ 95 + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED 96 + union YYSTYPE 97 + { 98 + #line 34 "parser/parser.y" 99 + 100 + int token; 101 + Node* node; 102 + 103 + #line 104 "parser/parser.h" 104 + 105 + }; 106 + typedef union YYSTYPE YYSTYPE; 107 + # define YYSTYPE_IS_TRIVIAL 1 108 + # define YYSTYPE_IS_DECLARED 1 109 + #endif 110 + 111 + 112 + 113 + 114 + int yyparse (void** ast_root, void* scanner); 115 + 116 + 117 + #endif /* !YY_YY_PARSER_PARSER_H_INCLUDED */
+252
parser/parser.y
··· 1 + %{ 2 + #include "node.h" 3 + #include "lexer.h" 4 + #include <stdio.h> 5 + #include <stdlib.h> 6 + 7 + /* Forward declarations of node helpers implemented in parser/nodetype.c */ 8 + Node* new_node(NodeType type, int token_start); 9 + Node* new_node1(NodeType type, int token_start, Node* n1); 10 + Node* new_node2(NodeType type, int token_start, Node* n1, Node* n2); 11 + Node* new_node3(NodeType type, int token_start, Node* n1, Node* n2, Node* n3); 12 + Node* op_node1(int op, int token_start, Node* n1); 13 + Node* op_node2(int op, int token_start, Node* n1, Node* n2); 14 + void set_node_type(Node* node, NodeType type); 15 + void add_child(Node* parent, Node* child); 16 + void set_token_end(Node* node, int token_end); 17 + 18 + /* yyerror matching the generated parser expectations */ 19 + void yyerror(void **ast_root, void *scanner, const char *s) { 20 + (void)ast_root; (void)scanner; 21 + fprintf(stderr, "parse error: %s\n", s); 22 + } 23 + 24 + /* yylex prototype using void* so it's visible before YYSTYPE is defined in the generated file */ 25 + int yylex(void *yylval_param, void *scanner); 26 + 27 + %} 28 + 29 + %parse-param { void** ast_root } 30 + %parse-param { void* scanner } 31 + %lex-param { void* scanner } 32 + 33 + 34 + %union { 35 + int token; 36 + Node* node; 37 + } 38 + 39 + %type <node> Main Expression Interp String ID Atom Select Apply Op InterpID AttrPath List Binds InheritList Function ArgSet Arg 40 + 41 + %define api.pure full 42 + %debug 43 + 44 + %token <token> ASSERT_ IF_ THEN ELSE_ LET IN WITH OR_ REC INHERIT ELLIPSIS INTERP SPACE COMMENT II 45 + %token <token> URI PATH FLOAT INT_ T_ID TEXT ARG_ID ARG_BRACKET 46 + 47 + %token <token> ':' '@' ',' ';' '"' '.' '(' ')' '[' ']' '{' '}' '=' 48 + 49 + %right <token> IMPL 50 + %left <token> OR 51 + %left <token> AND 52 + %nonassoc <token> EQ NEQ 53 + %left <token> '<' '>' LEQ GEQ 54 + %right <token> UPDATE 55 + %nonassoc <token> '!' 56 + %left <token> '+' '-' 57 + %left <token> '*' '/' 58 + %right <token> CONCAT 59 + %nonassoc <token> '?' 60 + %nonassoc <token> NEGATE 61 + 62 + %% 63 + 64 + 65 + Main 66 + : Expression 67 + { *ast_root = $1; } 68 + ; 69 + 70 + Expression 71 + : Op 72 + | ASSERT_ Expression ';' Expression 73 + { $$ = new_node2(ASSERT_NODE, $1, $2, $4); set_token_end($$, $3); } 74 + | IF_ Expression THEN Expression ELSE_ Expression 75 + { $$ = new_node3(IF_NODE, $1, $2, $4, $6); set_token_end($$, $3); } 76 + | LET Binds IN Expression 77 + { $$ = new_node2(LET_NODE, $1, $2, $4); set_token_end($$, $3); } 78 + | WITH Expression ';' Expression 79 + { $$ = new_node2(WITH_NODE, $1, $2, $4); set_token_end($$, $3); } 80 + | Function 81 + ; 82 + 83 + Interp 84 + : INTERP Expression '}' 85 + { $$ = new_node1(INTERP_NODE, $1, $2); set_token_end($$, $3); } 86 + ; 87 + 88 + String 89 + : 90 + { $$ = new_node(STRING_NODE, 0); } 91 + | String TEXT 92 + { add_child($1, new_node(TEXT_NODE, $2)); $$ = $1; } 93 + | String Interp 94 + { add_child($1, $2); $$ = $1; } 95 + ; 96 + 97 + ID 98 + : T_ID 99 + { $$ = new_node(ID_NODE, $1); } 100 + ; 101 + 102 + Atom 103 + : URI 104 + { $$ = new_node(URI_NODE, $1); } 105 + | PATH 106 + { $$ = new_node(PATH_NODE, $1); } 107 + | FLOAT 108 + { $$ = new_node(FLOAT_NODE, $1); } 109 + | INT_ 110 + { $$ = new_node(INT_NODE, $1); } 111 + | ID 112 + | '"' String '"' 113 + { set_token_end($2, $3); $$ = $2; } 114 + | II String II 115 + { set_node_type($2, I_STRING_NODE); set_token_end($2, $3); $$ = $2; } 116 + | '(' Expression ')' 117 + { $$ = new_node1(PARENS_NODE, $1, $2); set_token_end($$, $3); } 118 + | '[' List ']' 119 + { set_token_end($2, $3); $$ = $2; } 120 + | '{' Binds '}' 121 + { set_node_type($2, SET_NODE); set_token_end($2, $3); $$ = $2; } 122 + | REC '{' Binds '}' 123 + { set_node_type($3, REC_SET_NODE); set_token_end($3, $4); $$ = $3; } 124 + ; 125 + 126 + Select 127 + : Atom 128 + | Atom '.' AttrPath 129 + { $$ = new_node2(SELECT_NODE, $2, $1, $3); } 130 + | Atom '.' AttrPath OR_ Select 131 + { $$ = new_node3(SELECT_OR_NODE, $2, $1, $3, $5); set_token_end($$, $4); } 132 + ; 133 + 134 + Apply 135 + : Select 136 + | Apply Select 137 + { $$ = new_node2(APPLY_NODE, 0, $1, $2); } 138 + ; 139 + 140 + Op 141 + : Apply 142 + | '-' Op %prec NEGATE 143 + { $$ = op_node1('-', $1, $2); } 144 + | Op '?' AttrPath 145 + { $$ = op_node2('?', $2, $1, $3); } 146 + | Op CONCAT Op 147 + { $$ = op_node2(CONCAT, $2, $1, $3); } 148 + | Op '/' Op 149 + { $$ = op_node2('/', $2, $1, $3); } 150 + | Op '*' Op 151 + { $$ = op_node2('*', $2, $1, $3); } 152 + | Op '-' Op 153 + { $$ = op_node2('-', $2, $1, $3); } 154 + | Op '+' Op 155 + { $$ = op_node2('+', $2, $1, $3); } 156 + | '!' Op 157 + { $$ = op_node1('!', $1, $2); } 158 + | Op UPDATE Op 159 + { $$ = op_node2(UPDATE, $2, $1, $3); } 160 + | Op GEQ Op 161 + { $$ = op_node2(GEQ, $2, $1, $3); } 162 + | Op LEQ Op 163 + { $$ = op_node2(LEQ, $2, $1, $3); } 164 + | Op '>' Op 165 + { $$ = op_node2('>', $2, $1, $3); } 166 + | Op '<' Op 167 + { $$ = op_node2('<', $2, $1, $3); } 168 + | Op NEQ Op 169 + { $$ = op_node2(NEQ, $2, $1, $3); } 170 + | Op EQ Op 171 + { $$ = op_node2(EQ, $2, $1, $3); } 172 + | Op AND Op 173 + { $$ = op_node2(AND, $2, $1, $3); } 174 + | Op OR Op 175 + { $$ = op_node2(OR, $2, $1, $3); } 176 + | Op IMPL Op 177 + { $$ = op_node2(IMPL, $2, $1, $3); } 178 + ; 179 + 180 + InterpID 181 + : ID 182 + | OR_ 183 + { $$ = new_node(ID_NODE, $1); } 184 + | Interp 185 + | '"' String '"' 186 + { set_token_end($2, $3); $$ = $2; } 187 + ; 188 + 189 + AttrPath 190 + : InterpID 191 + { $$ = new_node1(ATTR_PATH_NODE, 0, $1); } 192 + | AttrPath '.' InterpID 193 + { add_child($1, $3); set_token_end($1, 0); $$ = $1; } 194 + ; 195 + 196 + List 197 + : 198 + { $$ = new_node(LIST_NODE, 0); } 199 + | List Select 200 + { add_child($1, $2); $$ = $1; } 201 + ; 202 + 203 + Binds 204 + : 205 + { $$ = new_node(BINDS_NODE, 0); } 206 + | Binds AttrPath '=' Expression ';' 207 + { add_child($1, new_node2(BIND_NODE, $3, $2, $4)); $$ = $1; } 208 + | Binds INHERIT InheritList ';' 209 + { add_child($1, new_node1(INHERIT_NODE, $2, $3)); $$ = $1; } 210 + | Binds INHERIT '(' Expression ')' InheritList ';' 211 + { add_child($1, new_node2(INHERIT_FROM_NODE, $2, $4, $6)); $$ = $1; } 212 + ; 213 + 214 + InheritList 215 + : 216 + { $$ = new_node(INHERIT_LIST_NODE, 0); } 217 + | InheritList InterpID 218 + { add_child($1, $2); $$ = $1; } 219 + ; 220 + 221 + Function 222 + : ARG_ID ':' Expression 223 + { $$ = new_node2(FUNCTION_NODE, $2, new_node(ID_NODE, $1), $3); } 224 + | ARG_BRACKET ArgSet '}' ':' Expression 225 + { $$ = new_node2(FUNCTION_NODE, $4, $2, $5); set_token_end($2, $3); } 226 + | ARG_ID '@' ARG_BRACKET ArgSet '}' ':' Expression 227 + { $$ = new_node3(FUNCTION_NODE, $2, new_node(ID_NODE, $1), $4, $7); set_token_end($4, $5); } 228 + | ARG_BRACKET ArgSet '}' '@' ID ':' Expression 229 + { $$ = new_node3(FUNCTION_NODE, $4, $5, $2, $7); set_token_end($2, $3); } 230 + | ARG_BRACKET ArgSet '}' '@' ARG_ID ':' Expression 231 + { $$ = new_node3(FUNCTION_NODE, $4, new_node(ID_NODE, $5), $2, $7); set_token_end($2, $3); } 232 + ; 233 + 234 + ArgSet 235 + : 236 + { $$ = new_node(ARG_SET_NODE, 0); } 237 + | Arg 238 + { $$ = new_node1(ARG_SET_NODE, 0, $1); } 239 + | ELLIPSIS 240 + { $$ = new_node1(ARG_SET_NODE, 0, new_node(ARG_NODE, $1)); } 241 + | Arg ',' ArgSet 242 + { add_child($3, $1); $$ = $3; } 243 + ; 244 + 245 + Arg 246 + : ID 247 + { $$ = new_node1(ARG_NODE, 0, $1); } 248 + | ID '?' Expression 249 + { $$ = new_node2(ARG_NODE, $2, $1, $3); } 250 + ; 251 + 252 + %%
+43
parser/tokens.h
··· 1 + #ifndef PARSER_TOKENS_H 2 + #define PARSER_TOKENS_H 3 + 4 + /* Token numbers derived from the legacy Go parser (yyPrivate based). */ 5 + #define YYPRIVATE 57344 6 + 7 + #define ASSERT_ 57346 8 + #define IF_ 57347 9 + #define THEN 57348 10 + #define ELSE_ 57349 11 + #define LET 57350 12 + #define IN 57351 13 + #define WITH 57352 14 + #define OR_ 57353 15 + #define REC 57354 16 + #define INHERIT 57355 17 + #define ELLIPSIS 57356 18 + #define INTERP 57357 19 + #define SPACE 57358 20 + #define COMMENT 57359 21 + #define II 57360 22 + #define URI 57361 23 + #define PATH 57362 24 + #define FLOAT 57363 25 + #define INT_ 57364 26 + #define T_ID 57365 27 + #define ID 57365 /* alias */ 28 + #define TEXT 57366 29 + #define ARG_ID 57367 30 + #define ARG_BRACKET 57368 31 + 32 + #define IMPL 57369 33 + #define OR 57370 34 + #define AND 57371 35 + #define EQ 57372 36 + #define NEQ 57373 37 + #define LEQ 57374 38 + #define GEQ 57375 39 + #define UPDATE 57376 40 + #define CONCAT 57377 41 + #define NEGATE 57378 42 + 43 + #endif /* PARSER_TOKENS_H */
+107
parser/walk.c
··· 1 + #define _XOPEN_SOURCE 700 2 + 3 + #include <stdio.h> 4 + #include <stdlib.h> 5 + #include <string.h> 6 + #include <ftw.h> 7 + #include <errno.h> 8 + #include <sys/stat.h> 9 + 10 + #include "lexer_adapter.h" 11 + #include "node.h" 12 + #include "parser.h" 13 + 14 + static size_t total_files = 0; 15 + static size_t ok_count = 0; 16 + static size_t fail_count = 0; 17 + 18 + /* dynamic array of failed paths */ 19 + static char **failed_paths = NULL; 20 + static size_t failed_capacity = 0; 21 + static size_t failed_len = 0; 22 + 23 + static void add_failed(const char *path) { 24 + if (failed_len + 1 > failed_capacity) { 25 + size_t nc = failed_capacity ? failed_capacity * 2 : 64; 26 + char **n = realloc(failed_paths, nc * sizeof(char*)); 27 + if (!n) return; 28 + failed_paths = n; 29 + failed_capacity = nc; 30 + } 31 + /* use manual strdup to avoid relying on POSIX strdup */ 32 + size_t l = strlen(path) + 1; 33 + char *s = malloc(l); 34 + if (s) memcpy(s, path, l); 35 + failed_paths[failed_len++] = s; 36 + } 37 + 38 + static int has_nix_ext(const char *path) { 39 + size_t n = strlen(path); 40 + if (n < 4) return 0; 41 + return strcmp(path + n - 4, ".nix") == 0; 42 + } 43 + 44 + static int process_file(const char *path) { 45 + FILE *f = fopen(path, "rb"); 46 + if (!f) return -1; 47 + if (fseek(f, 0, SEEK_END) != 0) { fclose(f); return -1; } 48 + long sz = ftell(f); 49 + if (sz < 0) { fclose(f); return -1; } 50 + if (fseek(f, 0, SEEK_SET) != 0) { fclose(f); return -1; } 51 + char *buf = malloc((size_t)sz); 52 + if (!buf) { fclose(f); return -1; } 53 + if (fread(buf, 1, (size_t)sz, f) != (size_t)sz) { fclose(f); free(buf); return -1; } 54 + fclose(f); 55 + 56 + void *scanner = create_scanner(buf, (int)sz, path); 57 + if (!scanner) { free(buf); return -1; } 58 + 59 + void *ast = NULL; 60 + int perr = yyparse(&ast, scanner); 61 + if (perr == 0 && ast != NULL) { 62 + ok_count++; 63 + } else { 64 + fail_count++; 65 + add_failed(path); 66 + } 67 + 68 + free_scanner(scanner); 69 + free(buf); 70 + total_files++; 71 + return 0; 72 + } 73 + 74 + static int walk_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) { 75 + (void)sb; (void)ftwbuf; 76 + if (typeflag == FTW_F && has_nix_ext(fpath)) { 77 + process_file(fpath); 78 + } 79 + return 0; /* continue */ 80 + } 81 + 82 + int main(int argc, char **argv) { 83 + if (argc < 2) { 84 + fprintf(stderr, "usage: %s <directory>\n", argv[0]); 85 + return 2; 86 + } 87 + const char *dir = argv[1]; 88 + 89 + /* nftw with reasonable limits */ 90 + if (nftw(dir, walk_cb, 20, FTW_PHYS) != 0) { 91 + fprintf(stderr, "nftw failed: %s\n", strerror(errno)); 92 + return 1; 93 + } 94 + 95 + printf("total .nix files: %zu\n", total_files); 96 + printf("parsed ok: %zu\n", ok_count); 97 + printf("parsed failed: %zu\n", fail_count); 98 + if (fail_count > 0) { 99 + printf("failed paths:\n"); 100 + for (size_t i = 0; i < failed_len; ++i) { 101 + printf("%s\n", failed_paths[i]); 102 + free(failed_paths[i]); 103 + } 104 + } 105 + free(failed_paths); 106 + return 0; 107 + }