diff options
| author | Root THC | 2026-02-24 12:42:47 +0000 |
|---|---|---|
| committer | Root THC | 2026-02-24 12:42:47 +0000 |
| commit | c9cbeced5b3f2bdd7407e29c0811e65954132540 (patch) | |
| tree | aefc355416b561111819de159ccbd86c3004cf88 /other/gramble | |
| parent | 073fe4bf9fca6bf40cef2886d75df832ef4b6fca (diff) | |
initial
Diffstat (limited to 'other/gramble')
| -rw-r--r-- | other/gramble/FORMAT | 6 | ||||
| -rw-r--r-- | other/gramble/Makefile | 42 | ||||
| -rw-r--r-- | other/gramble/common.c | 370 | ||||
| -rw-r--r-- | other/gramble/common.h | 31 | ||||
| -rw-r--r-- | other/gramble/common.o | bin | 0 -> 28708 bytes | |||
| -rw-r--r-- | other/gramble/compiler.l | 95 | ||||
| -rw-r--r-- | other/gramble/compiler.y | 271 | ||||
| -rw-r--r-- | other/gramble/input-driver.c | 105 | ||||
| -rw-r--r-- | other/gramble/input-driver.o | bin | 0 -> 11232 bytes | |||
| -rw-r--r-- | other/gramble/input-test | bin | 0 -> 92539 bytes | |||
| -rw-r--r-- | other/gramble/input-test.c | 76 | ||||
| -rw-r--r-- | other/gramble/input.h | 17 | ||||
| -rw-r--r-- | other/gramble/input.l | 61 | ||||
| -rw-r--r-- | other/gramble/input.y | 110 | ||||
| -rw-r--r-- | other/gramble/lex.yy.c | 1597 | ||||
| -rw-r--r-- | other/gramble/lex.yy.o | bin | 0 -> 29416 bytes | |||
| -rw-r--r-- | other/gramble/producer.c | 103 | ||||
| -rw-r--r-- | other/gramble/test | 5 | ||||
| -rw-r--r-- | other/gramble/y.output | 347 | ||||
| -rw-r--r-- | other/gramble/y.tab.c | 1303 | ||||
| -rw-r--r-- | other/gramble/y.tab.h | 71 | ||||
| -rw-r--r-- | other/gramble/y.tab.o | bin | 0 -> 23288 bytes |
22 files changed, 4610 insertions, 0 deletions
diff --git a/other/gramble/FORMAT b/other/gramble/FORMAT new file mode 100644 index 0000000..41cc6db --- /dev/null +++ b/other/gramble/FORMAT | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | |||
| 2 | |||
| 3 | prodname: | ||
| 4 | [prod|strings*](size:min-max)(filter:/filter/)(~filter:/filterinverted/) | ||
| 5 | |||
| 6 | |||
diff --git a/other/gramble/Makefile b/other/gramble/Makefile new file mode 100644 index 0000000..27e8c72 --- /dev/null +++ b/other/gramble/Makefile | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | CC = gcc | ||
| 2 | #CFLAGS = -Wall -O2 -static | ||
| 3 | CFLAGS = -Wall -ggdb | ||
| 4 | #CFLAGS = -Wall -ggdb -DDEBUG | ||
| 5 | #CFLAGS = -Wall -ggdb -DYYDEBUG -DDEBUG | ||
| 6 | |||
| 7 | LIBS = | ||
| 8 | |||
| 9 | YACC = yacc | ||
| 10 | YACCOPT = -d -v -t | ||
| 11 | LEX = lex | ||
| 12 | LEXOPT = | ||
| 13 | |||
| 14 | OBJS = common.o \ | ||
| 15 | y.tab.o lex.yy.o input-driver.o | ||
| 16 | |||
| 17 | |||
| 18 | all: inputtest | ||
| 19 | |||
| 20 | link: $(OBJS) | ||
| 21 | |||
| 22 | dist: lex.yy.c y.tab.h | ||
| 23 | |||
| 24 | inputtest: $(OBJS) input-test.c | ||
| 25 | $(CC) -o input-test input-test.c $(OBJS) $(CFLAGS) $(LIBS) | ||
| 26 | |||
| 27 | gramble: $(OBJS) | ||
| 28 | $(CC) -o gramble $(OBJS) $(CFLAGS) $(LIBS) | ||
| 29 | |||
| 30 | lex.yy.o: lex.yy.c y.tab.h | ||
| 31 | |||
| 32 | lex.yy.c: input.l | ||
| 33 | $(LEX) $(LEXOPT) input.l | ||
| 34 | |||
| 35 | y.tab.c y.tab.h: input.y | ||
| 36 | $(YACC) $(YACCOPT) input.y | ||
| 37 | |||
| 38 | clean: | ||
| 39 | rm -f y.tab.c y.tab.h y.output lex.yy.c | ||
| 40 | rm -f gramble | ||
| 41 | rm -f *.o | ||
| 42 | |||
diff --git a/other/gramble/common.c b/other/gramble/common.c new file mode 100644 index 0000000..fa15d47 --- /dev/null +++ b/other/gramble/common.c | |||
| @@ -0,0 +1,370 @@ | |||
| 1 | |||
| 2 | #include <sys/types.h> | ||
| 3 | #include <sys/wait.h> | ||
| 4 | #include <sys/time.h> | ||
| 5 | #include <netinet/in.h> | ||
| 6 | #include <unistd.h> | ||
| 7 | #include <time.h> | ||
| 8 | #include <stdarg.h> | ||
| 9 | #include <stdio.h> | ||
| 10 | #include <string.h> | ||
| 11 | #include <stdlib.h> | ||
| 12 | #include <unistd.h> | ||
| 13 | #include "common.h" | ||
| 14 | |||
| 15 | |||
| 16 | #ifdef DEBUG | ||
| 17 | void | ||
| 18 | debugp (char *filename, const char *str, ...) | ||
| 19 | { | ||
| 20 | FILE *fp; /* temporary file pointer */ | ||
| 21 | va_list vl; | ||
| 22 | |||
| 23 | fp = fopen (filename, "a"); | ||
| 24 | if (fp == NULL) | ||
| 25 | return; | ||
| 26 | |||
| 27 | va_start (vl, str); | ||
| 28 | vfprintf (fp, str, vl); | ||
| 29 | va_end (vl); | ||
| 30 | |||
| 31 | fclose (fp); | ||
| 32 | |||
| 33 | return; | ||
| 34 | } | ||
| 35 | |||
| 36 | void | ||
| 37 | hexdump (char *filename, unsigned char *data, unsigned int amount) | ||
| 38 | { | ||
| 39 | FILE *fp; /* temporary file pointer */ | ||
| 40 | unsigned int dp, p; /* data pointer */ | ||
| 41 | const char trans[] = | ||
| 42 | "................................ !\"#$%&'()*+,-./0123456789" | ||
| 43 | ":;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklm" | ||
| 44 | "nopqrstuvwxyz{|}~...................................." | ||
| 45 | "....................................................." | ||
| 46 | "........................................"; | ||
| 47 | |||
| 48 | fp = fopen (filename, "a"); | ||
| 49 | if (fp == NULL) | ||
| 50 | return; | ||
| 51 | |||
| 52 | fprintf (fp, "\n-packet-\n"); | ||
| 53 | |||
| 54 | for (dp = 1; dp <= amount; dp++) { | ||
| 55 | fprintf (fp, "%02x ", data[dp-1]); | ||
| 56 | if ((dp % 8) == 0) | ||
| 57 | fprintf (fp, " "); | ||
| 58 | if ((dp % 16) == 0) { | ||
| 59 | fprintf (fp, "| "); | ||
| 60 | p = dp; | ||
| 61 | for (dp -= 16; dp < p; dp++) | ||
| 62 | fprintf (fp, "%c", trans[data[dp]]); | ||
| 63 | fflush (fp); | ||
| 64 | fprintf (fp, "\n"); | ||
| 65 | } | ||
| 66 | fflush (fp); | ||
| 67 | } | ||
| 68 | if ((amount % 16) != 0) { | ||
| 69 | p = dp = 16 - (amount % 16); | ||
| 70 | for (dp = p; dp > 0; dp--) { | ||
| 71 | fprintf (fp, " "); | ||
| 72 | if (((dp % 8) == 0) && (p != 8)) | ||
| 73 | fprintf (fp, " "); | ||
| 74 | fflush (fp); | ||
| 75 | } | ||
| 76 | fprintf (fp, " | "); | ||
| 77 | for (dp = (amount - (16 - p)); dp < amount; dp++) | ||
| 78 | fprintf (fp, "%c", trans[data[dp]]); | ||
| 79 | fflush (fp); | ||
| 80 | } | ||
| 81 | fprintf (fp, "\n"); | ||
| 82 | |||
| 83 | fclose (fp); | ||
| 84 | return; | ||
| 85 | } | ||
| 86 | |||
| 87 | #endif | ||
| 88 | |||
| 89 | |||
| 90 | /* z_fork | ||
| 91 | * | ||
| 92 | * fork and detach forked client completely to avoid zombies. | ||
| 93 | * taken from richard stevens excellent system programming book :) thanks, | ||
| 94 | * whereever you are now. | ||
| 95 | * | ||
| 96 | * caveat: the pid of the child has already died, it can just be used to | ||
| 97 | * differentiate between parent and not parent, the pid of the | ||
| 98 | * child is inaccessibly. | ||
| 99 | * | ||
| 100 | * return pid of child for old process | ||
| 101 | * return 0 for child | ||
| 102 | */ | ||
| 103 | |||
| 104 | pid_t | ||
| 105 | z_fork (void) | ||
| 106 | { | ||
| 107 | pid_t pid; | ||
| 108 | |||
| 109 | pid = fork (); | ||
| 110 | if (pid < 0) { | ||
| 111 | return (pid); | ||
| 112 | } else if (pid == 0) { | ||
| 113 | /* let the child fork again | ||
| 114 | */ | ||
| 115 | |||
| 116 | pid = fork (); | ||
| 117 | if (pid < 0) { | ||
| 118 | return (pid); | ||
| 119 | } else if (pid > 0) { | ||
| 120 | /* let the child and parent of the second child | ||
| 121 | * exit | ||
| 122 | */ | ||
| 123 | exit (EXIT_SUCCESS); | ||
| 124 | } | ||
| 125 | |||
| 126 | return (0); | ||
| 127 | } | ||
| 128 | |||
| 129 | waitpid (pid, NULL, 0); | ||
| 130 | |||
| 131 | return (pid); | ||
| 132 | } | ||
| 133 | |||
| 134 | |||
| 135 | /* m_random | ||
| 136 | * | ||
| 137 | * return a random number between `lowmark' and `highmark' | ||
| 138 | */ | ||
| 139 | |||
| 140 | int | ||
| 141 | m_random (int lowmark, int highmark) | ||
| 142 | { | ||
| 143 | long int rnd; | ||
| 144 | |||
| 145 | /* flip/swap them in case user messed up | ||
| 146 | */ | ||
| 147 | if (lowmark > highmark) { | ||
| 148 | lowmark ^= highmark; | ||
| 149 | highmark ^= lowmark; | ||
| 150 | lowmark ^= highmark; | ||
| 151 | } | ||
| 152 | rnd = lowmark; | ||
| 153 | |||
| 154 | rnd += (random () % (highmark - lowmark)); | ||
| 155 | |||
| 156 | /* this is lame, i know :) | ||
| 157 | */ | ||
| 158 | return (rnd); | ||
| 159 | } | ||
| 160 | |||
| 161 | |||
| 162 | /* set_tv | ||
| 163 | * | ||
| 164 | * initializes a struct timeval pointed to by `tv' to a second value of | ||
| 165 | * `seconds' | ||
| 166 | * | ||
| 167 | * return in any case | ||
| 168 | */ | ||
| 169 | |||
| 170 | void | ||
| 171 | set_tv (struct timeval *tv, int seconds) | ||
| 172 | { | ||
| 173 | tv->tv_sec = seconds; | ||
| 174 | tv->tv_usec = 0; | ||
| 175 | |||
| 176 | return; | ||
| 177 | } | ||
| 178 | |||
| 179 | |||
| 180 | /* xstrupper | ||
| 181 | * | ||
| 182 | * uppercase a string `str' | ||
| 183 | * | ||
| 184 | * return in any case | ||
| 185 | */ | ||
| 186 | |||
| 187 | void | ||
| 188 | xstrupper (char *str) | ||
| 189 | { | ||
| 190 | for (; *str != '\0'; ++str) { | ||
| 191 | if (*str >= 'a' && *str <= 'z') { | ||
| 192 | *str -= ('a' - 'A'); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | |||
| 196 | return; | ||
| 197 | } | ||
| 198 | |||
| 199 | |||
| 200 | /* concating snprintf | ||
| 201 | * | ||
| 202 | * determines the length of the string pointed to by `os', appending formatted | ||
| 203 | * string to a maximium length of `len'. | ||
| 204 | * | ||
| 205 | */ | ||
| 206 | |||
| 207 | void | ||
| 208 | scnprintf (char *os, size_t len, const char *str, ...) | ||
| 209 | { | ||
| 210 | va_list vl; | ||
| 211 | char *ostmp = os + strlen (os); | ||
| 212 | |||
| 213 | va_start (vl, str); | ||
| 214 | vsnprintf (ostmp, len - strlen (os) - 1, str, vl); | ||
| 215 | va_end (vl); | ||
| 216 | |||
| 217 | return; | ||
| 218 | } | ||
| 219 | |||
| 220 | unsigned long int | ||
| 221 | tdiff (struct timeval *old, struct timeval *new) | ||
| 222 | { | ||
| 223 | unsigned long int time1; | ||
| 224 | |||
| 225 | if (new->tv_sec >= old->tv_sec) { | ||
| 226 | time1 = new->tv_sec - old->tv_sec; | ||
| 227 | if ((new->tv_usec - 500000) >= old->tv_usec) | ||
| 228 | time1++; | ||
| 229 | } else { | ||
| 230 | time1 = old->tv_sec - new->tv_sec; | ||
| 231 | if ((old->tv_usec - 500000) >= new->tv_usec) | ||
| 232 | time1++; | ||
| 233 | } | ||
| 234 | |||
| 235 | return (time1); | ||
| 236 | } | ||
| 237 | |||
| 238 | |||
| 239 | /* ipv4_print | ||
| 240 | * | ||
| 241 | * padding = 0 -> don't padd | ||
| 242 | * padding = 1 -> padd with zeros | ||
| 243 | * padding = 2 -> padd with spaces | ||
| 244 | */ | ||
| 245 | |||
| 246 | char * | ||
| 247 | ipv4_print (char *dest, struct in_addr in, int padding) | ||
| 248 | { | ||
| 249 | unsigned char *ipp; | ||
| 250 | |||
| 251 | ipp = (unsigned char *) &in.s_addr; | ||
| 252 | |||
| 253 | strcpy (dest, ""); | ||
| 254 | |||
| 255 | switch (padding) { | ||
| 256 | case (0): | ||
| 257 | sprintf (dest, "%d.%d.%d.%d", ipp[0], ipp[1], ipp[2], ipp[3]); | ||
| 258 | break; | ||
| 259 | case (1): | ||
| 260 | sprintf (dest, "%03d.%03d.%03d.%03d", ipp[0], ipp[1], ipp[2], ipp[3]); | ||
| 261 | break; | ||
| 262 | case (2): | ||
| 263 | sprintf (dest, "%3d.%3d.%3d.%3d", ipp[0], ipp[1], ipp[2], ipp[3]); | ||
| 264 | break; | ||
| 265 | default: | ||
| 266 | break; | ||
| 267 | } | ||
| 268 | |||
| 269 | return (dest); | ||
| 270 | } | ||
| 271 | |||
| 272 | |||
| 273 | void * | ||
| 274 | xrealloc (void *m_ptr, size_t newsize) | ||
| 275 | { | ||
| 276 | void *n_ptr; | ||
| 277 | |||
| 278 | n_ptr = realloc (m_ptr, newsize); | ||
| 279 | if (n_ptr == NULL) { | ||
| 280 | fprintf (stderr, "realloc failed\n"); | ||
| 281 | exit (EXIT_FAILURE); | ||
| 282 | } | ||
| 283 | |||
| 284 | return (n_ptr); | ||
| 285 | } | ||
| 286 | |||
| 287 | |||
| 288 | char * | ||
| 289 | xstrdup (char *str) | ||
| 290 | { | ||
| 291 | char *b; | ||
| 292 | |||
| 293 | b = strdup (str); | ||
| 294 | if (b == NULL) { | ||
| 295 | fprintf (stderr, "strdup failed\n"); | ||
| 296 | exit (EXIT_FAILURE); | ||
| 297 | } | ||
| 298 | |||
| 299 | return (b); | ||
| 300 | } | ||
| 301 | |||
| 302 | |||
| 303 | void * | ||
| 304 | xcalloc (int factor, size_t size) | ||
| 305 | { | ||
| 306 | void *bla; | ||
| 307 | |||
| 308 | bla = calloc (factor, size); | ||
| 309 | |||
| 310 | if (bla == NULL) { | ||
| 311 | fprintf (stderr, "no memory left\n"); | ||
| 312 | exit (EXIT_FAILURE); | ||
| 313 | } | ||
| 314 | |||
| 315 | return (bla); | ||
| 316 | } | ||
| 317 | |||
| 318 | /* source by dk | ||
| 319 | */ | ||
| 320 | |||
| 321 | char * | ||
| 322 | allocncat (char **to, char *from, size_t len) | ||
| 323 | { | ||
| 324 | int rlen = strlen (from); | ||
| 325 | int null = (*to == NULL); | ||
| 326 | |||
| 327 | len = rlen < len ? rlen : len; | ||
| 328 | *to = xrealloc (*to, (null ? 0 : strlen (*to)) + len + 1); | ||
| 329 | if (null) | ||
| 330 | **to = '\0'; | ||
| 331 | |||
| 332 | return (strncat (*to, from, len)); | ||
| 333 | } | ||
| 334 | |||
| 335 | |||
| 336 | char * | ||
| 337 | alloccat (char **to, char *from) | ||
| 338 | { | ||
| 339 | return (allocncat (to, from, strlen (from))); | ||
| 340 | } | ||
| 341 | |||
| 342 | |||
| 343 | char * | ||
| 344 | file_load (char *pathname) | ||
| 345 | { | ||
| 346 | FILE * fp; | ||
| 347 | char * new; | ||
| 348 | |||
| 349 | if (pathname == NULL) | ||
| 350 | return (NULL); | ||
| 351 | |||
| 352 | fp = fopen (pathname, "r"); | ||
| 353 | if (fp == NULL) | ||
| 354 | return (NULL); | ||
| 355 | |||
| 356 | new = NULL; | ||
| 357 | while (feof (fp) == 0) { | ||
| 358 | unsigned long int rpos; | ||
| 359 | |||
| 360 | rpos = (new == NULL) ? 0 : strlen (new); | ||
| 361 | new = xrealloc (new, rpos + 1024); | ||
| 362 | memset (new + rpos, '\x00', 1024); | ||
| 363 | fread (new + rpos, sizeof (char), 1023, fp); | ||
| 364 | } | ||
| 365 | fclose (fp); | ||
| 366 | new = xrealloc (new, strlen (new) + 1); | ||
| 367 | |||
| 368 | return (new); | ||
| 369 | } | ||
| 370 | |||
diff --git a/other/gramble/common.h b/other/gramble/common.h new file mode 100644 index 0000000..f9b9f66 --- /dev/null +++ b/other/gramble/common.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | |||
| 2 | #ifndef Z_COMMON_H | ||
| 3 | #define Z_COMMON_H | ||
| 4 | |||
| 5 | |||
| 6 | #include <sys/types.h> | ||
| 7 | #include <sys/time.h> | ||
| 8 | #include <netinet/in.h> | ||
| 9 | #include <unistd.h> | ||
| 10 | |||
| 11 | |||
| 12 | #ifdef DEBUG | ||
| 13 | void debugp (char *filename, const char *str, ...); | ||
| 14 | void hexdump (char *filename, unsigned char *data, unsigned int amount); | ||
| 15 | #endif | ||
| 16 | pid_t z_fork (void); | ||
| 17 | int m_random (int lowmark, int highmark); | ||
| 18 | void set_tv (struct timeval *tv, int seconds); | ||
| 19 | void xstrupper (char *str); | ||
| 20 | void scnprintf (char *os, size_t len, const char *str, ...); | ||
| 21 | unsigned long int tdiff (struct timeval *old, struct timeval *new); | ||
| 22 | char * ipv4_print (char *dest, struct in_addr in, int padding); | ||
| 23 | void * xrealloc (void *m_ptr, size_t newsize); | ||
| 24 | char * xstrdup (char *str); | ||
| 25 | void * xcalloc (int factor, size_t size); | ||
| 26 | char * allocncat (char **to, char *from, size_t len); | ||
| 27 | char * alloccat (char **to, char *from); | ||
| 28 | char * file_load (char *pathname); | ||
| 29 | |||
| 30 | #endif | ||
| 31 | |||
diff --git a/other/gramble/common.o b/other/gramble/common.o new file mode 100644 index 0000000..18b6d2f --- /dev/null +++ b/other/gramble/common.o | |||
| Binary files differ | |||
diff --git a/other/gramble/compiler.l b/other/gramble/compiler.l new file mode 100644 index 0000000..1dbb21b --- /dev/null +++ b/other/gramble/compiler.l | |||
| @@ -0,0 +1,95 @@ | |||
| 1 | /* fornax - distributed packet network | ||
| 2 | * | ||
| 3 | * by team teso | ||
| 4 | * | ||
| 5 | * lex command lexical analyzer | ||
| 6 | */ | ||
| 7 | |||
| 8 | |||
| 9 | %{ | ||
| 10 | #undef yywrap | ||
| 11 | |||
| 12 | #include <string.h> | ||
| 13 | #include "../../shared/common.h" | ||
| 14 | #include "branch.h" | ||
| 15 | #include "call.h" | ||
| 16 | #include "compiler.h" | ||
| 17 | #include "condition.h" | ||
| 18 | #include "element.h" | ||
| 19 | #include "symbol.h" | ||
| 20 | #include "y.tab.h" | ||
| 21 | |||
| 22 | #undef ECHO | ||
| 23 | #undef YY_INPUT | ||
| 24 | #define YY_INPUT(b, r, ms) (r = cp_yyinput (b, ms)) | ||
| 25 | |||
| 26 | %} | ||
| 27 | |||
| 28 | %% | ||
| 29 | |||
| 30 | [\n\t ]+ ; /* strip any whitespaces */ | ||
| 31 | |||
| 32 | \{ { | ||
| 33 | return (EXPR_BLOCK_BEGIN); | ||
| 34 | } | ||
| 35 | |||
| 36 | \} { | ||
| 37 | return (EXPR_BLOCK_END); | ||
| 38 | } | ||
| 39 | |||
| 40 | \"[^\"]*\" { | ||
| 41 | yylval.str = xstrdup (yytext + 1); | ||
| 42 | yylval.str[strlen (yylval.str) - 1] = '\x00'; | ||
| 43 | |||
| 44 | return (ASTRING); | ||
| 45 | } | ||
| 46 | |||
| 47 | [iI][fF] { | ||
| 48 | return (IF); | ||
| 49 | } | ||
| 50 | |||
| 51 | [eE][lL][sS][eE] { | ||
| 52 | return (ELSE); | ||
| 53 | } | ||
| 54 | |||
| 55 | \$[a-zA-Z\_]+[a-zA-Z0-9\_]* { | ||
| 56 | yylval.str = xstrdup (yytext); | ||
| 57 | |||
| 58 | return (VARIABLE); | ||
| 59 | } | ||
| 60 | |||
| 61 | (\&\&)|(\|\|) { | ||
| 62 | if (strcmp (yytext, "&&") == 0) | ||
| 63 | yylval.logoper = LO_AND; | ||
| 64 | else if (strcmp (yytext, "||") == 0) | ||
| 65 | yylval.logoper = LO_OR; | ||
| 66 | |||
| 67 | return (LOG_OPER); | ||
| 68 | } | ||
| 69 | |||
| 70 | (\=\=)|(\>\=)|(\<\=)|(\!\=) { | ||
| 71 | if (strcmp (yytext, "==") == 0) | ||
| 72 | yylval.eq = EQ_EQUAL; | ||
| 73 | else if (strcmp (yytext, ">=") == 0) | ||
| 74 | yylval.eq = EQ_GREATEQ; | ||
| 75 | else if (strcmp (yytext, "<=") == 0) | ||
| 76 | yylval.eq = EQ_LOWEREQ; | ||
| 77 | else if (strcmp (yytext, "!=") == 0) | ||
| 78 | yylval.eq = EQ_NOTEQ; | ||
| 79 | |||
| 80 | return (EQ_OP); | ||
| 81 | } | ||
| 82 | |||
| 83 | [a-zA-Z0-9\.\_]+ { | ||
| 84 | yylval.str = xstrdup (yytext); | ||
| 85 | |||
| 86 | return (STRING); | ||
| 87 | } | ||
| 88 | |||
| 89 | [=] { | ||
| 90 | return (EQ); | ||
| 91 | } | ||
| 92 | |||
| 93 | . return (yytext[0]); | ||
| 94 | |||
| 95 | |||
diff --git a/other/gramble/compiler.y b/other/gramble/compiler.y new file mode 100644 index 0000000..d33ca67 --- /dev/null +++ b/other/gramble/compiler.y | |||
| @@ -0,0 +1,271 @@ | |||
| 1 | /* fornax - distributed packet network | ||
| 2 | * | ||
| 3 | * by team teso | ||
| 4 | * | ||
| 5 | * yacc command parser | ||
| 6 | */ | ||
| 7 | |||
| 8 | %{ | ||
| 9 | #ifdef DEBUG | ||
| 10 | #include <stdio.h> | ||
| 11 | #endif | ||
| 12 | #include <stdlib.h> | ||
| 13 | #include "branch.h" | ||
| 14 | #include "call.h" | ||
| 15 | #include "compiler.h" | ||
| 16 | #include "condition.h" | ||
| 17 | #include "element.h" | ||
| 18 | #include "symbol.h" | ||
| 19 | |||
| 20 | extern element ** gl_script; | ||
| 21 | |||
| 22 | %} | ||
| 23 | |||
| 24 | |||
| 25 | %union { | ||
| 26 | int eq; /* equality test operator */ | ||
| 27 | int logoper; /* logical operator */ | ||
| 28 | char * str; /* generic string pointer */ | ||
| 29 | element ** pp_element; | ||
| 30 | element * p_element; | ||
| 31 | call * p_call; | ||
| 32 | branch * p_branch; | ||
| 33 | condition * p_condition; | ||
| 34 | sym_elem * p_sym_elem; | ||
| 35 | sym_elem ** pp_sym_elem; | ||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | %token <eq> EQ | ||
| 40 | %token <eq> EQ_OP | ||
| 41 | %token <logoper> LOG_OPER | ||
| 42 | %token <str> STRING | ||
| 43 | %token <str> ASTRING | ||
| 44 | %token <str> VARIABLE | ||
| 45 | %token <str> SET | ||
| 46 | %token <str> IF | ||
| 47 | %token <str> ELSE | ||
| 48 | %token <str> EXPR_BLOCK_BEGIN | ||
| 49 | %token <str> EXPR_BLOCK_END | ||
| 50 | |||
| 51 | %type <pp_element> script | ||
| 52 | %type <pp_element> block | ||
| 53 | %type <pp_element> elementlist | ||
| 54 | %type <p_element> element | ||
| 55 | %type <p_call> call | ||
| 56 | %type <p_branch> branch | ||
| 57 | %type <p_condition> condition | ||
| 58 | %type <p_sym_elem> set | ||
| 59 | %type <pp_sym_elem> setlist | ||
| 60 | |||
| 61 | %% | ||
| 62 | |||
| 63 | |||
| 64 | script: | ||
| 65 | block | ||
| 66 | { | ||
| 67 | gl_script = $1; | ||
| 68 | } | ||
| 69 | |||
| 70 | ; | ||
| 71 | |||
| 72 | /* a block is a list of expression elements. the block is started with a | ||
| 73 | * `{' bracket and terminated by a `}' bracket. the simplest block just | ||
| 74 | * consists out of "{}" | ||
| 75 | */ | ||
| 76 | |||
| 77 | block: | ||
| 78 | EXPR_BLOCK_BEGIN elementlist EXPR_BLOCK_END | ||
| 79 | { | ||
| 80 | $$ = $2; | ||
| 81 | } | ||
| 82 | |||
| 83 | | EXPR_BLOCK_BEGIN EXPR_BLOCK_END | ||
| 84 | { | ||
| 85 | $$ = NULL; | ||
| 86 | } | ||
| 87 | |||
| 88 | ; | ||
| 89 | |||
| 90 | /* an elementlist is a concatation of single elements, which could be either | ||
| 91 | * expressions, settings or blocks | ||
| 92 | */ | ||
| 93 | |||
| 94 | elementlist: | ||
| 95 | elementlist element | ||
| 96 | { | ||
| 97 | #ifdef DEBUG | ||
| 98 | printf ("element %08x added to elementlist %08x\n", $2, $1); | ||
| 99 | #endif | ||
| 100 | $$ = elem_add ($1, $2); | ||
| 101 | } | ||
| 102 | |||
| 103 | | element | ||
| 104 | { | ||
| 105 | #ifdef DEBUG | ||
| 106 | printf ("element %08x added to elementlist NULL\n", $1); | ||
| 107 | #endif | ||
| 108 | $$ = NULL; | ||
| 109 | $$ = elem_add ($$, $1); | ||
| 110 | } | ||
| 111 | |||
| 112 | ; | ||
| 113 | |||
| 114 | |||
| 115 | /* an element is actually the gut of a program. elements are the pieces that | ||
| 116 | * are executed in a linear way, but an element can contain a block of other | ||
| 117 | * elements *shrug* | ||
| 118 | */ | ||
| 119 | |||
| 120 | element: | ||
| 121 | call | ||
| 122 | { | ||
| 123 | #ifdef DEBUG | ||
| 124 | printf ("call element %08x experienced \n", $1); | ||
| 125 | #endif | ||
| 126 | $$ = elem_create (); | ||
| 127 | $$ = elem_set_type ($$, ELEM_TYPE_CALL); | ||
| 128 | $$ = elem_set_data ($$, $1); | ||
| 129 | } | ||
| 130 | |||
| 131 | | branch | ||
| 132 | { | ||
| 133 | #ifdef DEBUG | ||
| 134 | printf ("branch element %08x experienced \n", $1); | ||
| 135 | #endif | ||
| 136 | $$ = elem_create (); | ||
| 137 | $$ = elem_set_type ($$, ELEM_TYPE_BRANCH); | ||
| 138 | $$ = elem_set_data ($$, $1); | ||
| 139 | } | ||
| 140 | |||
| 141 | | set | ||
| 142 | { | ||
| 143 | #ifdef DEBUG | ||
| 144 | printf ("set element %08x experienced \n", $1); | ||
| 145 | #endif | ||
| 146 | $$ = elem_create (); | ||
| 147 | $$ = elem_set_type ($$, ELEM_TYPE_SET); | ||
| 148 | $$ = elem_set_data ($$, $1); | ||
| 149 | } | ||
| 150 | |||
| 151 | ; | ||
| 152 | |||
| 153 | call: | ||
| 154 | STRING '(' setlist ')' | ||
| 155 | { | ||
| 156 | #ifdef DEBUG | ||
| 157 | printf ("call with parameters to symbol \"%s\" experienced \n", $1); | ||
| 158 | #endif | ||
| 159 | $$ = call_create (); | ||
| 160 | $$ = call_set_name ($$, $1); | ||
| 161 | $$ = call_set_parameters ($$, $3); | ||
| 162 | } | ||
| 163 | |||
| 164 | | STRING '(' ')' | ||
| 165 | { | ||
| 166 | #ifdef DEBUG | ||
| 167 | printf ("call without parameters to symbol \"%s\" experienced \n", $1); | ||
| 168 | #endif | ||
| 169 | $$ = call_create (); | ||
| 170 | $$ = call_set_name ($$, $1); | ||
| 171 | $$ = call_set_parameters ($$, NULL); | ||
| 172 | } | ||
| 173 | |||
| 174 | ; | ||
| 175 | |||
| 176 | setlist: | ||
| 177 | setlist set | ||
| 178 | { | ||
| 179 | #ifdef DEBUG | ||
| 180 | printf ("symbol %08x added to symbol table at %08x\n", $2, $1); | ||
| 181 | #endif | ||
| 182 | $$ = sym_elem_add ($1, $2); | ||
| 183 | } | ||
| 184 | |||
| 185 | | set | ||
| 186 | { | ||
| 187 | #ifdef DEBUG | ||
| 188 | printf ("symbol %08x added to NULL symbol table\n", $1); | ||
| 189 | #endif | ||
| 190 | $$ = NULL; | ||
| 191 | $$ = sym_elem_add ($$, $1); | ||
| 192 | } | ||
| 193 | |||
| 194 | ; | ||
| 195 | |||
| 196 | set: | ||
| 197 | STRING EQ ASTRING | ||
| 198 | { | ||
| 199 | #ifdef DEBUG | ||
| 200 | printf ("symbol pair (%s = \"%s\") created\n", $1, $3); | ||
| 201 | #endif | ||
| 202 | $$ = sym_elem_create ($1, $3); | ||
| 203 | } | ||
| 204 | |||
| 205 | ; | ||
| 206 | |||
| 207 | branch: | ||
| 208 | IF '(' condition ')' block | ||
| 209 | { | ||
| 210 | #ifdef DEBUG | ||
| 211 | printf ("if block with condition at %08x and block at %08x created\n", $3, $5); | ||
| 212 | #endif | ||
| 213 | $$ = br_create (); | ||
| 214 | $$ = br_set_condition ($$, $3); | ||
| 215 | $$ = br_set_block_if ($$, $5); | ||
| 216 | $$ = br_set_block_else ($$, NULL); | ||
| 217 | } | ||
| 218 | |||
| 219 | | IF '(' condition ')' block ELSE block | ||
| 220 | { | ||
| 221 | #ifdef DEBUG | ||
| 222 | printf ("if block with condition at %08x and blocks at %08x/%08x created\n", $3, $5, $7); | ||
| 223 | #endif | ||
| 224 | $$ = br_create (); | ||
| 225 | $$ = br_set_condition ($$, $3); | ||
| 226 | $$ = br_set_block_if ($$, $5); | ||
| 227 | $$ = br_set_block_else ($$, $7); | ||
| 228 | } | ||
| 229 | |||
| 230 | ; | ||
| 231 | |||
| 232 | condition: | ||
| 233 | '(' condition LOG_OPER condition ')' | ||
| 234 | { | ||
| 235 | #ifdef DEBUG | ||
| 236 | printf ("condition1 at %08x LOG_OPER condition2 at %08x created\n", $2, $4); | ||
| 237 | #endif | ||
| 238 | $$ = cond_create (); | ||
| 239 | $$ = cond_set_cond1 ($$, $2); | ||
| 240 | $$ = cond_set_logoper ($$, $3); | ||
| 241 | $$ = cond_set_cond2 ($$, $4); | ||
| 242 | $$ = cond_set_val1 ($$, NULL); | ||
| 243 | $$ = cond_set_val2 ($$, NULL); | ||
| 244 | } | ||
| 245 | |||
| 246 | | STRING EQ_OP ASTRING | ||
| 247 | { | ||
| 248 | #ifdef DEBUG | ||
| 249 | printf ("%s EQ_OP \"%s\"\n", $1, $3); | ||
| 250 | #endif | ||
| 251 | $$ = cond_create (); | ||
| 252 | $$ = cond_set_cond1 ($$, NULL); | ||
| 253 | $$ = cond_set_cond1 ($$, NULL); | ||
| 254 | $$ = cond_set_val1 ($$, $1); | ||
| 255 | $$ = cond_set_eqop ($$, $2); | ||
| 256 | $$ = cond_set_val2 ($$, $3); | ||
| 257 | } | ||
| 258 | |||
| 259 | ; | ||
| 260 | |||
| 261 | %% | ||
| 262 | |||
| 263 | #include "script.h" | ||
| 264 | #include "branch.h" | ||
| 265 | #include "call.h" | ||
| 266 | #include "compiler.h" | ||
| 267 | #include "condition.h" | ||
| 268 | #include "element.h" | ||
| 269 | #include "symbol.h" | ||
| 270 | |||
| 271 | |||
diff --git a/other/gramble/input-driver.c b/other/gramble/input-driver.c new file mode 100644 index 0000000..e68bdf3 --- /dev/null +++ b/other/gramble/input-driver.c | |||
| @@ -0,0 +1,105 @@ | |||
| 1 | /* gramble - grammar ramble | ||
| 2 | * | ||
| 3 | * team teso | ||
| 4 | * | ||
| 5 | * main grammar parser driver functions | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <setjmp.h> | ||
| 9 | #include <stdio.h> | ||
| 10 | #include <stdlib.h> | ||
| 11 | #include <string.h> | ||
| 12 | #include "input.h" | ||
| 13 | |||
| 14 | |||
| 15 | extern int yydebug; | ||
| 16 | extern FILE * yyout; | ||
| 17 | extern int yyparse (void); | ||
| 18 | |||
| 19 | |||
| 20 | void * in_grammar = NULL; /* parser return */ | ||
| 21 | |||
| 22 | char * in_input_ptr; | ||
| 23 | int in_input_lim; | ||
| 24 | |||
| 25 | jmp_buf in_yy_error_jmp; /* to catch errors in parser */ | ||
| 26 | |||
| 27 | |||
| 28 | /* overridden yacc functions | ||
| 29 | */ | ||
| 30 | |||
| 31 | int | ||
| 32 | yyerror (char *str) | ||
| 33 | { | ||
| 34 | longjmp (in_yy_error_jmp, 1); | ||
| 35 | |||
| 36 | exit (EXIT_FAILURE); | ||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | int | ||
| 41 | yywrap (void) | ||
| 42 | { | ||
| 43 | return (1); | ||
| 44 | } | ||
| 45 | |||
| 46 | |||
| 47 | /*** driver interface | ||
| 48 | */ | ||
| 49 | |||
| 50 | /* in_parse | ||
| 51 | * | ||
| 52 | * parse a grammar from buffer pointed to by 'buf', which is 'buf_len' bytes | ||
| 53 | * long. | ||
| 54 | * | ||
| 55 | * return NULL on failure | ||
| 56 | * return pointer to grammar on success | ||
| 57 | */ | ||
| 58 | |||
| 59 | void * /* FIXME: real pointer */ | ||
| 60 | in_parse (char *buf, int buf_len) | ||
| 61 | { | ||
| 62 | in_grammar = NULL; | ||
| 63 | |||
| 64 | |||
| 65 | in_input_ptr = buf; | ||
| 66 | in_input_lim = buf_len; | ||
| 67 | |||
| 68 | if (setjmp (in_yy_error_jmp) != 0) { | ||
| 69 | if (in_grammar != NULL) | ||
| 70 | return (NULL); | ||
| 71 | |||
| 72 | /* FIXME: free all associated memory */ | ||
| 73 | /* freebla (in_grammar) */ | ||
| 74 | return (NULL); | ||
| 75 | } | ||
| 76 | |||
| 77 | yyparse (); | ||
| 78 | |||
| 79 | return (in_grammar); | ||
| 80 | } | ||
| 81 | |||
| 82 | |||
| 83 | /* in_yyinput | ||
| 84 | * | ||
| 85 | * override yyinput functionality to allow more flexible parsing. internally | ||
| 86 | * used, never called by outsiders. | ||
| 87 | * | ||
| 88 | * return number of bytes read | ||
| 89 | */ | ||
| 90 | |||
| 91 | int | ||
| 92 | in_yyinput (char *buf, int size_max) | ||
| 93 | { | ||
| 94 | int n = 0; | ||
| 95 | |||
| 96 | n = (size_max >= in_input_lim) ? in_input_lim : size_max; | ||
| 97 | if (n > 0) { | ||
| 98 | memmove (buf, in_input_ptr, n); | ||
| 99 | in_input_ptr += n; | ||
| 100 | in_input_lim -= n; | ||
| 101 | } | ||
| 102 | |||
| 103 | return (n); | ||
| 104 | } | ||
| 105 | |||
diff --git a/other/gramble/input-driver.o b/other/gramble/input-driver.o new file mode 100644 index 0000000..d57dbbf --- /dev/null +++ b/other/gramble/input-driver.o | |||
| Binary files differ | |||
diff --git a/other/gramble/input-test b/other/gramble/input-test new file mode 100644 index 0000000..17ef4fe --- /dev/null +++ b/other/gramble/input-test | |||
| Binary files differ | |||
diff --git a/other/gramble/input-test.c b/other/gramble/input-test.c new file mode 100644 index 0000000..6c3fb01 --- /dev/null +++ b/other/gramble/input-test.c | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /* gramble - grammar ramble | ||
| 2 | * | ||
| 3 | * team teso | ||
| 4 | * | ||
| 5 | * input functions test program | ||
| 6 | */ | ||
| 7 | |||
| 8 | #include <stdio.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <string.h> | ||
| 11 | #include "common.h" | ||
| 12 | #include "input.h" | ||
| 13 | |||
| 14 | |||
| 15 | char * file_read (char *filename); | ||
| 16 | |||
| 17 | |||
| 18 | char * | ||
| 19 | file_read (char *filename) | ||
| 20 | { | ||
| 21 | FILE * fp; | ||
| 22 | char * array = NULL; | ||
| 23 | unsigned long int readbytes = 0; | ||
| 24 | size_t rb; | ||
| 25 | |||
| 26 | |||
| 27 | fp = fopen (filename, "r"); | ||
| 28 | if (fp == NULL) | ||
| 29 | return (NULL); | ||
| 30 | |||
| 31 | do { | ||
| 32 | array = xrealloc (array, readbytes + 1024); | ||
| 33 | rb = fread (array + readbytes, 1, 1024, fp); | ||
| 34 | readbytes += rb; | ||
| 35 | } while (rb > 0); | ||
| 36 | |||
| 37 | fclose (fp); | ||
| 38 | |||
| 39 | return (array); | ||
| 40 | } | ||
| 41 | |||
| 42 | |||
| 43 | int | ||
| 44 | main (int argc, char **argv) | ||
| 45 | { | ||
| 46 | void * inp; | ||
| 47 | char * grammar; | ||
| 48 | |||
| 49 | |||
| 50 | if (argc != 2) { | ||
| 51 | printf ("usage: %s <inputfile>\n\n", argv[0]); | ||
| 52 | |||
| 53 | exit (EXIT_FAILURE); | ||
| 54 | } | ||
| 55 | |||
| 56 | grammar = file_read (argv[1]); | ||
| 57 | if (grammar == NULL) { | ||
| 58 | fprintf (stderr, "couldn't open or read \"%s\", " | ||
| 59 | "aborting\n", argv[1]); | ||
| 60 | |||
| 61 | exit (EXIT_FAILURE); | ||
| 62 | } | ||
| 63 | |||
| 64 | inp = in_parse (grammar, strlen (grammar)); | ||
| 65 | printf ("---------------------------------------------------------" | ||
| 66 | "----------------------\n"); | ||
| 67 | printf ("parsing of grammar %s %s.\n\n", argv[1], | ||
| 68 | (inp == NULL) ? "failed" : "successful"); | ||
| 69 | |||
| 70 | /* TODO: sanity checking, free'ing etc. | ||
| 71 | */ | ||
| 72 | |||
| 73 | exit (EXIT_SUCCESS); | ||
| 74 | } | ||
| 75 | |||
| 76 | |||
diff --git a/other/gramble/input.h b/other/gramble/input.h new file mode 100644 index 0000000..47e7368 --- /dev/null +++ b/other/gramble/input.h | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | /* gramble - gammar ramble | ||
| 2 | * | ||
| 3 | * team teso | ||
| 4 | * | ||
| 5 | * input functions include file | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef GRAMBLE_INPUT_H | ||
| 9 | #define GRAMBLE_INPUT_H | ||
| 10 | |||
| 11 | int yyerror (char *str); | ||
| 12 | int yywrap (void); | ||
| 13 | int in_yyinput (char *buf, int size_max); | ||
| 14 | void *in_parse (char *buf, int buf_len); | ||
| 15 | |||
| 16 | #endif | ||
| 17 | |||
diff --git a/other/gramble/input.l b/other/gramble/input.l new file mode 100644 index 0000000..caebf4b --- /dev/null +++ b/other/gramble/input.l | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | /* gramble - gammar ramble | ||
| 2 | * | ||
| 3 | * team teso | ||
| 4 | * | ||
| 5 | * grammar lexer | ||
| 6 | */ | ||
| 7 | |||
| 8 | %{ | ||
| 9 | #undef yywrap | ||
| 10 | |||
| 11 | #include <string.h> | ||
| 12 | #include "y.tab.h" | ||
| 13 | #include "input.h" | ||
| 14 | |||
| 15 | #undef ECHO | ||
| 16 | #undef YY_INPUT | ||
| 17 | #define YY_INPUT(b, r, ms) (r = in_yyinput (b, ms)) | ||
| 18 | |||
| 19 | %} | ||
| 20 | |||
| 21 | %% | ||
| 22 | |||
| 23 | [\n\t ]+ ; | ||
| 24 | |||
| 25 | \"[^\"]*\" { | ||
| 26 | yylval.str = strdup (yytext + 1); | ||
| 27 | yylval.str[strlen (yylval.str) - 1] = '\0'; | ||
| 28 | |||
| 29 | return (TERM); | ||
| 30 | } | ||
| 31 | |||
| 32 | [0-9]+ { | ||
| 33 | sscanf (yytext, "%u", &yylval.uint); | ||
| 34 | |||
| 35 | return (NUM); | ||
| 36 | } | ||
| 37 | |||
| 38 | 0x[0-9abcdef]+ { | ||
| 39 | sscanf (yytext, "0x%x", &yylval.uint); | ||
| 40 | |||
| 41 | return (NUM); | ||
| 42 | } | ||
| 43 | |||
| 44 | [^\/]/\/ { | ||
| 45 | yylval.str = strdup (yytext); | ||
| 46 | |||
| 47 | return (NSSTR); | ||
| 48 | } | ||
| 49 | |||
| 50 | filter { | ||
| 51 | return (FILTER); | ||
| 52 | } | ||
| 53 | |||
| 54 | \~filter { | ||
| 55 | return (NEGFILTER); | ||
| 56 | } | ||
| 57 | |||
| 58 | size { | ||
| 59 | return (SIZE); | ||
| 60 | } | ||
| 61 | |||
diff --git a/other/gramble/input.y b/other/gramble/input.y new file mode 100644 index 0000000..17ae718 --- /dev/null +++ b/other/gramble/input.y | |||
| @@ -0,0 +1,110 @@ | |||
| 1 | /* gramble - grammar ramble | ||
| 2 | * | ||
| 3 | * team teso | ||
| 4 | * | ||
| 5 | * grammar parser | ||
| 6 | */ | ||
| 7 | |||
| 8 | %{ | ||
| 9 | #include <stdio.h> | ||
| 10 | #include <stdlib.h> | ||
| 11 | #include "input.h" | ||
| 12 | |||
| 13 | extern void * in_grammar; | ||
| 14 | |||
| 15 | %} | ||
| 16 | |||
| 17 | |||
| 18 | %union { | ||
| 19 | unsigned int uint; /* unsigned number (length) */ | ||
| 20 | unsigned char * str; /* generic ASCIIZ string pointer */ | ||
| 21 | void * ugly; | ||
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | %token <str> STR NSSTR NTERM TERM FILTER NEGFILTER SIZE | ||
| 26 | %token <uint> NUM | ||
| 27 | |||
| 28 | /* use % type here */ | ||
| 29 | %type <ugly> prod prodr prodrelem poptl popt | ||
| 30 | |||
| 31 | %start prodlist | ||
| 32 | |||
| 33 | %% | ||
| 34 | |||
| 35 | prodlist: | ||
| 36 | prodlist prod | ||
| 37 | { | ||
| 38 | in_grammar = NULL; | ||
| 39 | } | ||
| 40 | | prod | ||
| 41 | { | ||
| 42 | in_grammar = NULL; | ||
| 43 | } | ||
| 44 | ; | ||
| 45 | |||
| 46 | prod: NTERM ':' prodr | ||
| 47 | { | ||
| 48 | $$ = NULL; | ||
| 49 | } | ||
| 50 | ; | ||
| 51 | |||
| 52 | /* prodr, right side of a production */ | ||
| 53 | prodr: prodr prodrelem | ||
| 54 | { | ||
| 55 | $$ = NULL; | ||
| 56 | } | ||
| 57 | | prodrelem | ||
| 58 | { | ||
| 59 | $$ = NULL; | ||
| 60 | } | ||
| 61 | ; | ||
| 62 | |||
| 63 | /* prodr, right side of a production */ | ||
| 64 | prodrelem: '[' prodr ']' poptl | ||
| 65 | { | ||
| 66 | $$ = NULL; | ||
| 67 | } | ||
| 68 | | NTERM | ||
| 69 | { | ||
| 70 | $$ = NULL; | ||
| 71 | } | ||
| 72 | | TERM | ||
| 73 | { | ||
| 74 | $$ = NULL; | ||
| 75 | } | ||
| 76 | ; | ||
| 77 | |||
| 78 | /* production option list */ | ||
| 79 | poptl: poptl '(' popt ')' | ||
| 80 | { | ||
| 81 | $$ = NULL; | ||
| 82 | } | ||
| 83 | | | ||
| 84 | { | ||
| 85 | $$ = NULL; | ||
| 86 | } | ||
| 87 | ; | ||
| 88 | |||
| 89 | popt: FILTER ':' '/' NSSTR '/' | ||
| 90 | { | ||
| 91 | fprintf (stderr, "FILTER: %s with /%s/\n", $1, $4); | ||
| 92 | $$ = NULL; | ||
| 93 | } | ||
| 94 | | NEGFILTER ':' '/' NSSTR '/' | ||
| 95 | { | ||
| 96 | $$ = NULL; | ||
| 97 | } | ||
| 98 | | SIZE ':' NUM '-' NUM | ||
| 99 | { | ||
| 100 | $$ = NULL; | ||
| 101 | } | ||
| 102 | ; | ||
| 103 | |||
| 104 | |||
| 105 | %% | ||
| 106 | |||
| 107 | /* TODO: includes in parser come here | ||
| 108 | */ | ||
| 109 | |||
| 110 | |||
diff --git a/other/gramble/lex.yy.c b/other/gramble/lex.yy.c new file mode 100644 index 0000000..de10c64 --- /dev/null +++ b/other/gramble/lex.yy.c | |||
| @@ -0,0 +1,1597 @@ | |||
| 1 | /* A lexical scanner generated by flex */ | ||
| 2 | |||
| 3 | /* Scanner skeleton version: | ||
| 4 | * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ | ||
| 5 | */ | ||
| 6 | |||
| 7 | #define FLEX_SCANNER | ||
| 8 | #define YY_FLEX_MAJOR_VERSION 2 | ||
| 9 | #define YY_FLEX_MINOR_VERSION 5 | ||
| 10 | |||
| 11 | #include <stdio.h> | ||
| 12 | |||
| 13 | |||
| 14 | /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ | ||
| 15 | #ifdef c_plusplus | ||
| 16 | #ifndef __cplusplus | ||
| 17 | #define __cplusplus | ||
| 18 | #endif | ||
| 19 | #endif | ||
| 20 | |||
| 21 | |||
| 22 | #ifdef __cplusplus | ||
| 23 | |||
| 24 | #include <stdlib.h> | ||
| 25 | #include <unistd.h> | ||
| 26 | |||
| 27 | /* Use prototypes in function declarations. */ | ||
| 28 | #define YY_USE_PROTOS | ||
| 29 | |||
| 30 | /* The "const" storage-class-modifier is valid. */ | ||
| 31 | #define YY_USE_CONST | ||
| 32 | |||
| 33 | #else /* ! __cplusplus */ | ||
| 34 | |||
| 35 | #if __STDC__ | ||
| 36 | |||
| 37 | #define YY_USE_PROTOS | ||
| 38 | #define YY_USE_CONST | ||
| 39 | |||
| 40 | #endif /* __STDC__ */ | ||
| 41 | #endif /* ! __cplusplus */ | ||
| 42 | |||
| 43 | #ifdef __TURBOC__ | ||
| 44 | #pragma warn -rch | ||
| 45 | #pragma warn -use | ||
| 46 | #include <io.h> | ||
| 47 | #include <stdlib.h> | ||
| 48 | #define YY_USE_CONST | ||
| 49 | #define YY_USE_PROTOS | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #ifdef YY_USE_CONST | ||
| 53 | #define yyconst const | ||
| 54 | #else | ||
| 55 | #define yyconst | ||
| 56 | #endif | ||
| 57 | |||
| 58 | |||
| 59 | #ifdef YY_USE_PROTOS | ||
| 60 | #define YY_PROTO(proto) proto | ||
| 61 | #else | ||
| 62 | #define YY_PROTO(proto) () | ||
| 63 | #endif | ||
| 64 | |||
| 65 | /* Returned upon end-of-file. */ | ||
| 66 | #define YY_NULL 0 | ||
| 67 | |||
| 68 | /* Promotes a possibly negative, possibly signed char to an unsigned | ||
| 69 | * integer for use as an array index. If the signed char is negative, | ||
| 70 | * we want to instead treat it as an 8-bit unsigned char, hence the | ||
| 71 | * double cast. | ||
| 72 | */ | ||
| 73 | #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) | ||
| 74 | |||
| 75 | /* Enter a start condition. This macro really ought to take a parameter, | ||
| 76 | * but we do it the disgusting crufty way forced on us by the ()-less | ||
| 77 | * definition of BEGIN. | ||
| 78 | */ | ||
| 79 | #define BEGIN yy_start = 1 + 2 * | ||
| 80 | |||
| 81 | /* Translate the current start state into a value that can be later handed | ||
| 82 | * to BEGIN to return to the state. The YYSTATE alias is for lex | ||
| 83 | * compatibility. | ||
| 84 | */ | ||
| 85 | #define YY_START ((yy_start - 1) / 2) | ||
| 86 | #define YYSTATE YY_START | ||
| 87 | |||
| 88 | /* Action number for EOF rule of a given start state. */ | ||
| 89 | #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) | ||
| 90 | |||
| 91 | /* Special action meaning "start processing a new file". */ | ||
| 92 | #define YY_NEW_FILE yyrestart( yyin ) | ||
| 93 | |||
| 94 | #define YY_END_OF_BUFFER_CHAR 0 | ||
| 95 | |||
| 96 | /* Size of default input buffer. */ | ||
| 97 | #define YY_BUF_SIZE 16384 | ||
| 98 | |||
| 99 | typedef struct yy_buffer_state *YY_BUFFER_STATE; | ||
| 100 | |||
| 101 | extern int yyleng; | ||
| 102 | extern FILE *yyin, *yyout; | ||
| 103 | |||
| 104 | #define EOB_ACT_CONTINUE_SCAN 0 | ||
| 105 | #define EOB_ACT_END_OF_FILE 1 | ||
| 106 | #define EOB_ACT_LAST_MATCH 2 | ||
| 107 | |||
| 108 | /* The funky do-while in the following #define is used to turn the definition | ||
| 109 | * int a single C statement (which needs a semi-colon terminator). This | ||
| 110 | * avoids problems with code like: | ||
| 111 | * | ||
| 112 | * if ( condition_holds ) | ||
| 113 | * yyless( 5 ); | ||
| 114 | * else | ||
| 115 | * do_something_else(); | ||
| 116 | * | ||
| 117 | * Prior to using the do-while the compiler would get upset at the | ||
| 118 | * "else" because it interpreted the "if" statement as being all | ||
| 119 | * done when it reached the ';' after the yyless() call. | ||
| 120 | */ | ||
| 121 | |||
| 122 | /* Return all but the first 'n' matched characters back to the input stream. */ | ||
| 123 | |||
| 124 | #define yyless(n) \ | ||
| 125 | do \ | ||
| 126 | { \ | ||
| 127 | /* Undo effects of setting up yytext. */ \ | ||
| 128 | *yy_cp = yy_hold_char; \ | ||
| 129 | YY_RESTORE_YY_MORE_OFFSET \ | ||
| 130 | yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ | ||
| 131 | YY_DO_BEFORE_ACTION; /* set up yytext again */ \ | ||
| 132 | } \ | ||
| 133 | while ( 0 ) | ||
| 134 | |||
| 135 | #define unput(c) yyunput( c, yytext_ptr ) | ||
| 136 | |||
| 137 | /* The following is because we cannot portably get our hands on size_t | ||
| 138 | * (without autoconf's help, which isn't available because we want | ||
| 139 | * flex-generated scanners to compile on their own). | ||
| 140 | */ | ||
| 141 | typedef unsigned int yy_size_t; | ||
| 142 | |||
| 143 | |||
| 144 | struct yy_buffer_state | ||
| 145 | { | ||
| 146 | FILE *yy_input_file; | ||
| 147 | |||
| 148 | char *yy_ch_buf; /* input buffer */ | ||
| 149 | char *yy_buf_pos; /* current position in input buffer */ | ||
| 150 | |||
| 151 | /* Size of input buffer in bytes, not including room for EOB | ||
| 152 | * characters. | ||
| 153 | */ | ||
| 154 | yy_size_t yy_buf_size; | ||
| 155 | |||
| 156 | /* Number of characters read into yy_ch_buf, not including EOB | ||
| 157 | * characters. | ||
| 158 | */ | ||
| 159 | int yy_n_chars; | ||
| 160 | |||
| 161 | /* Whether we "own" the buffer - i.e., we know we created it, | ||
| 162 | * and can realloc() it to grow it, and should free() it to | ||
| 163 | * delete it. | ||
| 164 | */ | ||
| 165 | int yy_is_our_buffer; | ||
| 166 | |||
| 167 | /* Whether this is an "interactive" input source; if so, and | ||
| 168 | * if we're using stdio for input, then we want to use getc() | ||
| 169 | * instead of fread(), to make sure we stop fetching input after | ||
| 170 | * each newline. | ||
| 171 | */ | ||
| 172 | int yy_is_interactive; | ||
| 173 | |||
| 174 | /* Whether we're considered to be at the beginning of a line. | ||
| 175 | * If so, '^' rules will be active on the next match, otherwise | ||
| 176 | * not. | ||
| 177 | */ | ||
| 178 | int yy_at_bol; | ||
| 179 | |||
| 180 | /* Whether to try to fill the input buffer when we reach the | ||
| 181 | * end of it. | ||
| 182 | */ | ||
| 183 | int yy_fill_buffer; | ||
| 184 | |||
| 185 | int yy_buffer_status; | ||
| 186 | #define YY_BUFFER_NEW 0 | ||
| 187 | #define YY_BUFFER_NORMAL 1 | ||
| 188 | /* When an EOF's been seen but there's still some text to process | ||
| 189 | * then we mark the buffer as YY_EOF_PENDING, to indicate that we | ||
| 190 | * shouldn't try reading from the input source any more. We might | ||
| 191 | * still have a bunch of tokens to match, though, because of | ||
| 192 | * possible backing-up. | ||
| 193 | * | ||
| 194 | * When we actually see the EOF, we change the status to "new" | ||
| 195 | * (via yyrestart()), so that the user can continue scanning by | ||
| 196 | * just pointing yyin at a new input file. | ||
| 197 | */ | ||
| 198 | #define YY_BUFFER_EOF_PENDING 2 | ||
| 199 | }; | ||
| 200 | |||
| 201 | static YY_BUFFER_STATE yy_current_buffer = 0; | ||
| 202 | |||
| 203 | /* We provide macros for accessing buffer states in case in the | ||
| 204 | * future we want to put the buffer states in a more general | ||
| 205 | * "scanner state". | ||
| 206 | */ | ||
| 207 | #define YY_CURRENT_BUFFER yy_current_buffer | ||
| 208 | |||
| 209 | |||
| 210 | /* yy_hold_char holds the character lost when yytext is formed. */ | ||
| 211 | static char yy_hold_char; | ||
| 212 | |||
| 213 | static int yy_n_chars; /* number of characters read into yy_ch_buf */ | ||
| 214 | |||
| 215 | |||
| 216 | int yyleng; | ||
| 217 | |||
| 218 | /* Points to current character in buffer. */ | ||
| 219 | static char *yy_c_buf_p = (char *) 0; | ||
| 220 | static int yy_init = 1; /* whether we need to initialize */ | ||
| 221 | static int yy_start = 0; /* start state number */ | ||
| 222 | |||
| 223 | /* Flag which is used to allow yywrap()'s to do buffer switches | ||
| 224 | * instead of setting up a fresh yyin. A bit of a hack ... | ||
| 225 | */ | ||
| 226 | static int yy_did_buffer_switch_on_eof; | ||
| 227 | |||
| 228 | void yyrestart YY_PROTO(( FILE *input_file )); | ||
| 229 | |||
| 230 | void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); | ||
| 231 | void yy_load_buffer_state YY_PROTO(( void )); | ||
| 232 | YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); | ||
| 233 | void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); | ||
| 234 | void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); | ||
| 235 | void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); | ||
| 236 | #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) | ||
| 237 | |||
| 238 | YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); | ||
| 239 | YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); | ||
| 240 | YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); | ||
| 241 | |||
| 242 | static void *yy_flex_alloc YY_PROTO(( yy_size_t )); | ||
| 243 | static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); | ||
| 244 | static void yy_flex_free YY_PROTO(( void * )); | ||
| 245 | |||
| 246 | #define yy_new_buffer yy_create_buffer | ||
| 247 | |||
| 248 | #define yy_set_interactive(is_interactive) \ | ||
| 249 | { \ | ||
| 250 | if ( ! yy_current_buffer ) \ | ||
| 251 | yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ | ||
| 252 | yy_current_buffer->yy_is_interactive = is_interactive; \ | ||
| 253 | } | ||
| 254 | |||
| 255 | #define yy_set_bol(at_bol) \ | ||
| 256 | { \ | ||
| 257 | if ( ! yy_current_buffer ) \ | ||
| 258 | yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ | ||
| 259 | yy_current_buffer->yy_at_bol = at_bol; \ | ||
| 260 | } | ||
| 261 | |||
| 262 | #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) | ||
| 263 | |||
| 264 | typedef unsigned char YY_CHAR; | ||
| 265 | FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; | ||
| 266 | typedef int yy_state_type; | ||
| 267 | extern char *yytext; | ||
| 268 | #define yytext_ptr yytext | ||
| 269 | |||
| 270 | static yy_state_type yy_get_previous_state YY_PROTO(( void )); | ||
| 271 | static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); | ||
| 272 | static int yy_get_next_buffer YY_PROTO(( void )); | ||
| 273 | static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); | ||
| 274 | |||
| 275 | /* Done after the current pattern has been matched and before the | ||
| 276 | * corresponding action - sets up yytext. | ||
| 277 | */ | ||
| 278 | #define YY_DO_BEFORE_ACTION \ | ||
| 279 | yytext_ptr = yy_bp; \ | ||
| 280 | yyleng = (int) (yy_cp - yy_bp); \ | ||
| 281 | yy_hold_char = *yy_cp; \ | ||
| 282 | *yy_cp = '\0'; \ | ||
| 283 | yy_c_buf_p = yy_cp; | ||
| 284 | |||
| 285 | #define YY_NUM_RULES 9 | ||
| 286 | #define YY_END_OF_BUFFER 10 | ||
| 287 | static yyconst short int yy_accept[36] = | ||
| 288 | { 0, | ||
| 289 | 0, 0, 10, 9, 1, 9, 9, 3, 3, 9, | ||
| 290 | 9, 9, 5, 1, 0, 2, 5, 3, 0, 0, | ||
| 291 | 0, 0, 4, 0, 0, 0, 0, 8, 0, 0, | ||
| 292 | 0, 6, 0, 7, 0 | ||
| 293 | } ; | ||
| 294 | |||
| 295 | static yyconst int yy_ec[256] = | ||
| 296 | { 0, | ||
| 297 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, | ||
| 298 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 299 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 300 | 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, | ||
| 301 | 1, 1, 1, 1, 1, 1, 4, 5, 6, 6, | ||
| 302 | 6, 6, 6, 6, 6, 6, 6, 1, 1, 1, | ||
| 303 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 304 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 305 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 306 | 1, 1, 1, 1, 1, 1, 7, 7, 7, 7, | ||
| 307 | |||
| 308 | 8, 9, 1, 1, 10, 1, 1, 11, 1, 1, | ||
| 309 | 1, 1, 1, 12, 13, 14, 1, 1, 1, 15, | ||
| 310 | 1, 16, 1, 1, 1, 17, 1, 1, 1, 1, | ||
| 311 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 312 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 313 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 314 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 315 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 316 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 317 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 318 | |||
| 319 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 320 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 321 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 322 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 323 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 324 | 1, 1, 1, 1, 1 | ||
| 325 | } ; | ||
| 326 | |||
| 327 | static yyconst int yy_meta[18] = | ||
| 328 | { 0, | ||
| 329 | 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, | ||
| 330 | 1, 1, 1, 1, 1, 1, 1 | ||
| 331 | } ; | ||
| 332 | |||
| 333 | static yyconst short int yy_base[38] = | ||
| 334 | { 0, | ||
| 335 | 0, 0, 53, 48, 16, 18, 54, 19, 36, 22, | ||
| 336 | 23, 26, 54, 48, 46, 54, 45, 23, 0, 36, | ||
| 337 | 30, 35, 0, 30, 35, 31, 33, 54, 26, 27, | ||
| 338 | 30, 54, 19, 54, 54, 35, 17 | ||
| 339 | } ; | ||
| 340 | |||
| 341 | static yyconst short int yy_def[38] = | ||
| 342 | { 0, | ||
| 343 | 35, 1, 35, 35, 35, 36, 35, 35, 8, 35, | ||
| 344 | 35, 35, 35, 35, 36, 35, 36, 35, 37, 35, | ||
| 345 | 35, 35, 37, 35, 35, 35, 35, 35, 35, 35, | ||
| 346 | 35, 35, 35, 35, 0, 35, 35 | ||
| 347 | } ; | ||
| 348 | |||
| 349 | static yyconst short int yy_nxt[72] = | ||
| 350 | { 0, | ||
| 351 | 4, 5, 6, 7, 8, 9, 4, 4, 10, 4, | ||
| 352 | 4, 4, 11, 4, 4, 4, 12, 14, 23, 13, | ||
| 353 | 16, 17, 13, 18, 18, 13, 13, 18, 18, 13, | ||
| 354 | 34, 20, 21, 19, 22, 15, 15, 33, 32, 31, | ||
| 355 | 30, 29, 28, 27, 26, 25, 24, 16, 16, 14, | ||
| 356 | 35, 13, 35, 3, 35, 35, 35, 35, 35, 35, | ||
| 357 | 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, | ||
| 358 | 35 | ||
| 359 | } ; | ||
| 360 | |||
| 361 | static yyconst short int yy_chk[72] = | ||
| 362 | { 0, | ||
| 363 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | ||
| 364 | 1, 1, 1, 1, 1, 1, 1, 5, 37, 5, | ||
| 365 | 6, 6, 8, 8, 8, 10, 11, 18, 18, 12, | ||
| 366 | 33, 10, 11, 8, 12, 36, 36, 31, 30, 29, | ||
| 367 | 27, 26, 25, 24, 22, 21, 20, 17, 15, 14, | ||
| 368 | 9, 4, 3, 35, 35, 35, 35, 35, 35, 35, | ||
| 369 | 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, | ||
| 370 | 35 | ||
| 371 | } ; | ||
| 372 | |||
| 373 | static yy_state_type yy_last_accepting_state; | ||
| 374 | static char *yy_last_accepting_cpos; | ||
| 375 | |||
| 376 | /* The intent behind this definition is that it'll catch | ||
| 377 | * any uses of REJECT which flex missed. | ||
| 378 | */ | ||
| 379 | #define REJECT reject_used_but_not_detected | ||
| 380 | #define yymore() yymore_used_but_not_detected | ||
| 381 | #define YY_MORE_ADJ 0 | ||
| 382 | #define YY_RESTORE_YY_MORE_OFFSET | ||
| 383 | char *yytext; | ||
| 384 | #line 1 "input.l" | ||
| 385 | #define INITIAL 0 | ||
| 386 | /* gramble - gammar ramble | ||
| 387 | * | ||
| 388 | * team teso | ||
| 389 | * | ||
| 390 | * grammar lexer | ||
| 391 | */ | ||
| 392 | #line 9 "input.l" | ||
| 393 | #undef yywrap | ||
| 394 | |||
| 395 | #include <string.h> | ||
| 396 | #include "y.tab.h" | ||
| 397 | #include "input.h" | ||
| 398 | |||
| 399 | #undef ECHO | ||
| 400 | #undef YY_INPUT | ||
| 401 | #define YY_INPUT(b, r, ms) (r = in_yyinput (b, ms)) | ||
| 402 | |||
| 403 | #line 404 "lex.yy.c" | ||
| 404 | |||
| 405 | /* Macros after this point can all be overridden by user definitions in | ||
| 406 | * section 1. | ||
| 407 | */ | ||
| 408 | |||
| 409 | #ifndef YY_SKIP_YYWRAP | ||
| 410 | #ifdef __cplusplus | ||
| 411 | extern "C" int yywrap YY_PROTO(( void )); | ||
| 412 | #else | ||
| 413 | extern int yywrap YY_PROTO(( void )); | ||
| 414 | #endif | ||
| 415 | #endif | ||
| 416 | |||
| 417 | #ifndef YY_NO_UNPUT | ||
| 418 | static void yyunput YY_PROTO(( int c, char *buf_ptr )); | ||
| 419 | #endif | ||
| 420 | |||
| 421 | #ifndef yytext_ptr | ||
| 422 | static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); | ||
| 423 | #endif | ||
| 424 | |||
| 425 | #ifdef YY_NEED_STRLEN | ||
| 426 | static int yy_flex_strlen YY_PROTO(( yyconst char * )); | ||
| 427 | #endif | ||
| 428 | |||
| 429 | #ifndef YY_NO_INPUT | ||
| 430 | #ifdef __cplusplus | ||
| 431 | static int yyinput YY_PROTO(( void )); | ||
| 432 | #else | ||
| 433 | static int input YY_PROTO(( void )); | ||
| 434 | #endif | ||
| 435 | #endif | ||
| 436 | |||
| 437 | #if YY_STACK_USED | ||
| 438 | static int yy_start_stack_ptr = 0; | ||
| 439 | static int yy_start_stack_depth = 0; | ||
| 440 | static int *yy_start_stack = 0; | ||
| 441 | #ifndef YY_NO_PUSH_STATE | ||
| 442 | static void yy_push_state YY_PROTO(( int new_state )); | ||
| 443 | #endif | ||
| 444 | #ifndef YY_NO_POP_STATE | ||
| 445 | static void yy_pop_state YY_PROTO(( void )); | ||
| 446 | #endif | ||
| 447 | #ifndef YY_NO_TOP_STATE | ||
| 448 | static int yy_top_state YY_PROTO(( void )); | ||
| 449 | #endif | ||
| 450 | |||
| 451 | #else | ||
| 452 | #define YY_NO_PUSH_STATE 1 | ||
| 453 | #define YY_NO_POP_STATE 1 | ||
| 454 | #define YY_NO_TOP_STATE 1 | ||
| 455 | #endif | ||
| 456 | |||
| 457 | #ifdef YY_MALLOC_DECL | ||
| 458 | YY_MALLOC_DECL | ||
| 459 | #else | ||
| 460 | #if __STDC__ | ||
| 461 | #ifndef __cplusplus | ||
| 462 | #include <stdlib.h> | ||
| 463 | #endif | ||
| 464 | #else | ||
| 465 | /* Just try to get by without declaring the routines. This will fail | ||
| 466 | * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) | ||
| 467 | * or sizeof(void*) != sizeof(int). | ||
| 468 | */ | ||
| 469 | #endif | ||
| 470 | #endif | ||
| 471 | |||
| 472 | /* Amount of stuff to slurp up with each read. */ | ||
| 473 | #ifndef YY_READ_BUF_SIZE | ||
| 474 | #define YY_READ_BUF_SIZE 8192 | ||
| 475 | #endif | ||
| 476 | |||
| 477 | /* Copy whatever the last rule matched to the standard output. */ | ||
| 478 | |||
| 479 | #ifndef ECHO | ||
| 480 | /* This used to be an fputs(), but since the string might contain NUL's, | ||
| 481 | * we now use fwrite(). | ||
| 482 | */ | ||
| 483 | #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) | ||
| 484 | #endif | ||
| 485 | |||
| 486 | /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, | ||
| 487 | * is returned in "result". | ||
| 488 | */ | ||
| 489 | #ifndef YY_INPUT | ||
| 490 | #define YY_INPUT(buf,result,max_size) \ | ||
| 491 | if ( yy_current_buffer->yy_is_interactive ) \ | ||
| 492 | { \ | ||
| 493 | int c = '*', n; \ | ||
| 494 | for ( n = 0; n < max_size && \ | ||
| 495 | (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ | ||
| 496 | buf[n] = (char) c; \ | ||
| 497 | if ( c == '\n' ) \ | ||
| 498 | buf[n++] = (char) c; \ | ||
| 499 | if ( c == EOF && ferror( yyin ) ) \ | ||
| 500 | YY_FATAL_ERROR( "input in flex scanner failed" ); \ | ||
| 501 | result = n; \ | ||
| 502 | } \ | ||
| 503 | else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ | ||
| 504 | && ferror( yyin ) ) \ | ||
| 505 | YY_FATAL_ERROR( "input in flex scanner failed" ); | ||
| 506 | #endif | ||
| 507 | |||
| 508 | /* No semi-colon after return; correct usage is to write "yyterminate();" - | ||
| 509 | * we don't want an extra ';' after the "return" because that will cause | ||
| 510 | * some compilers to complain about unreachable statements. | ||
| 511 | */ | ||
| 512 | #ifndef yyterminate | ||
| 513 | #define yyterminate() return YY_NULL | ||
| 514 | #endif | ||
| 515 | |||
| 516 | /* Number of entries by which start-condition stack grows. */ | ||
| 517 | #ifndef YY_START_STACK_INCR | ||
| 518 | #define YY_START_STACK_INCR 25 | ||
| 519 | #endif | ||
| 520 | |||
| 521 | /* Report a fatal error. */ | ||
| 522 | #ifndef YY_FATAL_ERROR | ||
| 523 | #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) | ||
| 524 | #endif | ||
| 525 | |||
| 526 | /* Default declaration of generated scanner - a define so the user can | ||
| 527 | * easily add parameters. | ||
| 528 | */ | ||
| 529 | #ifndef YY_DECL | ||
| 530 | #define YY_DECL int yylex YY_PROTO(( void )) | ||
| 531 | #endif | ||
| 532 | |||
| 533 | /* Code executed at the beginning of each rule, after yytext and yyleng | ||
| 534 | * have been set up. | ||
| 535 | */ | ||
| 536 | #ifndef YY_USER_ACTION | ||
| 537 | #define YY_USER_ACTION | ||
| 538 | #endif | ||
| 539 | |||
| 540 | /* Code executed at the end of each rule. */ | ||
| 541 | #ifndef YY_BREAK | ||
| 542 | #define YY_BREAK break; | ||
| 543 | #endif | ||
| 544 | |||
| 545 | #define YY_RULE_SETUP \ | ||
| 546 | YY_USER_ACTION | ||
| 547 | |||
| 548 | YY_DECL | ||
| 549 | { | ||
| 550 | register yy_state_type yy_current_state; | ||
| 551 | register char *yy_cp, *yy_bp; | ||
| 552 | register int yy_act; | ||
| 553 | |||
| 554 | #line 21 "input.l" | ||
| 555 | |||
| 556 | |||
| 557 | #line 558 "lex.yy.c" | ||
| 558 | |||
| 559 | if ( yy_init ) | ||
| 560 | { | ||
| 561 | yy_init = 0; | ||
| 562 | |||
| 563 | #ifdef YY_USER_INIT | ||
| 564 | YY_USER_INIT; | ||
| 565 | #endif | ||
| 566 | |||
| 567 | if ( ! yy_start ) | ||
| 568 | yy_start = 1; /* first start state */ | ||
| 569 | |||
| 570 | if ( ! yyin ) | ||
| 571 | yyin = stdin; | ||
| 572 | |||
| 573 | if ( ! yyout ) | ||
| 574 | yyout = stdout; | ||
| 575 | |||
| 576 | if ( ! yy_current_buffer ) | ||
| 577 | yy_current_buffer = | ||
| 578 | yy_create_buffer( yyin, YY_BUF_SIZE ); | ||
| 579 | |||
| 580 | yy_load_buffer_state(); | ||
| 581 | } | ||
| 582 | |||
| 583 | while ( 1 ) /* loops until end-of-file is reached */ | ||
| 584 | { | ||
| 585 | yy_cp = yy_c_buf_p; | ||
| 586 | |||
| 587 | /* Support of yytext. */ | ||
| 588 | *yy_cp = yy_hold_char; | ||
| 589 | |||
| 590 | /* yy_bp points to the position in yy_ch_buf of the start of | ||
| 591 | * the current run. | ||
| 592 | */ | ||
| 593 | yy_bp = yy_cp; | ||
| 594 | |||
| 595 | yy_current_state = yy_start; | ||
| 596 | yy_match: | ||
| 597 | do | ||
| 598 | { | ||
| 599 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; | ||
| 600 | if ( yy_accept[yy_current_state] ) | ||
| 601 | { | ||
| 602 | yy_last_accepting_state = yy_current_state; | ||
| 603 | yy_last_accepting_cpos = yy_cp; | ||
| 604 | } | ||
| 605 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 606 | { | ||
| 607 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 608 | if ( yy_current_state >= 36 ) | ||
| 609 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 610 | } | ||
| 611 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
| 612 | ++yy_cp; | ||
| 613 | } | ||
| 614 | while ( yy_base[yy_current_state] != 54 ); | ||
| 615 | |||
| 616 | yy_find_action: | ||
| 617 | yy_act = yy_accept[yy_current_state]; | ||
| 618 | if ( yy_act == 0 ) | ||
| 619 | { /* have to back up */ | ||
| 620 | yy_cp = yy_last_accepting_cpos; | ||
| 621 | yy_current_state = yy_last_accepting_state; | ||
| 622 | yy_act = yy_accept[yy_current_state]; | ||
| 623 | } | ||
| 624 | |||
| 625 | YY_DO_BEFORE_ACTION; | ||
| 626 | |||
| 627 | |||
| 628 | do_action: /* This label is used only to access EOF actions. */ | ||
| 629 | |||
| 630 | |||
| 631 | switch ( yy_act ) | ||
| 632 | { /* beginning of action switch */ | ||
| 633 | case 0: /* must back up */ | ||
| 634 | /* undo the effects of YY_DO_BEFORE_ACTION */ | ||
| 635 | *yy_cp = yy_hold_char; | ||
| 636 | yy_cp = yy_last_accepting_cpos; | ||
| 637 | yy_current_state = yy_last_accepting_state; | ||
| 638 | goto yy_find_action; | ||
| 639 | |||
| 640 | case 1: | ||
| 641 | YY_RULE_SETUP | ||
| 642 | #line 23 "input.l" | ||
| 643 | ; | ||
| 644 | YY_BREAK | ||
| 645 | case 2: | ||
| 646 | YY_RULE_SETUP | ||
| 647 | #line 25 "input.l" | ||
| 648 | { | ||
| 649 | yylval.str = strdup (yytext + 1); | ||
| 650 | yylval.str[strlen (yylval.str) - 1] = '\0'; | ||
| 651 | |||
| 652 | return (TERM); | ||
| 653 | } | ||
| 654 | YY_BREAK | ||
| 655 | case 3: | ||
| 656 | YY_RULE_SETUP | ||
| 657 | #line 32 "input.l" | ||
| 658 | { | ||
| 659 | sscanf (yytext, "%u", &yylval.uint); | ||
| 660 | |||
| 661 | return (NUM); | ||
| 662 | } | ||
| 663 | YY_BREAK | ||
| 664 | case 4: | ||
| 665 | YY_RULE_SETUP | ||
| 666 | #line 38 "input.l" | ||
| 667 | { | ||
| 668 | sscanf (yytext, "0x%x", &yylval.uint); | ||
| 669 | |||
| 670 | return (NUM); | ||
| 671 | } | ||
| 672 | YY_BREAK | ||
| 673 | case 5: | ||
| 674 | *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ | ||
| 675 | yy_c_buf_p = yy_cp = yy_bp + 1; | ||
| 676 | YY_DO_BEFORE_ACTION; /* set up yytext again */ | ||
| 677 | YY_RULE_SETUP | ||
| 678 | #line 44 "input.l" | ||
| 679 | { | ||
| 680 | yylval.str = strdup (yytext); | ||
| 681 | |||
| 682 | return (NSSTR); | ||
| 683 | } | ||
| 684 | YY_BREAK | ||
| 685 | case 6: | ||
| 686 | YY_RULE_SETUP | ||
| 687 | #line 50 "input.l" | ||
| 688 | { | ||
| 689 | return (FILTER); | ||
| 690 | } | ||
| 691 | YY_BREAK | ||
| 692 | case 7: | ||
| 693 | YY_RULE_SETUP | ||
| 694 | #line 54 "input.l" | ||
| 695 | { | ||
| 696 | return (NEGFILTER); | ||
| 697 | } | ||
| 698 | YY_BREAK | ||
| 699 | case 8: | ||
| 700 | YY_RULE_SETUP | ||
| 701 | #line 58 "input.l" | ||
| 702 | { | ||
| 703 | return (SIZE); | ||
| 704 | } | ||
| 705 | YY_BREAK | ||
| 706 | case 9: | ||
| 707 | YY_RULE_SETUP | ||
| 708 | #line 62 "input.l" | ||
| 709 | ECHO; | ||
| 710 | YY_BREAK | ||
| 711 | #line 712 "lex.yy.c" | ||
| 712 | case YY_STATE_EOF(INITIAL): | ||
| 713 | yyterminate(); | ||
| 714 | |||
| 715 | case YY_END_OF_BUFFER: | ||
| 716 | { | ||
| 717 | /* Amount of text matched not including the EOB char. */ | ||
| 718 | int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; | ||
| 719 | |||
| 720 | /* Undo the effects of YY_DO_BEFORE_ACTION. */ | ||
| 721 | *yy_cp = yy_hold_char; | ||
| 722 | YY_RESTORE_YY_MORE_OFFSET | ||
| 723 | |||
| 724 | if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) | ||
| 725 | { | ||
| 726 | /* We're scanning a new file or input source. It's | ||
| 727 | * possible that this happened because the user | ||
| 728 | * just pointed yyin at a new source and called | ||
| 729 | * yylex(). If so, then we have to assure | ||
| 730 | * consistency between yy_current_buffer and our | ||
| 731 | * globals. Here is the right place to do so, because | ||
| 732 | * this is the first action (other than possibly a | ||
| 733 | * back-up) that will match for the new input source. | ||
| 734 | */ | ||
| 735 | yy_n_chars = yy_current_buffer->yy_n_chars; | ||
| 736 | yy_current_buffer->yy_input_file = yyin; | ||
| 737 | yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; | ||
| 738 | } | ||
| 739 | |||
| 740 | /* Note that here we test for yy_c_buf_p "<=" to the position | ||
| 741 | * of the first EOB in the buffer, since yy_c_buf_p will | ||
| 742 | * already have been incremented past the NUL character | ||
| 743 | * (since all states make transitions on EOB to the | ||
| 744 | * end-of-buffer state). Contrast this with the test | ||
| 745 | * in input(). | ||
| 746 | */ | ||
| 747 | if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) | ||
| 748 | { /* This was really a NUL. */ | ||
| 749 | yy_state_type yy_next_state; | ||
| 750 | |||
| 751 | yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; | ||
| 752 | |||
| 753 | yy_current_state = yy_get_previous_state(); | ||
| 754 | |||
| 755 | /* Okay, we're now positioned to make the NUL | ||
| 756 | * transition. We couldn't have | ||
| 757 | * yy_get_previous_state() go ahead and do it | ||
| 758 | * for us because it doesn't know how to deal | ||
| 759 | * with the possibility of jamming (and we don't | ||
| 760 | * want to build jamming into it because then it | ||
| 761 | * will run more slowly). | ||
| 762 | */ | ||
| 763 | |||
| 764 | yy_next_state = yy_try_NUL_trans( yy_current_state ); | ||
| 765 | |||
| 766 | yy_bp = yytext_ptr + YY_MORE_ADJ; | ||
| 767 | |||
| 768 | if ( yy_next_state ) | ||
| 769 | { | ||
| 770 | /* Consume the NUL. */ | ||
| 771 | yy_cp = ++yy_c_buf_p; | ||
| 772 | yy_current_state = yy_next_state; | ||
| 773 | goto yy_match; | ||
| 774 | } | ||
| 775 | |||
| 776 | else | ||
| 777 | { | ||
| 778 | yy_cp = yy_c_buf_p; | ||
| 779 | goto yy_find_action; | ||
| 780 | } | ||
| 781 | } | ||
| 782 | |||
| 783 | else switch ( yy_get_next_buffer() ) | ||
| 784 | { | ||
| 785 | case EOB_ACT_END_OF_FILE: | ||
| 786 | { | ||
| 787 | yy_did_buffer_switch_on_eof = 0; | ||
| 788 | |||
| 789 | if ( yywrap() ) | ||
| 790 | { | ||
| 791 | /* Note: because we've taken care in | ||
| 792 | * yy_get_next_buffer() to have set up | ||
| 793 | * yytext, we can now set up | ||
| 794 | * yy_c_buf_p so that if some total | ||
| 795 | * hoser (like flex itself) wants to | ||
| 796 | * call the scanner after we return the | ||
| 797 | * YY_NULL, it'll still work - another | ||
| 798 | * YY_NULL will get returned. | ||
| 799 | */ | ||
| 800 | yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; | ||
| 801 | |||
| 802 | yy_act = YY_STATE_EOF(YY_START); | ||
| 803 | goto do_action; | ||
| 804 | } | ||
| 805 | |||
| 806 | else | ||
| 807 | { | ||
| 808 | if ( ! yy_did_buffer_switch_on_eof ) | ||
| 809 | YY_NEW_FILE; | ||
| 810 | } | ||
| 811 | break; | ||
| 812 | } | ||
| 813 | |||
| 814 | case EOB_ACT_CONTINUE_SCAN: | ||
| 815 | yy_c_buf_p = | ||
| 816 | yytext_ptr + yy_amount_of_matched_text; | ||
| 817 | |||
| 818 | yy_current_state = yy_get_previous_state(); | ||
| 819 | |||
| 820 | yy_cp = yy_c_buf_p; | ||
| 821 | yy_bp = yytext_ptr + YY_MORE_ADJ; | ||
| 822 | goto yy_match; | ||
| 823 | |||
| 824 | case EOB_ACT_LAST_MATCH: | ||
| 825 | yy_c_buf_p = | ||
| 826 | &yy_current_buffer->yy_ch_buf[yy_n_chars]; | ||
| 827 | |||
| 828 | yy_current_state = yy_get_previous_state(); | ||
| 829 | |||
| 830 | yy_cp = yy_c_buf_p; | ||
| 831 | yy_bp = yytext_ptr + YY_MORE_ADJ; | ||
| 832 | goto yy_find_action; | ||
| 833 | } | ||
| 834 | break; | ||
| 835 | } | ||
| 836 | |||
| 837 | default: | ||
| 838 | YY_FATAL_ERROR( | ||
| 839 | "fatal flex scanner internal error--no action found" ); | ||
| 840 | } /* end of action switch */ | ||
| 841 | } /* end of scanning one token */ | ||
| 842 | } /* end of yylex */ | ||
| 843 | |||
| 844 | |||
| 845 | /* yy_get_next_buffer - try to read in a new buffer | ||
| 846 | * | ||
| 847 | * Returns a code representing an action: | ||
| 848 | * EOB_ACT_LAST_MATCH - | ||
| 849 | * EOB_ACT_CONTINUE_SCAN - continue scanning from current position | ||
| 850 | * EOB_ACT_END_OF_FILE - end of file | ||
| 851 | */ | ||
| 852 | |||
| 853 | static int yy_get_next_buffer() | ||
| 854 | { | ||
| 855 | register char *dest = yy_current_buffer->yy_ch_buf; | ||
| 856 | register char *source = yytext_ptr; | ||
| 857 | register int number_to_move, i; | ||
| 858 | int ret_val; | ||
| 859 | |||
| 860 | if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) | ||
| 861 | YY_FATAL_ERROR( | ||
| 862 | "fatal flex scanner internal error--end of buffer missed" ); | ||
| 863 | |||
| 864 | if ( yy_current_buffer->yy_fill_buffer == 0 ) | ||
| 865 | { /* Don't try to fill the buffer, so this is an EOF. */ | ||
| 866 | if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) | ||
| 867 | { | ||
| 868 | /* We matched a single character, the EOB, so | ||
| 869 | * treat this as a final EOF. | ||
| 870 | */ | ||
| 871 | return EOB_ACT_END_OF_FILE; | ||
| 872 | } | ||
| 873 | |||
| 874 | else | ||
| 875 | { | ||
| 876 | /* We matched some text prior to the EOB, first | ||
| 877 | * process it. | ||
| 878 | */ | ||
| 879 | return EOB_ACT_LAST_MATCH; | ||
| 880 | } | ||
| 881 | } | ||
| 882 | |||
| 883 | /* Try to read more data. */ | ||
| 884 | |||
| 885 | /* First move last chars to start of buffer. */ | ||
| 886 | number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; | ||
| 887 | |||
| 888 | for ( i = 0; i < number_to_move; ++i ) | ||
| 889 | *(dest++) = *(source++); | ||
| 890 | |||
| 891 | if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) | ||
| 892 | /* don't do the read, it's not guaranteed to return an EOF, | ||
| 893 | * just force an EOF | ||
| 894 | */ | ||
| 895 | yy_current_buffer->yy_n_chars = yy_n_chars = 0; | ||
| 896 | |||
| 897 | else | ||
| 898 | { | ||
| 899 | int num_to_read = | ||
| 900 | yy_current_buffer->yy_buf_size - number_to_move - 1; | ||
| 901 | |||
| 902 | while ( num_to_read <= 0 ) | ||
| 903 | { /* Not enough room in the buffer - grow it. */ | ||
| 904 | #ifdef YY_USES_REJECT | ||
| 905 | YY_FATAL_ERROR( | ||
| 906 | "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); | ||
| 907 | #else | ||
| 908 | |||
| 909 | /* just a shorter name for the current buffer */ | ||
| 910 | YY_BUFFER_STATE b = yy_current_buffer; | ||
| 911 | |||
| 912 | int yy_c_buf_p_offset = | ||
| 913 | (int) (yy_c_buf_p - b->yy_ch_buf); | ||
| 914 | |||
| 915 | if ( b->yy_is_our_buffer ) | ||
| 916 | { | ||
| 917 | int new_size = b->yy_buf_size * 2; | ||
| 918 | |||
| 919 | if ( new_size <= 0 ) | ||
| 920 | b->yy_buf_size += b->yy_buf_size / 8; | ||
| 921 | else | ||
| 922 | b->yy_buf_size *= 2; | ||
| 923 | |||
| 924 | b->yy_ch_buf = (char *) | ||
| 925 | /* Include room in for 2 EOB chars. */ | ||
| 926 | yy_flex_realloc( (void *) b->yy_ch_buf, | ||
| 927 | b->yy_buf_size + 2 ); | ||
| 928 | } | ||
| 929 | else | ||
| 930 | /* Can't grow it, we don't own it. */ | ||
| 931 | b->yy_ch_buf = 0; | ||
| 932 | |||
| 933 | if ( ! b->yy_ch_buf ) | ||
| 934 | YY_FATAL_ERROR( | ||
| 935 | "fatal error - scanner input buffer overflow" ); | ||
| 936 | |||
| 937 | yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; | ||
| 938 | |||
| 939 | num_to_read = yy_current_buffer->yy_buf_size - | ||
| 940 | number_to_move - 1; | ||
| 941 | #endif | ||
| 942 | } | ||
| 943 | |||
| 944 | if ( num_to_read > YY_READ_BUF_SIZE ) | ||
| 945 | num_to_read = YY_READ_BUF_SIZE; | ||
| 946 | |||
| 947 | /* Read in more data. */ | ||
| 948 | YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), | ||
| 949 | yy_n_chars, num_to_read ); | ||
| 950 | |||
| 951 | yy_current_buffer->yy_n_chars = yy_n_chars; | ||
| 952 | } | ||
| 953 | |||
| 954 | if ( yy_n_chars == 0 ) | ||
| 955 | { | ||
| 956 | if ( number_to_move == YY_MORE_ADJ ) | ||
| 957 | { | ||
| 958 | ret_val = EOB_ACT_END_OF_FILE; | ||
| 959 | yyrestart( yyin ); | ||
| 960 | } | ||
| 961 | |||
| 962 | else | ||
| 963 | { | ||
| 964 | ret_val = EOB_ACT_LAST_MATCH; | ||
| 965 | yy_current_buffer->yy_buffer_status = | ||
| 966 | YY_BUFFER_EOF_PENDING; | ||
| 967 | } | ||
| 968 | } | ||
| 969 | |||
| 970 | else | ||
| 971 | ret_val = EOB_ACT_CONTINUE_SCAN; | ||
| 972 | |||
| 973 | yy_n_chars += number_to_move; | ||
| 974 | yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; | ||
| 975 | yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; | ||
| 976 | |||
| 977 | yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; | ||
| 978 | |||
| 979 | return ret_val; | ||
| 980 | } | ||
| 981 | |||
| 982 | |||
| 983 | /* yy_get_previous_state - get the state just before the EOB char was reached */ | ||
| 984 | |||
| 985 | static yy_state_type yy_get_previous_state() | ||
| 986 | { | ||
| 987 | register yy_state_type yy_current_state; | ||
| 988 | register char *yy_cp; | ||
| 989 | |||
| 990 | yy_current_state = yy_start; | ||
| 991 | |||
| 992 | for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) | ||
| 993 | { | ||
| 994 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); | ||
| 995 | if ( yy_accept[yy_current_state] ) | ||
| 996 | { | ||
| 997 | yy_last_accepting_state = yy_current_state; | ||
| 998 | yy_last_accepting_cpos = yy_cp; | ||
| 999 | } | ||
| 1000 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 1001 | { | ||
| 1002 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 1003 | if ( yy_current_state >= 36 ) | ||
| 1004 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 1005 | } | ||
| 1006 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | return yy_current_state; | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | |||
| 1013 | /* yy_try_NUL_trans - try to make a transition on the NUL character | ||
| 1014 | * | ||
| 1015 | * synopsis | ||
| 1016 | * next_state = yy_try_NUL_trans( current_state ); | ||
| 1017 | */ | ||
| 1018 | |||
| 1019 | #ifdef YY_USE_PROTOS | ||
| 1020 | static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) | ||
| 1021 | #else | ||
| 1022 | static yy_state_type yy_try_NUL_trans( yy_current_state ) | ||
| 1023 | yy_state_type yy_current_state; | ||
| 1024 | #endif | ||
| 1025 | { | ||
| 1026 | register int yy_is_jam; | ||
| 1027 | register char *yy_cp = yy_c_buf_p; | ||
| 1028 | |||
| 1029 | register YY_CHAR yy_c = 1; | ||
| 1030 | if ( yy_accept[yy_current_state] ) | ||
| 1031 | { | ||
| 1032 | yy_last_accepting_state = yy_current_state; | ||
| 1033 | yy_last_accepting_cpos = yy_cp; | ||
| 1034 | } | ||
| 1035 | while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) | ||
| 1036 | { | ||
| 1037 | yy_current_state = (int) yy_def[yy_current_state]; | ||
| 1038 | if ( yy_current_state >= 36 ) | ||
| 1039 | yy_c = yy_meta[(unsigned int) yy_c]; | ||
| 1040 | } | ||
| 1041 | yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; | ||
| 1042 | yy_is_jam = (yy_current_state == 35); | ||
| 1043 | |||
| 1044 | return yy_is_jam ? 0 : yy_current_state; | ||
| 1045 | } | ||
| 1046 | |||
| 1047 | |||
| 1048 | #ifndef YY_NO_UNPUT | ||
| 1049 | #ifdef YY_USE_PROTOS | ||
| 1050 | static void yyunput( int c, register char *yy_bp ) | ||
| 1051 | #else | ||
| 1052 | static void yyunput( c, yy_bp ) | ||
| 1053 | int c; | ||
| 1054 | register char *yy_bp; | ||
| 1055 | #endif | ||
| 1056 | { | ||
| 1057 | register char *yy_cp = yy_c_buf_p; | ||
| 1058 | |||
| 1059 | /* undo effects of setting up yytext */ | ||
| 1060 | *yy_cp = yy_hold_char; | ||
| 1061 | |||
| 1062 | if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) | ||
| 1063 | { /* need to shift things up to make room */ | ||
| 1064 | /* +2 for EOB chars. */ | ||
| 1065 | register int number_to_move = yy_n_chars + 2; | ||
| 1066 | register char *dest = &yy_current_buffer->yy_ch_buf[ | ||
| 1067 | yy_current_buffer->yy_buf_size + 2]; | ||
| 1068 | register char *source = | ||
| 1069 | &yy_current_buffer->yy_ch_buf[number_to_move]; | ||
| 1070 | |||
| 1071 | while ( source > yy_current_buffer->yy_ch_buf ) | ||
| 1072 | *--dest = *--source; | ||
| 1073 | |||
| 1074 | yy_cp += (int) (dest - source); | ||
| 1075 | yy_bp += (int) (dest - source); | ||
| 1076 | yy_current_buffer->yy_n_chars = | ||
| 1077 | yy_n_chars = yy_current_buffer->yy_buf_size; | ||
| 1078 | |||
| 1079 | if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) | ||
| 1080 | YY_FATAL_ERROR( "flex scanner push-back overflow" ); | ||
| 1081 | } | ||
| 1082 | |||
| 1083 | *--yy_cp = (char) c; | ||
| 1084 | |||
| 1085 | |||
| 1086 | yytext_ptr = yy_bp; | ||
| 1087 | yy_hold_char = *yy_cp; | ||
| 1088 | yy_c_buf_p = yy_cp; | ||
| 1089 | } | ||
| 1090 | #endif /* ifndef YY_NO_UNPUT */ | ||
| 1091 | |||
| 1092 | |||
| 1093 | #ifdef __cplusplus | ||
| 1094 | static int yyinput() | ||
| 1095 | #else | ||
| 1096 | static int input() | ||
| 1097 | #endif | ||
| 1098 | { | ||
| 1099 | int c; | ||
| 1100 | |||
| 1101 | *yy_c_buf_p = yy_hold_char; | ||
| 1102 | |||
| 1103 | if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) | ||
| 1104 | { | ||
| 1105 | /* yy_c_buf_p now points to the character we want to return. | ||
| 1106 | * If this occurs *before* the EOB characters, then it's a | ||
| 1107 | * valid NUL; if not, then we've hit the end of the buffer. | ||
| 1108 | */ | ||
| 1109 | if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) | ||
| 1110 | /* This was really a NUL. */ | ||
| 1111 | *yy_c_buf_p = '\0'; | ||
| 1112 | |||
| 1113 | else | ||
| 1114 | { /* need more input */ | ||
| 1115 | int offset = yy_c_buf_p - yytext_ptr; | ||
| 1116 | ++yy_c_buf_p; | ||
| 1117 | |||
| 1118 | switch ( yy_get_next_buffer() ) | ||
| 1119 | { | ||
| 1120 | case EOB_ACT_LAST_MATCH: | ||
| 1121 | /* This happens because yy_g_n_b() | ||
| 1122 | * sees that we've accumulated a | ||
| 1123 | * token and flags that we need to | ||
| 1124 | * try matching the token before | ||
| 1125 | * proceeding. But for input(), | ||
| 1126 | * there's no matching to consider. | ||
| 1127 | * So convert the EOB_ACT_LAST_MATCH | ||
| 1128 | * to EOB_ACT_END_OF_FILE. | ||
| 1129 | */ | ||
| 1130 | |||
| 1131 | /* Reset buffer status. */ | ||
| 1132 | yyrestart( yyin ); | ||
| 1133 | |||
| 1134 | /* fall through */ | ||
| 1135 | |||
| 1136 | case EOB_ACT_END_OF_FILE: | ||
| 1137 | { | ||
| 1138 | if ( yywrap() ) | ||
| 1139 | return EOF; | ||
| 1140 | |||
| 1141 | if ( ! yy_did_buffer_switch_on_eof ) | ||
| 1142 | YY_NEW_FILE; | ||
| 1143 | #ifdef __cplusplus | ||
| 1144 | return yyinput(); | ||
| 1145 | #else | ||
| 1146 | return input(); | ||
| 1147 | #endif | ||
| 1148 | } | ||
| 1149 | |||
| 1150 | case EOB_ACT_CONTINUE_SCAN: | ||
| 1151 | yy_c_buf_p = yytext_ptr + offset; | ||
| 1152 | break; | ||
| 1153 | } | ||
| 1154 | } | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ | ||
| 1158 | *yy_c_buf_p = '\0'; /* preserve yytext */ | ||
| 1159 | yy_hold_char = *++yy_c_buf_p; | ||
| 1160 | |||
| 1161 | |||
| 1162 | return c; | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | |||
| 1166 | #ifdef YY_USE_PROTOS | ||
| 1167 | void yyrestart( FILE *input_file ) | ||
| 1168 | #else | ||
| 1169 | void yyrestart( input_file ) | ||
| 1170 | FILE *input_file; | ||
| 1171 | #endif | ||
| 1172 | { | ||
| 1173 | if ( ! yy_current_buffer ) | ||
| 1174 | yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); | ||
| 1175 | |||
| 1176 | yy_init_buffer( yy_current_buffer, input_file ); | ||
| 1177 | yy_load_buffer_state(); | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | |||
| 1181 | #ifdef YY_USE_PROTOS | ||
| 1182 | void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) | ||
| 1183 | #else | ||
| 1184 | void yy_switch_to_buffer( new_buffer ) | ||
| 1185 | YY_BUFFER_STATE new_buffer; | ||
| 1186 | #endif | ||
| 1187 | { | ||
| 1188 | if ( yy_current_buffer == new_buffer ) | ||
| 1189 | return; | ||
| 1190 | |||
| 1191 | if ( yy_current_buffer ) | ||
| 1192 | { | ||
| 1193 | /* Flush out information for old buffer. */ | ||
| 1194 | *yy_c_buf_p = yy_hold_char; | ||
| 1195 | yy_current_buffer->yy_buf_pos = yy_c_buf_p; | ||
| 1196 | yy_current_buffer->yy_n_chars = yy_n_chars; | ||
| 1197 | } | ||
| 1198 | |||
| 1199 | yy_current_buffer = new_buffer; | ||
| 1200 | yy_load_buffer_state(); | ||
| 1201 | |||
| 1202 | /* We don't actually know whether we did this switch during | ||
| 1203 | * EOF (yywrap()) processing, but the only time this flag | ||
| 1204 | * is looked at is after yywrap() is called, so it's safe | ||
| 1205 | * to go ahead and always set it. | ||
| 1206 | */ | ||
| 1207 | yy_did_buffer_switch_on_eof = 1; | ||
| 1208 | } | ||
| 1209 | |||
| 1210 | |||
| 1211 | #ifdef YY_USE_PROTOS | ||
| 1212 | void yy_load_buffer_state( void ) | ||
| 1213 | #else | ||
| 1214 | void yy_load_buffer_state() | ||
| 1215 | #endif | ||
| 1216 | { | ||
| 1217 | yy_n_chars = yy_current_buffer->yy_n_chars; | ||
| 1218 | yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; | ||
| 1219 | yyin = yy_current_buffer->yy_input_file; | ||
| 1220 | yy_hold_char = *yy_c_buf_p; | ||
| 1221 | } | ||
| 1222 | |||
| 1223 | |||
| 1224 | #ifdef YY_USE_PROTOS | ||
| 1225 | YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) | ||
| 1226 | #else | ||
| 1227 | YY_BUFFER_STATE yy_create_buffer( file, size ) | ||
| 1228 | FILE *file; | ||
| 1229 | int size; | ||
| 1230 | #endif | ||
| 1231 | { | ||
| 1232 | YY_BUFFER_STATE b; | ||
| 1233 | |||
| 1234 | b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); | ||
| 1235 | if ( ! b ) | ||
| 1236 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
| 1237 | |||
| 1238 | b->yy_buf_size = size; | ||
| 1239 | |||
| 1240 | /* yy_ch_buf has to be 2 characters longer than the size given because | ||
| 1241 | * we need to put in 2 end-of-buffer characters. | ||
| 1242 | */ | ||
| 1243 | b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); | ||
| 1244 | if ( ! b->yy_ch_buf ) | ||
| 1245 | YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); | ||
| 1246 | |||
| 1247 | b->yy_is_our_buffer = 1; | ||
| 1248 | |||
| 1249 | yy_init_buffer( b, file ); | ||
| 1250 | |||
| 1251 | return b; | ||
| 1252 | } | ||
| 1253 | |||
| 1254 | |||
| 1255 | #ifdef YY_USE_PROTOS | ||
| 1256 | void yy_delete_buffer( YY_BUFFER_STATE b ) | ||
| 1257 | #else | ||
| 1258 | void yy_delete_buffer( b ) | ||
| 1259 | YY_BUFFER_STATE b; | ||
| 1260 | #endif | ||
| 1261 | { | ||
| 1262 | if ( ! b ) | ||
| 1263 | return; | ||
| 1264 | |||
| 1265 | if ( b == yy_current_buffer ) | ||
| 1266 | yy_current_buffer = (YY_BUFFER_STATE) 0; | ||
| 1267 | |||
| 1268 | if ( b->yy_is_our_buffer ) | ||
| 1269 | yy_flex_free( (void *) b->yy_ch_buf ); | ||
| 1270 | |||
| 1271 | yy_flex_free( (void *) b ); | ||
| 1272 | } | ||
| 1273 | |||
| 1274 | |||
| 1275 | #ifndef YY_ALWAYS_INTERACTIVE | ||
| 1276 | #ifndef YY_NEVER_INTERACTIVE | ||
| 1277 | extern int isatty YY_PROTO(( int )); | ||
| 1278 | #endif | ||
| 1279 | #endif | ||
| 1280 | |||
| 1281 | #ifdef YY_USE_PROTOS | ||
| 1282 | void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) | ||
| 1283 | #else | ||
| 1284 | void yy_init_buffer( b, file ) | ||
| 1285 | YY_BUFFER_STATE b; | ||
| 1286 | FILE *file; | ||
| 1287 | #endif | ||
| 1288 | |||
| 1289 | |||
| 1290 | { | ||
| 1291 | yy_flush_buffer( b ); | ||
| 1292 | |||
| 1293 | b->yy_input_file = file; | ||
| 1294 | b->yy_fill_buffer = 1; | ||
| 1295 | |||
| 1296 | #if YY_ALWAYS_INTERACTIVE | ||
| 1297 | b->yy_is_interactive = 1; | ||
| 1298 | #else | ||
| 1299 | #if YY_NEVER_INTERACTIVE | ||
| 1300 | b->yy_is_interactive = 0; | ||
| 1301 | #else | ||
| 1302 | b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; | ||
| 1303 | #endif | ||
| 1304 | #endif | ||
| 1305 | } | ||
| 1306 | |||
| 1307 | |||
| 1308 | #ifdef YY_USE_PROTOS | ||
| 1309 | void yy_flush_buffer( YY_BUFFER_STATE b ) | ||
| 1310 | #else | ||
| 1311 | void yy_flush_buffer( b ) | ||
| 1312 | YY_BUFFER_STATE b; | ||
| 1313 | #endif | ||
| 1314 | |||
| 1315 | { | ||
| 1316 | if ( ! b ) | ||
| 1317 | return; | ||
| 1318 | |||
| 1319 | b->yy_n_chars = 0; | ||
| 1320 | |||
| 1321 | /* We always need two end-of-buffer characters. The first causes | ||
| 1322 | * a transition to the end-of-buffer state. The second causes | ||
| 1323 | * a jam in that state. | ||
| 1324 | */ | ||
| 1325 | b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; | ||
| 1326 | b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; | ||
| 1327 | |||
| 1328 | b->yy_buf_pos = &b->yy_ch_buf[0]; | ||
| 1329 | |||
| 1330 | b->yy_at_bol = 1; | ||
| 1331 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
| 1332 | |||
| 1333 | if ( b == yy_current_buffer ) | ||
| 1334 | yy_load_buffer_state(); | ||
| 1335 | } | ||
| 1336 | |||
| 1337 | |||
| 1338 | #ifndef YY_NO_SCAN_BUFFER | ||
| 1339 | #ifdef YY_USE_PROTOS | ||
| 1340 | YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) | ||
| 1341 | #else | ||
| 1342 | YY_BUFFER_STATE yy_scan_buffer( base, size ) | ||
| 1343 | char *base; | ||
| 1344 | yy_size_t size; | ||
| 1345 | #endif | ||
| 1346 | { | ||
| 1347 | YY_BUFFER_STATE b; | ||
| 1348 | |||
| 1349 | if ( size < 2 || | ||
| 1350 | base[size-2] != YY_END_OF_BUFFER_CHAR || | ||
| 1351 | base[size-1] != YY_END_OF_BUFFER_CHAR ) | ||
| 1352 | /* They forgot to leave room for the EOB's. */ | ||
| 1353 | return 0; | ||
| 1354 | |||
| 1355 | b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); | ||
| 1356 | if ( ! b ) | ||
| 1357 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); | ||
| 1358 | |||
| 1359 | b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ | ||
| 1360 | b->yy_buf_pos = b->yy_ch_buf = base; | ||
| 1361 | b->yy_is_our_buffer = 0; | ||
| 1362 | b->yy_input_file = 0; | ||
| 1363 | b->yy_n_chars = b->yy_buf_size; | ||
| 1364 | b->yy_is_interactive = 0; | ||
| 1365 | b->yy_at_bol = 1; | ||
| 1366 | b->yy_fill_buffer = 0; | ||
| 1367 | b->yy_buffer_status = YY_BUFFER_NEW; | ||
| 1368 | |||
| 1369 | yy_switch_to_buffer( b ); | ||
| 1370 | |||
| 1371 | return b; | ||
| 1372 | } | ||
| 1373 | #endif | ||
| 1374 | |||
| 1375 | |||
| 1376 | #ifndef YY_NO_SCAN_STRING | ||
| 1377 | #ifdef YY_USE_PROTOS | ||
| 1378 | YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) | ||
| 1379 | #else | ||
| 1380 | YY_BUFFER_STATE yy_scan_string( yy_str ) | ||
| 1381 | yyconst char *yy_str; | ||
| 1382 | #endif | ||
| 1383 | { | ||
| 1384 | int len; | ||
| 1385 | for ( len = 0; yy_str[len]; ++len ) | ||
| 1386 | ; | ||
| 1387 | |||
| 1388 | return yy_scan_bytes( yy_str, len ); | ||
| 1389 | } | ||
| 1390 | #endif | ||
| 1391 | |||
| 1392 | |||
| 1393 | #ifndef YY_NO_SCAN_BYTES | ||
| 1394 | #ifdef YY_USE_PROTOS | ||
| 1395 | YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) | ||
| 1396 | #else | ||
| 1397 | YY_BUFFER_STATE yy_scan_bytes( bytes, len ) | ||
| 1398 | yyconst char *bytes; | ||
| 1399 | int len; | ||
| 1400 | #endif | ||
| 1401 | { | ||
| 1402 | YY_BUFFER_STATE b; | ||
| 1403 | char *buf; | ||
| 1404 | yy_size_t n; | ||
| 1405 | int i; | ||
| 1406 | |||
| 1407 | /* Get memory for full buffer, including space for trailing EOB's. */ | ||
| 1408 | n = len + 2; | ||
| 1409 | buf = (char *) yy_flex_alloc( n ); | ||
| 1410 | if ( ! buf ) | ||
| 1411 | YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); | ||
| 1412 | |||
| 1413 | for ( i = 0; i < len; ++i ) | ||
| 1414 | buf[i] = bytes[i]; | ||
| 1415 | |||
| 1416 | buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; | ||
| 1417 | |||
| 1418 | b = yy_scan_buffer( buf, n ); | ||
| 1419 | if ( ! b ) | ||
| 1420 | YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); | ||
| 1421 | |||
| 1422 | /* It's okay to grow etc. this buffer, and we should throw it | ||
| 1423 | * away when we're done. | ||
| 1424 | */ | ||
| 1425 | b->yy_is_our_buffer = 1; | ||
| 1426 | |||
| 1427 | return b; | ||
| 1428 | } | ||
| 1429 | #endif | ||
| 1430 | |||
| 1431 | |||
| 1432 | #ifndef YY_NO_PUSH_STATE | ||
| 1433 | #ifdef YY_USE_PROTOS | ||
| 1434 | static void yy_push_state( int new_state ) | ||
| 1435 | #else | ||
| 1436 | static void yy_push_state( new_state ) | ||
| 1437 | int new_state; | ||
| 1438 | #endif | ||
| 1439 | { | ||
| 1440 | if ( yy_start_stack_ptr >= yy_start_stack_depth ) | ||
| 1441 | { | ||
| 1442 | yy_size_t new_size; | ||
| 1443 | |||
| 1444 | yy_start_stack_depth += YY_START_STACK_INCR; | ||
| 1445 | new_size = yy_start_stack_depth * sizeof( int ); | ||
| 1446 | |||
| 1447 | if ( ! yy_start_stack ) | ||
| 1448 | yy_start_stack = (int *) yy_flex_alloc( new_size ); | ||
| 1449 | |||
| 1450 | else | ||
| 1451 | yy_start_stack = (int *) yy_flex_realloc( | ||
| 1452 | (void *) yy_start_stack, new_size ); | ||
| 1453 | |||
| 1454 | if ( ! yy_start_stack ) | ||
| 1455 | YY_FATAL_ERROR( | ||
| 1456 | "out of memory expanding start-condition stack" ); | ||
| 1457 | } | ||
| 1458 | |||
| 1459 | yy_start_stack[yy_start_stack_ptr++] = YY_START; | ||
| 1460 | |||
| 1461 | BEGIN(new_state); | ||
| 1462 | } | ||
| 1463 | #endif | ||
| 1464 | |||
| 1465 | |||
| 1466 | #ifndef YY_NO_POP_STATE | ||
| 1467 | static void yy_pop_state() | ||
| 1468 | { | ||
| 1469 | if ( --yy_start_stack_ptr < 0 ) | ||
| 1470 | YY_FATAL_ERROR( "start-condition stack underflow" ); | ||
| 1471 | |||
| 1472 | BEGIN(yy_start_stack[yy_start_stack_ptr]); | ||
| 1473 | } | ||
| 1474 | #endif | ||
| 1475 | |||
| 1476 | |||
| 1477 | #ifndef YY_NO_TOP_STATE | ||
| 1478 | static int yy_top_state() | ||
| 1479 | { | ||
| 1480 | return yy_start_stack[yy_start_stack_ptr - 1]; | ||
| 1481 | } | ||
| 1482 | #endif | ||
| 1483 | |||
| 1484 | #ifndef YY_EXIT_FAILURE | ||
| 1485 | #define YY_EXIT_FAILURE 2 | ||
| 1486 | #endif | ||
| 1487 | |||
| 1488 | #ifdef YY_USE_PROTOS | ||
| 1489 | static void yy_fatal_error( yyconst char msg[] ) | ||
| 1490 | #else | ||
| 1491 | static void yy_fatal_error( msg ) | ||
| 1492 | char msg[]; | ||
| 1493 | #endif | ||
| 1494 | { | ||
| 1495 | (void) fprintf( stderr, "%s\n", msg ); | ||
| 1496 | exit( YY_EXIT_FAILURE ); | ||
| 1497 | } | ||
| 1498 | |||
| 1499 | |||
| 1500 | |||
| 1501 | /* Redefine yyless() so it works in section 3 code. */ | ||
| 1502 | |||
| 1503 | #undef yyless | ||
| 1504 | #define yyless(n) \ | ||
| 1505 | do \ | ||
| 1506 | { \ | ||
| 1507 | /* Undo effects of setting up yytext. */ \ | ||
| 1508 | yytext[yyleng] = yy_hold_char; \ | ||
| 1509 | yy_c_buf_p = yytext + n; \ | ||
| 1510 | yy_hold_char = *yy_c_buf_p; \ | ||
| 1511 | *yy_c_buf_p = '\0'; \ | ||
| 1512 | yyleng = n; \ | ||
| 1513 | } \ | ||
| 1514 | while ( 0 ) | ||
| 1515 | |||
| 1516 | |||
| 1517 | /* Internal utility routines. */ | ||
| 1518 | |||
| 1519 | #ifndef yytext_ptr | ||
| 1520 | #ifdef YY_USE_PROTOS | ||
| 1521 | static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) | ||
| 1522 | #else | ||
| 1523 | static void yy_flex_strncpy( s1, s2, n ) | ||
| 1524 | char *s1; | ||
| 1525 | yyconst char *s2; | ||
| 1526 | int n; | ||
| 1527 | #endif | ||
| 1528 | { | ||
| 1529 | register int i; | ||
| 1530 | for ( i = 0; i < n; ++i ) | ||
| 1531 | s1[i] = s2[i]; | ||
| 1532 | } | ||
| 1533 | #endif | ||
| 1534 | |||
| 1535 | #ifdef YY_NEED_STRLEN | ||
| 1536 | #ifdef YY_USE_PROTOS | ||
| 1537 | static int yy_flex_strlen( yyconst char *s ) | ||
| 1538 | #else | ||
| 1539 | static int yy_flex_strlen( s ) | ||
| 1540 | yyconst char *s; | ||
| 1541 | #endif | ||
| 1542 | { | ||
| 1543 | register int n; | ||
| 1544 | for ( n = 0; s[n]; ++n ) | ||
| 1545 | ; | ||
| 1546 | |||
| 1547 | return n; | ||
| 1548 | } | ||
| 1549 | #endif | ||
| 1550 | |||
| 1551 | |||
| 1552 | #ifdef YY_USE_PROTOS | ||
| 1553 | static void *yy_flex_alloc( yy_size_t size ) | ||
| 1554 | #else | ||
| 1555 | static void *yy_flex_alloc( size ) | ||
| 1556 | yy_size_t size; | ||
| 1557 | #endif | ||
| 1558 | { | ||
| 1559 | return (void *) malloc( size ); | ||
| 1560 | } | ||
| 1561 | |||
| 1562 | #ifdef YY_USE_PROTOS | ||
| 1563 | static void *yy_flex_realloc( void *ptr, yy_size_t size ) | ||
| 1564 | #else | ||
| 1565 | static void *yy_flex_realloc( ptr, size ) | ||
| 1566 | void *ptr; | ||
| 1567 | yy_size_t size; | ||
| 1568 | #endif | ||
| 1569 | { | ||
| 1570 | /* The cast to (char *) in the following accommodates both | ||
| 1571 | * implementations that use char* generic pointers, and those | ||
| 1572 | * that use void* generic pointers. It works with the latter | ||
| 1573 | * because both ANSI C and C++ allow castless assignment from | ||
| 1574 | * any pointer type to void*, and deal with argument conversions | ||
| 1575 | * as though doing an assignment. | ||
| 1576 | */ | ||
| 1577 | return (void *) realloc( (char *) ptr, size ); | ||
| 1578 | } | ||
| 1579 | |||
| 1580 | #ifdef YY_USE_PROTOS | ||
| 1581 | static void yy_flex_free( void *ptr ) | ||
| 1582 | #else | ||
| 1583 | static void yy_flex_free( ptr ) | ||
| 1584 | void *ptr; | ||
| 1585 | #endif | ||
| 1586 | { | ||
| 1587 | free( ptr ); | ||
| 1588 | } | ||
| 1589 | |||
| 1590 | #if YY_MAIN | ||
| 1591 | int main() | ||
| 1592 | { | ||
| 1593 | yylex(); | ||
| 1594 | return 0; | ||
| 1595 | } | ||
| 1596 | #endif | ||
| 1597 | #line 62 "input.l" | ||
diff --git a/other/gramble/lex.yy.o b/other/gramble/lex.yy.o new file mode 100644 index 0000000..74af246 --- /dev/null +++ b/other/gramble/lex.yy.o | |||
| Binary files differ | |||
diff --git a/other/gramble/producer.c b/other/gramble/producer.c new file mode 100644 index 0000000..55346b8 --- /dev/null +++ b/other/gramble/producer.c | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | /* gramble - grammar ramble | ||
| 2 | * production engine for grammar derivations | ||
| 3 | * | ||
| 4 | * -scut | ||
| 5 | */ | ||
| 6 | |||
| 7 | |||
| 8 | /* we use a pushdown ntm like construct to generate valid derivations of the | ||
| 9 | * original grammar. | ||
| 10 | */ | ||
| 11 | |||
| 12 | |||
| 13 | /* terminal structure | ||
| 14 | * | ||
| 15 | * a simple word consisting of characters | ||
| 16 | */ | ||
| 17 | typedef struct { | ||
| 18 | unsigned int word_len; /* length, not including NUL */ | ||
| 19 | unsigned char * word; /* if word_Len > 0: must be non-NULL */ | ||
| 20 | } terminal; | ||
| 21 | |||
| 22 | |||
| 23 | /* nonterminal structure | ||
| 24 | * | ||
| 25 | * contains 'plist', a pointer to a production list of that nonterminal | ||
| 26 | */ | ||
| 27 | typedef struct { | ||
| 28 | unsigned int pcount; /* number of productions for that nterm */ | ||
| 29 | symbol ** plist; /* list of productions for that nonterminal */ | ||
| 30 | } nonterminal; | ||
| 31 | |||
| 32 | |||
| 33 | /* symbol structure | ||
| 34 | * | ||
| 35 | * shared linked list of symbols consisting of terminals and nonterminals. | ||
| 36 | * `next' being NULL marks the end of the derivation. `prev' being NULL marks | ||
| 37 | * the first. | ||
| 38 | * exactly one of `term' or `nterm' has to be non-NULL and point to a valid | ||
| 39 | * structure. | ||
| 40 | */ | ||
| 41 | typedef struct symbol { | ||
| 42 | symbol * prev; | ||
| 43 | symbol * next; | ||
| 44 | terminal * term; | ||
| 45 | nonterminal * nterm; | ||
| 46 | } symbol; | ||
| 47 | |||
| 48 | |||
| 49 | /* prod_genstatement | ||
| 50 | * | ||
| 51 | * derive a nonterminal completely to nonterminals. stop when the output | ||
| 52 | * buffer `obuf' has been filled with `obuf_len' bytes or when there are | ||
| 53 | * no more nonterminals to derive. start to derive from nonterminal `step'. | ||
| 54 | * | ||
| 55 | * return number of terminal characters derived on success | ||
| 56 | * return -1 on failure | ||
| 57 | */ | ||
| 58 | |||
| 59 | unsigned int | ||
| 60 | prod_genstatement (nonterminal *step, | ||
| 61 | unsigned char *obuf, unsigned long int obuf_len) | ||
| 62 | { | ||
| 63 | unsigned int produced = 0, | ||
| 64 | sub_produced = 0; | ||
| 65 | unsigned int psel; /* production selector */ | ||
| 66 | symbol * prod; /* production to use */ | ||
| 67 | |||
| 68 | |||
| 69 | if (obuf_len == 0) | ||
| 70 | return (0); | ||
| 71 | |||
| 72 | /* TODO: choose a more custom selection over a random pick | ||
| 73 | */ | ||
| 74 | psel = random_get (0, step->pcount - 1); | ||
| 75 | |||
| 76 | for (prod = start->plist[psel] ; prod != NULL ; prod = prod->next) { | ||
| 77 | |||
| 78 | /* terminals */ | ||
| 79 | if (prod->term != NULL) { | ||
| 80 | if (prod->term->word_len < obuf_len) { | ||
| 81 | memcpy (obuf, prod->term->word, | ||
| 82 | prod->term->word_len); | ||
| 83 | obuf += prod->term->word_len; | ||
| 84 | obuf_len -= prod->term->word_len; | ||
| 85 | produced += prod->term->word_len; | ||
| 86 | } else /* no room left :-( */ | ||
| 87 | return (produced); | ||
| 88 | |||
| 89 | /* non-terminals */ | ||
| 90 | } else if (prod->nterm != NULL) { | ||
| 91 | |||
| 92 | sub_produced = prod_genstatement (prod->nterm, | ||
| 93 | obuf, obuf_len); | ||
| 94 | obuf += sub_produced; | ||
| 95 | obuf_len -= sub_produced; | ||
| 96 | } | ||
| 97 | } | ||
| 98 | |||
| 99 | /* finished deriving */ | ||
| 100 | return (produced); | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
diff --git a/other/gramble/test b/other/gramble/test new file mode 100644 index 0000000..5cccc7b --- /dev/null +++ b/other/gramble/test | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | |||
| 2 | pname: "foo" cow | ||
| 3 | cow: ["moo" cow](filter:/baz/) | ||
| 4 | cow: "baz" | ||
| 5 | |||
diff --git a/other/gramble/y.output b/other/gramble/y.output new file mode 100644 index 0000000..2faa6a0 --- /dev/null +++ b/other/gramble/y.output | |||
| @@ -0,0 +1,347 @@ | |||
| 1 | Terminals which are not used | ||
| 2 | |||
| 3 | STR | ||
| 4 | |||
| 5 | |||
| 6 | State 10 conflicts: 1 shift/reduce | ||
| 7 | |||
| 8 | |||
| 9 | Grammar | ||
| 10 | |||
| 11 | 0 $accept: prodlist $end | ||
| 12 | |||
| 13 | 1 prodlist: prodlist prod | ||
| 14 | 2 | prod | ||
| 15 | |||
| 16 | 3 prod: NTERM ':' prodr | ||
| 17 | |||
| 18 | 4 prodr: prodr prodrelem | ||
| 19 | 5 | prodrelem | ||
| 20 | |||
| 21 | 6 prodrelem: '[' prodr ']' poptl | ||
| 22 | 7 | NTERM | ||
| 23 | 8 | TERM | ||
| 24 | |||
| 25 | 9 poptl: poptl '(' popt ')' | ||
| 26 | 10 | /* empty */ | ||
| 27 | |||
| 28 | 11 popt: FILTER ':' '/' NSSTR '/' | ||
| 29 | 12 | NEGFILTER ':' '/' NSSTR '/' | ||
| 30 | 13 | SIZE ':' NUM '-' NUM | ||
| 31 | |||
| 32 | |||
| 33 | Terminals, with rules where they appear | ||
| 34 | |||
| 35 | $end (0) 0 | ||
| 36 | '(' (40) 9 | ||
| 37 | ')' (41) 9 | ||
| 38 | '-' (45) 13 | ||
| 39 | '/' (47) 11 12 | ||
| 40 | ':' (58) 3 11 12 13 | ||
| 41 | '[' (91) 6 | ||
| 42 | ']' (93) 6 | ||
| 43 | error (256) | ||
| 44 | STR (258) | ||
| 45 | NSSTR (259) 11 12 | ||
| 46 | NTERM (260) 3 7 | ||
| 47 | TERM (261) 8 | ||
| 48 | FILTER (262) 11 | ||
| 49 | NEGFILTER (263) 12 | ||
| 50 | SIZE (264) 13 | ||
| 51 | NUM (265) 13 | ||
| 52 | |||
| 53 | |||
| 54 | Nonterminals, with rules where they appear | ||
| 55 | |||
| 56 | $accept (18) | ||
| 57 | on left: 0 | ||
| 58 | prodlist (19) | ||
| 59 | on left: 1 2, on right: 0 1 | ||
| 60 | prod (20) | ||
| 61 | on left: 3, on right: 1 2 | ||
| 62 | prodr (21) | ||
| 63 | on left: 4 5, on right: 3 4 6 | ||
| 64 | prodrelem (22) | ||
| 65 | on left: 6 7 8, on right: 4 5 | ||
| 66 | poptl (23) | ||
| 67 | on left: 9 10, on right: 6 9 | ||
| 68 | popt (24) | ||
| 69 | on left: 11 12 13, on right: 9 | ||
| 70 | |||
| 71 | |||
| 72 | state 0 | ||
| 73 | |||
| 74 | 0 $accept: . prodlist $end | ||
| 75 | |||
| 76 | NTERM shift, and go to state 1 | ||
| 77 | |||
| 78 | prodlist go to state 2 | ||
| 79 | prod go to state 3 | ||
| 80 | |||
| 81 | |||
| 82 | state 1 | ||
| 83 | |||
| 84 | 3 prod: NTERM . ':' prodr | ||
| 85 | |||
| 86 | ':' shift, and go to state 4 | ||
| 87 | |||
| 88 | |||
| 89 | state 2 | ||
| 90 | |||
| 91 | 0 $accept: prodlist . $end | ||
| 92 | 1 prodlist: prodlist . prod | ||
| 93 | |||
| 94 | $end shift, and go to state 5 | ||
| 95 | NTERM shift, and go to state 1 | ||
| 96 | |||
| 97 | prod go to state 6 | ||
| 98 | |||
| 99 | |||
| 100 | state 3 | ||
| 101 | |||
| 102 | 2 prodlist: prod . | ||
| 103 | |||
| 104 | $default reduce using rule 2 (prodlist) | ||
| 105 | |||
| 106 | |||
| 107 | state 4 | ||
| 108 | |||
| 109 | 3 prod: NTERM ':' . prodr | ||
| 110 | |||
| 111 | NTERM shift, and go to state 7 | ||
| 112 | TERM shift, and go to state 8 | ||
| 113 | '[' shift, and go to state 9 | ||
| 114 | |||
| 115 | prodr go to state 10 | ||
| 116 | prodrelem go to state 11 | ||
| 117 | |||
| 118 | |||
| 119 | state 5 | ||
| 120 | |||
| 121 | 0 $accept: prodlist $end . | ||
| 122 | |||
| 123 | $default accept | ||
| 124 | |||
| 125 | |||
| 126 | state 6 | ||
| 127 | |||
| 128 | 1 prodlist: prodlist prod . | ||
| 129 | |||
| 130 | $default reduce using rule 1 (prodlist) | ||
| 131 | |||
| 132 | |||
| 133 | state 7 | ||
| 134 | |||
| 135 | 7 prodrelem: NTERM . | ||
| 136 | |||
| 137 | $default reduce using rule 7 (prodrelem) | ||
| 138 | |||
| 139 | |||
| 140 | state 8 | ||
| 141 | |||
| 142 | 8 prodrelem: TERM . | ||
| 143 | |||
| 144 | $default reduce using rule 8 (prodrelem) | ||
| 145 | |||
| 146 | |||
| 147 | state 9 | ||
| 148 | |||
| 149 | 6 prodrelem: '[' . prodr ']' poptl | ||
| 150 | |||
| 151 | NTERM shift, and go to state 7 | ||
| 152 | TERM shift, and go to state 8 | ||
| 153 | '[' shift, and go to state 9 | ||
| 154 | |||
| 155 | prodr go to state 12 | ||
| 156 | prodrelem go to state 11 | ||
| 157 | |||
| 158 | |||
| 159 | state 10 | ||
| 160 | |||
| 161 | 3 prod: NTERM ':' prodr . | ||
| 162 | 4 prodr: prodr . prodrelem | ||
| 163 | |||
| 164 | NTERM shift, and go to state 7 | ||
| 165 | TERM shift, and go to state 8 | ||
| 166 | '[' shift, and go to state 9 | ||
| 167 | |||
| 168 | NTERM [reduce using rule 3 (prod)] | ||
| 169 | $default reduce using rule 3 (prod) | ||
| 170 | |||
| 171 | prodrelem go to state 13 | ||
| 172 | |||
| 173 | |||
| 174 | state 11 | ||
| 175 | |||
| 176 | 5 prodr: prodrelem . | ||
| 177 | |||
| 178 | $default reduce using rule 5 (prodr) | ||
| 179 | |||
| 180 | |||
| 181 | state 12 | ||
| 182 | |||
| 183 | 4 prodr: prodr . prodrelem | ||
| 184 | 6 prodrelem: '[' prodr . ']' poptl | ||
| 185 | |||
| 186 | NTERM shift, and go to state 7 | ||
| 187 | TERM shift, and go to state 8 | ||
| 188 | '[' shift, and go to state 9 | ||
| 189 | ']' shift, and go to state 14 | ||
| 190 | |||
| 191 | prodrelem go to state 13 | ||
| 192 | |||
| 193 | |||
| 194 | state 13 | ||
| 195 | |||
| 196 | 4 prodr: prodr prodrelem . | ||
| 197 | |||
| 198 | $default reduce using rule 4 (prodr) | ||
| 199 | |||
| 200 | |||
| 201 | state 14 | ||
| 202 | |||
| 203 | 6 prodrelem: '[' prodr ']' . poptl | ||
| 204 | |||
| 205 | $default reduce using rule 10 (poptl) | ||
| 206 | |||
| 207 | poptl go to state 15 | ||
| 208 | |||
| 209 | |||
| 210 | state 15 | ||
| 211 | |||
| 212 | 6 prodrelem: '[' prodr ']' poptl . | ||
| 213 | 9 poptl: poptl . '(' popt ')' | ||
| 214 | |||
| 215 | '(' shift, and go to state 16 | ||
| 216 | |||
| 217 | $default reduce using rule 6 (prodrelem) | ||
| 218 | |||
| 219 | |||
| 220 | state 16 | ||
| 221 | |||
| 222 | 9 poptl: poptl '(' . popt ')' | ||
| 223 | |||
| 224 | FILTER shift, and go to state 17 | ||
| 225 | NEGFILTER shift, and go to state 18 | ||
| 226 | SIZE shift, and go to state 19 | ||
| 227 | |||
| 228 | popt go to state 20 | ||
| 229 | |||
| 230 | |||
| 231 | state 17 | ||
| 232 | |||
| 233 | 11 popt: FILTER . ':' '/' NSSTR '/' | ||
| 234 | |||
| 235 | ':' shift, and go to state 21 | ||
| 236 | |||
| 237 | |||
| 238 | state 18 | ||
| 239 | |||
| 240 | 12 popt: NEGFILTER . ':' '/' NSSTR '/' | ||
| 241 | |||
| 242 | ':' shift, and go to state 22 | ||
| 243 | |||
| 244 | |||
| 245 | state 19 | ||
| 246 | |||
| 247 | 13 popt: SIZE . ':' NUM '-' NUM | ||
| 248 | |||
| 249 | ':' shift, and go to state 23 | ||
| 250 | |||
| 251 | |||
| 252 | state 20 | ||
| 253 | |||
| 254 | 9 poptl: poptl '(' popt . ')' | ||
| 255 | |||
| 256 | ')' shift, and go to state 24 | ||
| 257 | |||
| 258 | |||
| 259 | state 21 | ||
| 260 | |||
| 261 | 11 popt: FILTER ':' . '/' NSSTR '/' | ||
| 262 | |||
| 263 | '/' shift, and go to state 25 | ||
| 264 | |||
| 265 | |||
| 266 | state 22 | ||
| 267 | |||
| 268 | 12 popt: NEGFILTER ':' . '/' NSSTR '/' | ||
| 269 | |||
| 270 | '/' shift, and go to state 26 | ||
| 271 | |||
| 272 | |||
| 273 | state 23 | ||
| 274 | |||
| 275 | 13 popt: SIZE ':' . NUM '-' NUM | ||
| 276 | |||
| 277 | NUM shift, and go to state 27 | ||
| 278 | |||
| 279 | |||
| 280 | state 24 | ||
| 281 | |||
| 282 | 9 poptl: poptl '(' popt ')' . | ||
| 283 | |||
| 284 | $default reduce using rule 9 (poptl) | ||
| 285 | |||
| 286 | |||
| 287 | state 25 | ||
| 288 | |||
| 289 | 11 popt: FILTER ':' '/' . NSSTR '/' | ||
| 290 | |||
| 291 | NSSTR shift, and go to state 28 | ||
| 292 | |||
| 293 | |||
| 294 | state 26 | ||
| 295 | |||
| 296 | 12 popt: NEGFILTER ':' '/' . NSSTR '/' | ||
| 297 | |||
| 298 | NSSTR shift, and go to state 29 | ||
| 299 | |||
| 300 | |||
| 301 | state 27 | ||
| 302 | |||
| 303 | 13 popt: SIZE ':' NUM . '-' NUM | ||
| 304 | |||
| 305 | '-' shift, and go to state 30 | ||
| 306 | |||
| 307 | |||
| 308 | state 28 | ||
| 309 | |||
| 310 | 11 popt: FILTER ':' '/' NSSTR . '/' | ||
| 311 | |||
| 312 | '/' shift, and go to state 31 | ||
| 313 | |||
| 314 | |||
| 315 | state 29 | ||
| 316 | |||
| 317 | 12 popt: NEGFILTER ':' '/' NSSTR . '/' | ||
| 318 | |||
| 319 | '/' shift, and go to state 32 | ||
| 320 | |||
| 321 | |||
| 322 | state 30 | ||
| 323 | |||
| 324 | 13 popt: SIZE ':' NUM '-' . NUM | ||
| 325 | |||
| 326 | NUM shift, and go to state 33 | ||
| 327 | |||
| 328 | |||
| 329 | state 31 | ||
| 330 | |||
| 331 | 11 popt: FILTER ':' '/' NSSTR '/' . | ||
| 332 | |||
| 333 | $default reduce using rule 11 (popt) | ||
| 334 | |||
| 335 | |||
| 336 | state 32 | ||
| 337 | |||
| 338 | 12 popt: NEGFILTER ':' '/' NSSTR '/' . | ||
| 339 | |||
| 340 | $default reduce using rule 12 (popt) | ||
| 341 | |||
| 342 | |||
| 343 | state 33 | ||
| 344 | |||
| 345 | 13 popt: SIZE ':' NUM '-' NUM . | ||
| 346 | |||
| 347 | $default reduce using rule 13 (popt) | ||
diff --git a/other/gramble/y.tab.c b/other/gramble/y.tab.c new file mode 100644 index 0000000..1f5f4d0 --- /dev/null +++ b/other/gramble/y.tab.c | |||
| @@ -0,0 +1,1303 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 1.875a. */ | ||
| 2 | |||
| 3 | /* Skeleton parser for Yacc-like parsing with Bison, | ||
| 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 19 | Boston, MA 02111-1307, USA. */ | ||
| 20 | |||
| 21 | /* As a special exception, when this file is copied by Bison into a | ||
| 22 | Bison output file, you may use that output file without restriction. | ||
| 23 | This special exception was added by the Free Software Foundation | ||
| 24 | in version 1.24 of Bison. */ | ||
| 25 | |||
| 26 | /* Written by Richard Stallman by simplifying the original so called | ||
| 27 | ``semantic'' parser. */ | ||
| 28 | |||
| 29 | /* All symbols defined below should begin with yy or YY, to avoid | ||
| 30 | infringing on user name space. This should be done even for local | ||
| 31 | variables, as they might otherwise be expanded by user macros. | ||
| 32 | There are some unavoidable exceptions within include files to | ||
| 33 | define necessary library symbols; they are noted "INFRINGES ON | ||
| 34 | USER NAME SPACE" below. */ | ||
| 35 | |||
| 36 | /* Identify Bison output. */ | ||
| 37 | #define YYBISON 1 | ||
| 38 | |||
| 39 | /* Skeleton name. */ | ||
| 40 | #define YYSKELETON_NAME "yacc.c" | ||
| 41 | |||
| 42 | /* Pure parsers. */ | ||
| 43 | #define YYPURE 0 | ||
| 44 | |||
| 45 | /* Using locations. */ | ||
| 46 | #define YYLSP_NEEDED 0 | ||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | /* Tokens. */ | ||
| 51 | #ifndef YYTOKENTYPE | ||
| 52 | # define YYTOKENTYPE | ||
| 53 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
| 54 | know about them. */ | ||
| 55 | enum yytokentype { | ||
| 56 | STR = 258, | ||
| 57 | NSSTR = 259, | ||
| 58 | NTERM = 260, | ||
| 59 | TERM = 261, | ||
| 60 | FILTER = 262, | ||
| 61 | NEGFILTER = 263, | ||
| 62 | SIZE = 264, | ||
| 63 | NUM = 265 | ||
| 64 | }; | ||
| 65 | #endif | ||
| 66 | #define STR 258 | ||
| 67 | #define NSSTR 259 | ||
| 68 | #define NTERM 260 | ||
| 69 | #define TERM 261 | ||
| 70 | #define FILTER 262 | ||
| 71 | #define NEGFILTER 263 | ||
| 72 | #define SIZE 264 | ||
| 73 | #define NUM 265 | ||
| 74 | |||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | /* Copy the first part of user declarations. */ | ||
| 79 | #line 8 "input.y" | ||
| 80 | |||
| 81 | #include <stdio.h> | ||
| 82 | #include <stdlib.h> | ||
| 83 | #include "input.h" | ||
| 84 | |||
| 85 | extern void * in_grammar; | ||
| 86 | |||
| 87 | |||
| 88 | |||
| 89 | /* Enabling traces. */ | ||
| 90 | #ifndef YYDEBUG | ||
| 91 | # define YYDEBUG 1 | ||
| 92 | #endif | ||
| 93 | |||
| 94 | /* Enabling verbose error messages. */ | ||
| 95 | #ifdef YYERROR_VERBOSE | ||
| 96 | # undef YYERROR_VERBOSE | ||
| 97 | # define YYERROR_VERBOSE 1 | ||
| 98 | #else | ||
| 99 | # define YYERROR_VERBOSE 0 | ||
| 100 | #endif | ||
| 101 | |||
| 102 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) | ||
| 103 | #line 18 "input.y" | ||
| 104 | typedef union YYSTYPE { | ||
| 105 | unsigned int uint; /* unsigned number (length) */ | ||
| 106 | unsigned char * str; /* generic ASCIIZ string pointer */ | ||
| 107 | void * ugly; | ||
| 108 | } YYSTYPE; | ||
| 109 | /* Line 191 of yacc.c. */ | ||
| 110 | #line 111 "y.tab.c" | ||
| 111 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | ||
| 112 | # define YYSTYPE_IS_DECLARED 1 | ||
| 113 | # define YYSTYPE_IS_TRIVIAL 1 | ||
| 114 | #endif | ||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | /* Copy the second part of user declarations. */ | ||
| 119 | |||
| 120 | |||
| 121 | /* Line 214 of yacc.c. */ | ||
| 122 | #line 123 "y.tab.c" | ||
| 123 | |||
| 124 | #if ! defined (yyoverflow) || YYERROR_VERBOSE | ||
| 125 | |||
| 126 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | ||
| 127 | |||
| 128 | # if YYSTACK_USE_ALLOCA | ||
| 129 | # define YYSTACK_ALLOC alloca | ||
| 130 | # else | ||
| 131 | # ifndef YYSTACK_USE_ALLOCA | ||
| 132 | # if defined (alloca) || defined (_ALLOCA_H) | ||
| 133 | # define YYSTACK_ALLOC alloca | ||
| 134 | # else | ||
| 135 | # ifdef __GNUC__ | ||
| 136 | # define YYSTACK_ALLOC __builtin_alloca | ||
| 137 | # endif | ||
| 138 | # endif | ||
| 139 | # endif | ||
| 140 | # endif | ||
| 141 | |||
| 142 | # ifdef YYSTACK_ALLOC | ||
| 143 | /* Pacify GCC's `empty if-body' warning. */ | ||
| 144 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) | ||
| 145 | # else | ||
| 146 | # if defined (__STDC__) || defined (__cplusplus) | ||
| 147 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 148 | # define YYSIZE_T size_t | ||
| 149 | # endif | ||
| 150 | # define YYSTACK_ALLOC malloc | ||
| 151 | # define YYSTACK_FREE free | ||
| 152 | # endif | ||
| 153 | #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ | ||
| 154 | |||
| 155 | |||
| 156 | #if (! defined (yyoverflow) \ | ||
| 157 | && (! defined (__cplusplus) \ | ||
| 158 | || (YYSTYPE_IS_TRIVIAL))) | ||
| 159 | |||
| 160 | /* A type that is properly aligned for any stack member. */ | ||
| 161 | union yyalloc | ||
| 162 | { | ||
| 163 | short yyss; | ||
| 164 | YYSTYPE yyvs; | ||
| 165 | }; | ||
| 166 | |||
| 167 | /* The size of the maximum gap between one aligned stack and the next. */ | ||
| 168 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | ||
| 169 | |||
| 170 | /* The size of an array large to enough to hold all stacks, each with | ||
| 171 | N elements. */ | ||
| 172 | # define YYSTACK_BYTES(N) \ | ||
| 173 | ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ | ||
| 174 | + YYSTACK_GAP_MAXIMUM) | ||
| 175 | |||
| 176 | /* Copy COUNT objects from FROM to TO. The source and destination do | ||
| 177 | not overlap. */ | ||
| 178 | # ifndef YYCOPY | ||
| 179 | # if 1 < __GNUC__ | ||
| 180 | # define YYCOPY(To, From, Count) \ | ||
| 181 | __builtin_memcpy (To, From, (Count) * sizeof (*(From))) | ||
| 182 | # else | ||
| 183 | # define YYCOPY(To, From, Count) \ | ||
| 184 | do \ | ||
| 185 | { \ | ||
| 186 | register YYSIZE_T yyi; \ | ||
| 187 | for (yyi = 0; yyi < (Count); yyi++) \ | ||
| 188 | (To)[yyi] = (From)[yyi]; \ | ||
| 189 | } \ | ||
| 190 | while (0) | ||
| 191 | # endif | ||
| 192 | # endif | ||
| 193 | |||
| 194 | /* Relocate STACK from its old location to the new one. The | ||
| 195 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | ||
| 196 | elements in the stack, and YYPTR gives the new location of the | ||
| 197 | stack. Advance YYPTR to a properly aligned location for the next | ||
| 198 | stack. */ | ||
| 199 | # define YYSTACK_RELOCATE(Stack) \ | ||
| 200 | do \ | ||
| 201 | { \ | ||
| 202 | YYSIZE_T yynewbytes; \ | ||
| 203 | YYCOPY (&yyptr->Stack, Stack, yysize); \ | ||
| 204 | Stack = &yyptr->Stack; \ | ||
| 205 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | ||
| 206 | yyptr += yynewbytes / sizeof (*yyptr); \ | ||
| 207 | } \ | ||
| 208 | while (0) | ||
| 209 | |||
| 210 | #endif | ||
| 211 | |||
| 212 | #if defined (__STDC__) || defined (__cplusplus) | ||
| 213 | typedef signed char yysigned_char; | ||
| 214 | #else | ||
| 215 | typedef short yysigned_char; | ||
| 216 | #endif | ||
| 217 | |||
| 218 | /* YYFINAL -- State number of the termination state. */ | ||
| 219 | #define YYFINAL 5 | ||
| 220 | /* YYLAST -- Last index in YYTABLE. */ | ||
| 221 | #define YYLAST 35 | ||
| 222 | |||
| 223 | /* YYNTOKENS -- Number of terminals. */ | ||
| 224 | #define YYNTOKENS 18 | ||
| 225 | /* YYNNTS -- Number of nonterminals. */ | ||
| 226 | #define YYNNTS 7 | ||
| 227 | /* YYNRULES -- Number of rules. */ | ||
| 228 | #define YYNRULES 14 | ||
| 229 | /* YYNRULES -- Number of states. */ | ||
| 230 | #define YYNSTATES 34 | ||
| 231 | |||
| 232 | /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ | ||
| 233 | #define YYUNDEFTOK 2 | ||
| 234 | #define YYMAXUTOK 265 | ||
| 235 | |||
| 236 | #define YYTRANSLATE(YYX) \ | ||
| 237 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | ||
| 238 | |||
| 239 | /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ | ||
| 240 | static const unsigned char yytranslate[] = | ||
| 241 | { | ||
| 242 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 243 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 244 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 245 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 246 | 14, 15, 2, 2, 2, 17, 2, 16, 2, 2, | ||
| 247 | 2, 2, 2, 2, 2, 2, 2, 2, 11, 2, | ||
| 248 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 249 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 250 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 251 | 2, 12, 2, 13, 2, 2, 2, 2, 2, 2, | ||
| 252 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 253 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 254 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 255 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 256 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 257 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 258 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 259 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 260 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 261 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 262 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 263 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 264 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 265 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 266 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | ||
| 267 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | ||
| 268 | 5, 6, 7, 8, 9, 10 | ||
| 269 | }; | ||
| 270 | |||
| 271 | #if YYDEBUG | ||
| 272 | /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in | ||
| 273 | YYRHS. */ | ||
| 274 | static const unsigned char yyprhs[] = | ||
| 275 | { | ||
| 276 | 0, 0, 3, 6, 8, 12, 15, 17, 22, 24, | ||
| 277 | 26, 31, 32, 38, 44 | ||
| 278 | }; | ||
| 279 | |||
| 280 | /* YYRHS -- A `-1'-separated list of the rules' RHS. */ | ||
| 281 | static const yysigned_char yyrhs[] = | ||
| 282 | { | ||
| 283 | 19, 0, -1, 19, 20, -1, 20, -1, 5, 11, | ||
| 284 | 21, -1, 21, 22, -1, 22, -1, 12, 21, 13, | ||
| 285 | 23, -1, 5, -1, 6, -1, 23, 14, 24, 15, | ||
| 286 | -1, -1, 7, 11, 16, 4, 16, -1, 8, 11, | ||
| 287 | 16, 4, 16, -1, 9, 11, 10, 17, 10, -1 | ||
| 288 | }; | ||
| 289 | |||
| 290 | /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ | ||
| 291 | static const unsigned char yyrline[] = | ||
| 292 | { | ||
| 293 | 0, 36, 36, 40, 46, 53, 57, 64, 68, 72, | ||
| 294 | 79, 84, 89, 94, 98 | ||
| 295 | }; | ||
| 296 | #endif | ||
| 297 | |||
| 298 | #if YYDEBUG || YYERROR_VERBOSE | ||
| 299 | /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | ||
| 300 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | ||
| 301 | static const char *const yytname[] = | ||
| 302 | { | ||
| 303 | "$end", "error", "$undefined", "STR", "NSSTR", "NTERM", "TERM", "FILTER", | ||
| 304 | "NEGFILTER", "SIZE", "NUM", "':'", "'['", "']'", "'('", "')'", "'/'", | ||
| 305 | "'-'", "$accept", "prodlist", "prod", "prodr", "prodrelem", "poptl", | ||
| 306 | "popt", 0 | ||
| 307 | }; | ||
| 308 | #endif | ||
| 309 | |||
| 310 | # ifdef YYPRINT | ||
| 311 | /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to | ||
| 312 | token YYLEX-NUM. */ | ||
| 313 | static const unsigned short yytoknum[] = | ||
| 314 | { | ||
| 315 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | ||
| 316 | 265, 58, 91, 93, 40, 41, 47, 45 | ||
| 317 | }; | ||
| 318 | # endif | ||
| 319 | |||
| 320 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | ||
| 321 | static const unsigned char yyr1[] = | ||
| 322 | { | ||
| 323 | 0, 18, 19, 19, 20, 21, 21, 22, 22, 22, | ||
| 324 | 23, 23, 24, 24, 24 | ||
| 325 | }; | ||
| 326 | |||
| 327 | /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ | ||
| 328 | static const unsigned char yyr2[] = | ||
| 329 | { | ||
| 330 | 0, 2, 2, 1, 3, 2, 1, 4, 1, 1, | ||
| 331 | 4, 0, 5, 5, 5 | ||
| 332 | }; | ||
| 333 | |||
| 334 | /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state | ||
| 335 | STATE-NUM when YYTABLE doesn't specify something else to do. Zero | ||
| 336 | means the default is an error. */ | ||
| 337 | static const unsigned char yydefact[] = | ||
| 338 | { | ||
| 339 | 0, 0, 0, 3, 0, 1, 2, 8, 9, 0, | ||
| 340 | 4, 6, 0, 5, 11, 7, 0, 0, 0, 0, | ||
| 341 | 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, | ||
| 342 | 0, 12, 13, 14 | ||
| 343 | }; | ||
| 344 | |||
| 345 | /* YYDEFGOTO[NTERM-NUM]. */ | ||
| 346 | static const yysigned_char yydefgoto[] = | ||
| 347 | { | ||
| 348 | -1, 2, 3, 10, 11, 15, 20 | ||
| 349 | }; | ||
| 350 | |||
| 351 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | ||
| 352 | STATE-NUM. */ | ||
| 353 | #define YYPACT_NINF -7 | ||
| 354 | static const yysigned_char yypact[] = | ||
| 355 | { | ||
| 356 | 9, 6, 5, -7, -3, -7, -7, -7, -7, -3, | ||
| 357 | -3, -7, -5, -7, -7, 1, 4, 7, 8, 10, | ||
| 358 | 11, 0, 12, 13, -7, 16, 18, 14, 17, 19, | ||
| 359 | 15, -7, -7, -7 | ||
| 360 | }; | ||
| 361 | |||
| 362 | /* YYPGOTO[NTERM-NUM]. */ | ||
| 363 | static const yysigned_char yypgoto[] = | ||
| 364 | { | ||
| 365 | -7, -7, 22, 20, -6, -7, -7 | ||
| 366 | }; | ||
| 367 | |||
| 368 | /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If | ||
| 369 | positive, shift that token. If negative, reduce the rule which | ||
| 370 | number is the opposite. If zero, do what YYDEFACT says. | ||
| 371 | If YYTABLE_NINF, syntax error. */ | ||
| 372 | #define YYTABLE_NINF -1 | ||
| 373 | static const unsigned char yytable[] = | ||
| 374 | { | ||
| 375 | 7, 8, 7, 8, 13, 5, 13, 9, 14, 9, | ||
| 376 | 1, 17, 18, 19, 1, 16, 25, 4, 21, 22, | ||
| 377 | 28, 23, 29, 27, 6, 33, 24, 0, 26, 12, | ||
| 378 | 0, 30, 0, 31, 0, 32 | ||
| 379 | }; | ||
| 380 | |||
| 381 | static const yysigned_char yycheck[] = | ||
| 382 | { | ||
| 383 | 5, 6, 5, 6, 10, 0, 12, 12, 13, 12, | ||
| 384 | 5, 7, 8, 9, 5, 14, 16, 11, 11, 11, | ||
| 385 | 4, 11, 4, 10, 2, 10, 15, -1, 16, 9, | ||
| 386 | -1, 17, -1, 16, -1, 16 | ||
| 387 | }; | ||
| 388 | |||
| 389 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | ||
| 390 | symbol of state STATE-NUM. */ | ||
| 391 | static const unsigned char yystos[] = | ||
| 392 | { | ||
| 393 | 0, 5, 19, 20, 11, 0, 20, 5, 6, 12, | ||
| 394 | 21, 22, 21, 22, 13, 23, 14, 7, 8, 9, | ||
| 395 | 24, 11, 11, 11, 15, 16, 16, 10, 4, 4, | ||
| 396 | 17, 16, 16, 10 | ||
| 397 | }; | ||
| 398 | |||
| 399 | #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) | ||
| 400 | # define YYSIZE_T __SIZE_TYPE__ | ||
| 401 | #endif | ||
| 402 | #if ! defined (YYSIZE_T) && defined (size_t) | ||
| 403 | # define YYSIZE_T size_t | ||
| 404 | #endif | ||
| 405 | #if ! defined (YYSIZE_T) | ||
| 406 | # if defined (__STDC__) || defined (__cplusplus) | ||
| 407 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 408 | # define YYSIZE_T size_t | ||
| 409 | # endif | ||
| 410 | #endif | ||
| 411 | #if ! defined (YYSIZE_T) | ||
| 412 | # define YYSIZE_T unsigned int | ||
| 413 | #endif | ||
| 414 | |||
| 415 | #define yyerrok (yyerrstatus = 0) | ||
| 416 | #define yyclearin (yychar = YYEMPTY) | ||
| 417 | #define YYEMPTY (-2) | ||
| 418 | #define YYEOF 0 | ||
| 419 | |||
| 420 | #define YYACCEPT goto yyacceptlab | ||
| 421 | #define YYABORT goto yyabortlab | ||
| 422 | #define YYERROR goto yyerrlab1 | ||
| 423 | |||
| 424 | |||
| 425 | /* Like YYERROR except do call yyerror. This remains here temporarily | ||
| 426 | to ease the transition to the new meaning of YYERROR, for GCC. | ||
| 427 | Once GCC version 2 has supplanted version 1, this can go. */ | ||
| 428 | |||
| 429 | #define YYFAIL goto yyerrlab | ||
| 430 | |||
| 431 | #define YYRECOVERING() (!!yyerrstatus) | ||
| 432 | |||
| 433 | #define YYBACKUP(Token, Value) \ | ||
| 434 | do \ | ||
| 435 | if (yychar == YYEMPTY && yylen == 1) \ | ||
| 436 | { \ | ||
| 437 | yychar = (Token); \ | ||
| 438 | yylval = (Value); \ | ||
| 439 | yytoken = YYTRANSLATE (yychar); \ | ||
| 440 | YYPOPSTACK; \ | ||
| 441 | goto yybackup; \ | ||
| 442 | } \ | ||
| 443 | else \ | ||
| 444 | { \ | ||
| 445 | yyerror ("syntax error: cannot back up");\ | ||
| 446 | YYERROR; \ | ||
| 447 | } \ | ||
| 448 | while (0) | ||
| 449 | |||
| 450 | #define YYTERROR 1 | ||
| 451 | #define YYERRCODE 256 | ||
| 452 | |||
| 453 | /* YYLLOC_DEFAULT -- Compute the default location (before the actions | ||
| 454 | are run). */ | ||
| 455 | |||
| 456 | #ifndef YYLLOC_DEFAULT | ||
| 457 | # define YYLLOC_DEFAULT(Current, Rhs, N) \ | ||
| 458 | Current.first_line = Rhs[1].first_line; \ | ||
| 459 | Current.first_column = Rhs[1].first_column; \ | ||
| 460 | Current.last_line = Rhs[N].last_line; \ | ||
| 461 | Current.last_column = Rhs[N].last_column; | ||
| 462 | #endif | ||
| 463 | |||
| 464 | /* YYLEX -- calling `yylex' with the right arguments. */ | ||
| 465 | |||
| 466 | #ifdef YYLEX_PARAM | ||
| 467 | # define YYLEX yylex (YYLEX_PARAM) | ||
| 468 | #else | ||
| 469 | # define YYLEX yylex () | ||
| 470 | #endif | ||
| 471 | |||
| 472 | /* Enable debugging if requested. */ | ||
| 473 | #if YYDEBUG | ||
| 474 | |||
| 475 | # ifndef YYFPRINTF | ||
| 476 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | ||
| 477 | # define YYFPRINTF fprintf | ||
| 478 | # endif | ||
| 479 | |||
| 480 | # define YYDPRINTF(Args) \ | ||
| 481 | do { \ | ||
| 482 | if (yydebug) \ | ||
| 483 | YYFPRINTF Args; \ | ||
| 484 | } while (0) | ||
| 485 | |||
| 486 | # define YYDSYMPRINT(Args) \ | ||
| 487 | do { \ | ||
| 488 | if (yydebug) \ | ||
| 489 | yysymprint Args; \ | ||
| 490 | } while (0) | ||
| 491 | |||
| 492 | # define YYDSYMPRINTF(Title, Token, Value, Location) \ | ||
| 493 | do { \ | ||
| 494 | if (yydebug) \ | ||
| 495 | { \ | ||
| 496 | YYFPRINTF (stderr, "%s ", Title); \ | ||
| 497 | yysymprint (stderr, \ | ||
| 498 | Token, Value); \ | ||
| 499 | YYFPRINTF (stderr, "\n"); \ | ||
| 500 | } \ | ||
| 501 | } while (0) | ||
| 502 | |||
| 503 | /*------------------------------------------------------------------. | ||
| 504 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | ||
| 505 | | TOP (cinluded). | | ||
| 506 | `------------------------------------------------------------------*/ | ||
| 507 | |||
| 508 | #if defined (__STDC__) || defined (__cplusplus) | ||
| 509 | static void | ||
| 510 | yy_stack_print (short *bottom, short *top) | ||
| 511 | #else | ||
| 512 | static void | ||
| 513 | yy_stack_print (bottom, top) | ||
| 514 | short *bottom; | ||
| 515 | short *top; | ||
| 516 | #endif | ||
| 517 | { | ||
| 518 | YYFPRINTF (stderr, "Stack now"); | ||
| 519 | for (/* Nothing. */; bottom <= top; ++bottom) | ||
| 520 | YYFPRINTF (stderr, " %d", *bottom); | ||
| 521 | YYFPRINTF (stderr, "\n"); | ||
| 522 | } | ||
| 523 | |||
| 524 | # define YY_STACK_PRINT(Bottom, Top) \ | ||
| 525 | do { \ | ||
| 526 | if (yydebug) \ | ||
| 527 | yy_stack_print ((Bottom), (Top)); \ | ||
| 528 | } while (0) | ||
| 529 | |||
| 530 | |||
| 531 | /*------------------------------------------------. | ||
| 532 | | Report that the YYRULE is going to be reduced. | | ||
| 533 | `------------------------------------------------*/ | ||
| 534 | |||
| 535 | #if defined (__STDC__) || defined (__cplusplus) | ||
| 536 | static void | ||
| 537 | yy_reduce_print (int yyrule) | ||
| 538 | #else | ||
| 539 | static void | ||
| 540 | yy_reduce_print (yyrule) | ||
| 541 | int yyrule; | ||
| 542 | #endif | ||
| 543 | { | ||
| 544 | int yyi; | ||
| 545 | unsigned int yylineno = yyrline[yyrule]; | ||
| 546 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", | ||
| 547 | yyrule - 1, yylineno); | ||
| 548 | /* Print the symbols being reduced, and their result. */ | ||
| 549 | for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) | ||
| 550 | YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); | ||
| 551 | YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); | ||
| 552 | } | ||
| 553 | |||
| 554 | # define YY_REDUCE_PRINT(Rule) \ | ||
| 555 | do { \ | ||
| 556 | if (yydebug) \ | ||
| 557 | yy_reduce_print (Rule); \ | ||
| 558 | } while (0) | ||
| 559 | |||
| 560 | /* Nonzero means print parse trace. It is left uninitialized so that | ||
| 561 | multiple parsers can coexist. */ | ||
| 562 | int yydebug; | ||
| 563 | #else /* !YYDEBUG */ | ||
| 564 | # define YYDPRINTF(Args) | ||
| 565 | # define YYDSYMPRINT(Args) | ||
| 566 | # define YYDSYMPRINTF(Title, Token, Value, Location) | ||
| 567 | # define YY_STACK_PRINT(Bottom, Top) | ||
| 568 | # define YY_REDUCE_PRINT(Rule) | ||
| 569 | #endif /* !YYDEBUG */ | ||
| 570 | |||
| 571 | |||
| 572 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | ||
| 573 | #ifndef YYINITDEPTH | ||
| 574 | # define YYINITDEPTH 200 | ||
| 575 | #endif | ||
| 576 | |||
| 577 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | ||
| 578 | if the built-in stack extension method is used). | ||
| 579 | |||
| 580 | Do not make this value too large; the results are undefined if | ||
| 581 | SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) | ||
| 582 | evaluated with infinite-precision integer arithmetic. */ | ||
| 583 | |||
| 584 | #if YYMAXDEPTH == 0 | ||
| 585 | # undef YYMAXDEPTH | ||
| 586 | #endif | ||
| 587 | |||
| 588 | #ifndef YYMAXDEPTH | ||
| 589 | # define YYMAXDEPTH 10000 | ||
| 590 | #endif | ||
| 591 | |||
| 592 | |||
| 593 | |||
| 594 | #if YYERROR_VERBOSE | ||
| 595 | |||
| 596 | # ifndef yystrlen | ||
| 597 | # if defined (__GLIBC__) && defined (_STRING_H) | ||
| 598 | # define yystrlen strlen | ||
| 599 | # else | ||
| 600 | /* Return the length of YYSTR. */ | ||
| 601 | static YYSIZE_T | ||
| 602 | # if defined (__STDC__) || defined (__cplusplus) | ||
| 603 | yystrlen (const char *yystr) | ||
| 604 | # else | ||
| 605 | yystrlen (yystr) | ||
| 606 | const char *yystr; | ||
| 607 | # endif | ||
| 608 | { | ||
| 609 | register const char *yys = yystr; | ||
| 610 | |||
| 611 | while (*yys++ != '\0') | ||
| 612 | continue; | ||
| 613 | |||
| 614 | return yys - yystr - 1; | ||
| 615 | } | ||
| 616 | # endif | ||
| 617 | # endif | ||
| 618 | |||
| 619 | # ifndef yystpcpy | ||
| 620 | # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) | ||
| 621 | # define yystpcpy stpcpy | ||
| 622 | # else | ||
| 623 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | ||
| 624 | YYDEST. */ | ||
| 625 | static char * | ||
| 626 | # if defined (__STDC__) || defined (__cplusplus) | ||
| 627 | yystpcpy (char *yydest, const char *yysrc) | ||
| 628 | # else | ||
| 629 | yystpcpy (yydest, yysrc) | ||
| 630 | char *yydest; | ||
| 631 | const char *yysrc; | ||
| 632 | # endif | ||
| 633 | { | ||
| 634 | register char *yyd = yydest; | ||
| 635 | register const char *yys = yysrc; | ||
| 636 | |||
| 637 | while ((*yyd++ = *yys++) != '\0') | ||
| 638 | continue; | ||
| 639 | |||
| 640 | return yyd - 1; | ||
| 641 | } | ||
| 642 | # endif | ||
| 643 | # endif | ||
| 644 | |||
| 645 | #endif /* !YYERROR_VERBOSE */ | ||
| 646 | |||
| 647 | |||
| 648 | |||
| 649 | #if YYDEBUG | ||
| 650 | /*--------------------------------. | ||
| 651 | | Print this symbol on YYOUTPUT. | | ||
| 652 | `--------------------------------*/ | ||
| 653 | |||
| 654 | #if defined (__STDC__) || defined (__cplusplus) | ||
| 655 | static void | ||
| 656 | yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) | ||
| 657 | #else | ||
| 658 | static void | ||
| 659 | yysymprint (yyoutput, yytype, yyvaluep) | ||
| 660 | FILE *yyoutput; | ||
| 661 | int yytype; | ||
| 662 | YYSTYPE *yyvaluep; | ||
| 663 | #endif | ||
| 664 | { | ||
| 665 | /* Pacify ``unused variable'' warnings. */ | ||
| 666 | (void) yyvaluep; | ||
| 667 | |||
| 668 | if (yytype < YYNTOKENS) | ||
| 669 | { | ||
| 670 | YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); | ||
| 671 | # ifdef YYPRINT | ||
| 672 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | ||
| 673 | # endif | ||
| 674 | } | ||
| 675 | else | ||
| 676 | YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); | ||
| 677 | |||
| 678 | switch (yytype) | ||
| 679 | { | ||
| 680 | default: | ||
| 681 | break; | ||
| 682 | } | ||
| 683 | YYFPRINTF (yyoutput, ")"); | ||
| 684 | } | ||
| 685 | |||
| 686 | #endif /* ! YYDEBUG */ | ||
| 687 | /*-----------------------------------------------. | ||
| 688 | | Release the memory associated to this symbol. | | ||
| 689 | `-----------------------------------------------*/ | ||
| 690 | |||
| 691 | #if defined (__STDC__) || defined (__cplusplus) | ||
| 692 | static void | ||
| 693 | yydestruct (int yytype, YYSTYPE *yyvaluep) | ||
| 694 | #else | ||
| 695 | static void | ||
| 696 | yydestruct (yytype, yyvaluep) | ||
| 697 | int yytype; | ||
| 698 | YYSTYPE *yyvaluep; | ||
| 699 | #endif | ||
| 700 | { | ||
| 701 | /* Pacify ``unused variable'' warnings. */ | ||
| 702 | (void) yyvaluep; | ||
| 703 | |||
| 704 | switch (yytype) | ||
| 705 | { | ||
| 706 | |||
| 707 | default: | ||
| 708 | break; | ||
| 709 | } | ||
| 710 | } | ||
| 711 | |||
| 712 | |||
| 713 | /* Prevent warnings from -Wmissing-prototypes. */ | ||
| 714 | |||
| 715 | #ifdef YYPARSE_PARAM | ||
| 716 | # if defined (__STDC__) || defined (__cplusplus) | ||
| 717 | int yyparse (void *YYPARSE_PARAM); | ||
| 718 | # else | ||
| 719 | int yyparse (); | ||
| 720 | # endif | ||
| 721 | #else /* ! YYPARSE_PARAM */ | ||
| 722 | #if defined (__STDC__) || defined (__cplusplus) | ||
| 723 | int yyparse (void); | ||
| 724 | #else | ||
| 725 | int yyparse (); | ||
| 726 | #endif | ||
| 727 | #endif /* ! YYPARSE_PARAM */ | ||
| 728 | |||
| 729 | |||
| 730 | |||
| 731 | /* The lookahead symbol. */ | ||
| 732 | int yychar; | ||
| 733 | |||
| 734 | /* The semantic value of the lookahead symbol. */ | ||
| 735 | YYSTYPE yylval; | ||
| 736 | |||
| 737 | /* Number of syntax errors so far. */ | ||
| 738 | int yynerrs; | ||
| 739 | |||
| 740 | |||
| 741 | |||
| 742 | /*----------. | ||
| 743 | | yyparse. | | ||
| 744 | `----------*/ | ||
| 745 | |||
| 746 | #ifdef YYPARSE_PARAM | ||
| 747 | # if defined (__STDC__) || defined (__cplusplus) | ||
| 748 | int yyparse (void *YYPARSE_PARAM) | ||
| 749 | # else | ||
| 750 | int yyparse (YYPARSE_PARAM) | ||
| 751 | void *YYPARSE_PARAM; | ||
| 752 | # endif | ||
| 753 | #else /* ! YYPARSE_PARAM */ | ||
| 754 | #if defined (__STDC__) || defined (__cplusplus) | ||
| 755 | int | ||
| 756 | yyparse (void) | ||
| 757 | #else | ||
| 758 | int | ||
| 759 | yyparse () | ||
| 760 | |||
| 761 | #endif | ||
| 762 | #endif | ||
| 763 | { | ||
| 764 | |||
| 765 | register int yystate; | ||
| 766 | register int yyn; | ||
| 767 | int yyresult; | ||
| 768 | /* Number of tokens to shift before error messages enabled. */ | ||
| 769 | int yyerrstatus; | ||
| 770 | /* Lookahead token as an internal (translated) token number. */ | ||
| 771 | int yytoken = 0; | ||
| 772 | |||
| 773 | /* Three stacks and their tools: | ||
| 774 | `yyss': related to states, | ||
| 775 | `yyvs': related to semantic values, | ||
| 776 | `yyls': related to locations. | ||
| 777 | |||
| 778 | Refer to the stacks thru separate pointers, to allow yyoverflow | ||
| 779 | to reallocate them elsewhere. */ | ||
| 780 | |||
| 781 | /* The state stack. */ | ||
| 782 | short yyssa[YYINITDEPTH]; | ||
| 783 | short *yyss = yyssa; | ||
| 784 | register short *yyssp; | ||
| 785 | |||
| 786 | /* The semantic value stack. */ | ||
| 787 | YYSTYPE yyvsa[YYINITDEPTH]; | ||
| 788 | YYSTYPE *yyvs = yyvsa; | ||
| 789 | register YYSTYPE *yyvsp; | ||
| 790 | |||
| 791 | |||
| 792 | |||
| 793 | #define YYPOPSTACK (yyvsp--, yyssp--) | ||
| 794 | |||
| 795 | YYSIZE_T yystacksize = YYINITDEPTH; | ||
| 796 | |||
| 797 | /* The variables used to return semantic value and location from the | ||
| 798 | action routines. */ | ||
| 799 | YYSTYPE yyval; | ||
| 800 | |||
| 801 | |||
| 802 | /* When reducing, the number of symbols on the RHS of the reduced | ||
| 803 | rule. */ | ||
| 804 | int yylen; | ||
| 805 | |||
| 806 | YYDPRINTF ((stderr, "Starting parse\n")); | ||
| 807 | |||
| 808 | yystate = 0; | ||
| 809 | yyerrstatus = 0; | ||
| 810 | yynerrs = 0; | ||
| 811 | yychar = YYEMPTY; /* Cause a token to be read. */ | ||
| 812 | |||
| 813 | /* Initialize stack pointers. | ||
| 814 | Waste one element of value and location stack | ||
| 815 | so that they stay on the same level as the state stack. | ||
| 816 | The wasted elements are never initialized. */ | ||
| 817 | |||
| 818 | yyssp = yyss; | ||
| 819 | yyvsp = yyvs; | ||
| 820 | |||
| 821 | goto yysetstate; | ||
| 822 | |||
| 823 | /*------------------------------------------------------------. | ||
| 824 | | yynewstate -- Push a new state, which is found in yystate. | | ||
| 825 | `------------------------------------------------------------*/ | ||
| 826 | yynewstate: | ||
| 827 | /* In all cases, when you get here, the value and location stacks | ||
| 828 | have just been pushed. so pushing a state here evens the stacks. | ||
| 829 | */ | ||
| 830 | yyssp++; | ||
| 831 | |||
| 832 | yysetstate: | ||
| 833 | *yyssp = yystate; | ||
| 834 | |||
| 835 | if (yyss + yystacksize - 1 <= yyssp) | ||
| 836 | { | ||
| 837 | /* Get the current used size of the three stacks, in elements. */ | ||
| 838 | YYSIZE_T yysize = yyssp - yyss + 1; | ||
| 839 | |||
| 840 | #ifdef yyoverflow | ||
| 841 | { | ||
| 842 | /* Give user a chance to reallocate the stack. Use copies of | ||
| 843 | these so that the &'s don't force the real ones into | ||
| 844 | memory. */ | ||
| 845 | YYSTYPE *yyvs1 = yyvs; | ||
| 846 | short *yyss1 = yyss; | ||
| 847 | |||
| 848 | |||
| 849 | /* Each stack pointer address is followed by the size of the | ||
| 850 | data in use in that stack, in bytes. This used to be a | ||
| 851 | conditional around just the two extra args, but that might | ||
| 852 | be undefined if yyoverflow is a macro. */ | ||
| 853 | yyoverflow ("parser stack overflow", | ||
| 854 | &yyss1, yysize * sizeof (*yyssp), | ||
| 855 | &yyvs1, yysize * sizeof (*yyvsp), | ||
| 856 | |||
| 857 | &yystacksize); | ||
| 858 | |||
| 859 | yyss = yyss1; | ||
| 860 | yyvs = yyvs1; | ||
| 861 | } | ||
| 862 | #else /* no yyoverflow */ | ||
| 863 | # ifndef YYSTACK_RELOCATE | ||
| 864 | goto yyoverflowlab; | ||
| 865 | # else | ||
| 866 | /* Extend the stack our own way. */ | ||
| 867 | if (YYMAXDEPTH <= yystacksize) | ||
| 868 | goto yyoverflowlab; | ||
| 869 | yystacksize *= 2; | ||
| 870 | if (YYMAXDEPTH < yystacksize) | ||
| 871 | yystacksize = YYMAXDEPTH; | ||
| 872 | |||
| 873 | { | ||
| 874 | short *yyss1 = yyss; | ||
| 875 | union yyalloc *yyptr = | ||
| 876 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | ||
| 877 | if (! yyptr) | ||
| 878 | goto yyoverflowlab; | ||
| 879 | YYSTACK_RELOCATE (yyss); | ||
| 880 | YYSTACK_RELOCATE (yyvs); | ||
| 881 | |||
| 882 | # undef YYSTACK_RELOCATE | ||
| 883 | if (yyss1 != yyssa) | ||
| 884 | YYSTACK_FREE (yyss1); | ||
| 885 | } | ||
| 886 | # endif | ||
| 887 | #endif /* no yyoverflow */ | ||
| 888 | |||
| 889 | yyssp = yyss + yysize - 1; | ||
| 890 | yyvsp = yyvs + yysize - 1; | ||
| 891 | |||
| 892 | |||
| 893 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", | ||
| 894 | (unsigned long int) yystacksize)); | ||
| 895 | |||
| 896 | if (yyss + yystacksize - 1 <= yyssp) | ||
| 897 | YYABORT; | ||
| 898 | } | ||
| 899 | |||
| 900 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); | ||
| 901 | |||
| 902 | goto yybackup; | ||
| 903 | |||
| 904 | /*-----------. | ||
| 905 | | yybackup. | | ||
| 906 | `-----------*/ | ||
| 907 | yybackup: | ||
| 908 | |||
| 909 | /* Do appropriate processing given the current state. */ | ||
| 910 | /* Read a lookahead token if we need one and don't already have one. */ | ||
| 911 | /* yyresume: */ | ||
| 912 | |||
| 913 | /* First try to decide what to do without reference to lookahead token. */ | ||
| 914 | |||
| 915 | yyn = yypact[yystate]; | ||
| 916 | if (yyn == YYPACT_NINF) | ||
| 917 | goto yydefault; | ||
| 918 | |||
| 919 | /* Not known => get a lookahead token if don't already have one. */ | ||
| 920 | |||
| 921 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | ||
| 922 | if (yychar == YYEMPTY) | ||
| 923 | { | ||
| 924 | YYDPRINTF ((stderr, "Reading a token: ")); | ||
| 925 | yychar = YYLEX; | ||
| 926 | } | ||
| 927 | |||
| 928 | if (yychar <= YYEOF) | ||
| 929 | { | ||
| 930 | yychar = yytoken = YYEOF; | ||
| 931 | YYDPRINTF ((stderr, "Now at end of input.\n")); | ||
| 932 | } | ||
| 933 | else | ||
| 934 | { | ||
| 935 | yytoken = YYTRANSLATE (yychar); | ||
| 936 | YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); | ||
| 937 | } | ||
| 938 | |||
| 939 | /* If the proper action on seeing token YYTOKEN is to reduce or to | ||
| 940 | detect an error, take that action. */ | ||
| 941 | yyn += yytoken; | ||
| 942 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) | ||
| 943 | goto yydefault; | ||
| 944 | yyn = yytable[yyn]; | ||
| 945 | if (yyn <= 0) | ||
| 946 | { | ||
| 947 | if (yyn == 0 || yyn == YYTABLE_NINF) | ||
| 948 | goto yyerrlab; | ||
| 949 | yyn = -yyn; | ||
| 950 | goto yyreduce; | ||
| 951 | } | ||
| 952 | |||
| 953 | if (yyn == YYFINAL) | ||
| 954 | YYACCEPT; | ||
| 955 | |||
| 956 | /* Shift the lookahead token. */ | ||
| 957 | YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); | ||
| 958 | |||
| 959 | /* Discard the token being shifted unless it is eof. */ | ||
| 960 | if (yychar != YYEOF) | ||
| 961 | yychar = YYEMPTY; | ||
| 962 | |||
| 963 | *++yyvsp = yylval; | ||
| 964 | |||
| 965 | |||
| 966 | /* Count tokens shifted since error; after three, turn off error | ||
| 967 | status. */ | ||
| 968 | if (yyerrstatus) | ||
| 969 | yyerrstatus--; | ||
| 970 | |||
| 971 | yystate = yyn; | ||
| 972 | goto yynewstate; | ||
| 973 | |||
| 974 | |||
| 975 | /*-----------------------------------------------------------. | ||
| 976 | | yydefault -- do the default action for the current state. | | ||
| 977 | `-----------------------------------------------------------*/ | ||
| 978 | yydefault: | ||
| 979 | yyn = yydefact[yystate]; | ||
| 980 | if (yyn == 0) | ||
| 981 | goto yyerrlab; | ||
| 982 | goto yyreduce; | ||
| 983 | |||
| 984 | |||
| 985 | /*-----------------------------. | ||
| 986 | | yyreduce -- Do a reduction. | | ||
| 987 | `-----------------------------*/ | ||
| 988 | yyreduce: | ||
| 989 | /* yyn is the number of a rule to reduce with. */ | ||
| 990 | yylen = yyr2[yyn]; | ||
| 991 | |||
| 992 | /* If YYLEN is nonzero, implement the default value of the action: | ||
| 993 | `$$ = $1'. | ||
| 994 | |||
| 995 | Otherwise, the following line sets YYVAL to garbage. | ||
| 996 | This behavior is undocumented and Bison | ||
| 997 | users should not rely upon it. Assigning to YYVAL | ||
| 998 | unconditionally makes the parser a bit smaller, and it avoids a | ||
| 999 | GCC warning that YYVAL may be used uninitialized. */ | ||
| 1000 | yyval = yyvsp[1-yylen]; | ||
| 1001 | |||
| 1002 | |||
| 1003 | YY_REDUCE_PRINT (yyn); | ||
| 1004 | switch (yyn) | ||
| 1005 | { | ||
| 1006 | case 2: | ||
| 1007 | #line 37 "input.y" | ||
| 1008 | { | ||
| 1009 | in_grammar = NULL; | ||
| 1010 | } | ||
| 1011 | break; | ||
| 1012 | |||
| 1013 | case 3: | ||
| 1014 | #line 41 "input.y" | ||
| 1015 | { | ||
| 1016 | in_grammar = NULL; | ||
| 1017 | } | ||
| 1018 | break; | ||
| 1019 | |||
| 1020 | case 4: | ||
| 1021 | #line 47 "input.y" | ||
| 1022 | { | ||
| 1023 | yyval.ugly = NULL; | ||
| 1024 | } | ||
| 1025 | break; | ||
| 1026 | |||
| 1027 | case 5: | ||
| 1028 | #line 54 "input.y" | ||
| 1029 | { | ||
| 1030 | yyval.ugly = NULL; | ||
| 1031 | } | ||
| 1032 | break; | ||
| 1033 | |||
| 1034 | case 6: | ||
| 1035 | #line 58 "input.y" | ||
| 1036 | { | ||
| 1037 | yyval.ugly = NULL; | ||
| 1038 | } | ||
| 1039 | break; | ||
| 1040 | |||
| 1041 | case 7: | ||
| 1042 | #line 65 "input.y" | ||
| 1043 | { | ||
| 1044 | yyval.ugly = NULL; | ||
| 1045 | } | ||
| 1046 | break; | ||
| 1047 | |||
| 1048 | case 8: | ||
| 1049 | #line 69 "input.y" | ||
| 1050 | { | ||
| 1051 | yyval.ugly = NULL; | ||
| 1052 | } | ||
| 1053 | break; | ||
| 1054 | |||
| 1055 | case 9: | ||
| 1056 | #line 73 "input.y" | ||
| 1057 | { | ||
| 1058 | yyval.ugly = NULL; | ||
| 1059 | } | ||
| 1060 | break; | ||
| 1061 | |||
| 1062 | case 10: | ||
| 1063 | #line 80 "input.y" | ||
| 1064 | { | ||
| 1065 | yyval.ugly = NULL; | ||
| 1066 | } | ||
| 1067 | break; | ||
| 1068 | |||
| 1069 | case 11: | ||
| 1070 | #line 84 "input.y" | ||
| 1071 | { | ||
| 1072 | yyval.ugly = NULL; | ||
| 1073 | } | ||
| 1074 | break; | ||
| 1075 | |||
| 1076 | case 12: | ||
| 1077 | #line 90 "input.y" | ||
| 1078 | { | ||
| 1079 | fprintf (stderr, "FILTER: %s with /%s/\n", yyvsp[-4].str, yyvsp[-1].str); | ||
| 1080 | yyval.ugly = NULL; | ||
| 1081 | } | ||
| 1082 | break; | ||
| 1083 | |||
| 1084 | case 13: | ||
| 1085 | #line 95 "input.y" | ||
| 1086 | { | ||
| 1087 | yyval.ugly = NULL; | ||
| 1088 | } | ||
| 1089 | break; | ||
| 1090 | |||
| 1091 | case 14: | ||
| 1092 | #line 99 "input.y" | ||
| 1093 | { | ||
| 1094 | yyval.ugly = NULL; | ||
| 1095 | } | ||
| 1096 | break; | ||
| 1097 | |||
| 1098 | |||
| 1099 | } | ||
| 1100 | |||
| 1101 | /* Line 999 of yacc.c. */ | ||
| 1102 | #line 1103 "y.tab.c" | ||
| 1103 | |||
| 1104 | yyvsp -= yylen; | ||
| 1105 | yyssp -= yylen; | ||
| 1106 | |||
| 1107 | |||
| 1108 | YY_STACK_PRINT (yyss, yyssp); | ||
| 1109 | |||
| 1110 | *++yyvsp = yyval; | ||
| 1111 | |||
| 1112 | |||
| 1113 | /* Now `shift' the result of the reduction. Determine what state | ||
| 1114 | that goes to, based on the state we popped back to and the rule | ||
| 1115 | number reduced by. */ | ||
| 1116 | |||
| 1117 | yyn = yyr1[yyn]; | ||
| 1118 | |||
| 1119 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | ||
| 1120 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) | ||
| 1121 | yystate = yytable[yystate]; | ||
| 1122 | else | ||
| 1123 | yystate = yydefgoto[yyn - YYNTOKENS]; | ||
| 1124 | |||
| 1125 | goto yynewstate; | ||
| 1126 | |||
| 1127 | |||
| 1128 | /*------------------------------------. | ||
| 1129 | | yyerrlab -- here on detecting error | | ||
| 1130 | `------------------------------------*/ | ||
| 1131 | yyerrlab: | ||
| 1132 | /* If not already recovering from an error, report this error. */ | ||
| 1133 | if (!yyerrstatus) | ||
| 1134 | { | ||
| 1135 | ++yynerrs; | ||
| 1136 | #if YYERROR_VERBOSE | ||
| 1137 | yyn = yypact[yystate]; | ||
| 1138 | |||
| 1139 | if (YYPACT_NINF < yyn && yyn < YYLAST) | ||
| 1140 | { | ||
| 1141 | YYSIZE_T yysize = 0; | ||
| 1142 | int yytype = YYTRANSLATE (yychar); | ||
| 1143 | char *yymsg; | ||
| 1144 | int yyx, yycount; | ||
| 1145 | |||
| 1146 | yycount = 0; | ||
| 1147 | /* Start YYX at -YYN if negative to avoid negative indexes in | ||
| 1148 | YYCHECK. */ | ||
| 1149 | for (yyx = yyn < 0 ? -yyn : 0; | ||
| 1150 | yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) | ||
| 1151 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | ||
| 1152 | yysize += yystrlen (yytname[yyx]) + 15, yycount++; | ||
| 1153 | yysize += yystrlen ("syntax error, unexpected ") + 1; | ||
| 1154 | yysize += yystrlen (yytname[yytype]); | ||
| 1155 | yymsg = (char *) YYSTACK_ALLOC (yysize); | ||
| 1156 | if (yymsg != 0) | ||
| 1157 | { | ||
| 1158 | char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); | ||
| 1159 | yyp = yystpcpy (yyp, yytname[yytype]); | ||
| 1160 | |||
| 1161 | if (yycount < 5) | ||
| 1162 | { | ||
| 1163 | yycount = 0; | ||
| 1164 | for (yyx = yyn < 0 ? -yyn : 0; | ||
| 1165 | yyx < (int) (sizeof (yytname) / sizeof (char *)); | ||
| 1166 | yyx++) | ||
| 1167 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) | ||
| 1168 | { | ||
| 1169 | const char *yyq = ! yycount ? ", expecting " : " or "; | ||
| 1170 | yyp = yystpcpy (yyp, yyq); | ||
| 1171 | yyp = yystpcpy (yyp, yytname[yyx]); | ||
| 1172 | yycount++; | ||
| 1173 | } | ||
| 1174 | } | ||
| 1175 | yyerror (yymsg); | ||
| 1176 | YYSTACK_FREE (yymsg); | ||
| 1177 | } | ||
| 1178 | else | ||
| 1179 | yyerror ("syntax error; also virtual memory exhausted"); | ||
| 1180 | } | ||
| 1181 | else | ||
| 1182 | #endif /* YYERROR_VERBOSE */ | ||
| 1183 | yyerror ("syntax error"); | ||
| 1184 | } | ||
| 1185 | |||
| 1186 | |||
| 1187 | |||
| 1188 | if (yyerrstatus == 3) | ||
| 1189 | { | ||
| 1190 | /* If just tried and failed to reuse lookahead token after an | ||
| 1191 | error, discard it. */ | ||
| 1192 | |||
| 1193 | /* Return failure if at end of input. */ | ||
| 1194 | if (yychar == YYEOF) | ||
| 1195 | { | ||
| 1196 | /* Pop the error token. */ | ||
| 1197 | YYPOPSTACK; | ||
| 1198 | /* Pop the rest of the stack. */ | ||
| 1199 | while (yyss < yyssp) | ||
| 1200 | { | ||
| 1201 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); | ||
| 1202 | yydestruct (yystos[*yyssp], yyvsp); | ||
| 1203 | YYPOPSTACK; | ||
| 1204 | } | ||
| 1205 | YYABORT; | ||
| 1206 | } | ||
| 1207 | |||
| 1208 | YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); | ||
| 1209 | yydestruct (yytoken, &yylval); | ||
| 1210 | yychar = YYEMPTY; | ||
| 1211 | |||
| 1212 | } | ||
| 1213 | |||
| 1214 | /* Else will try to reuse lookahead token after shifting the error | ||
| 1215 | token. */ | ||
| 1216 | goto yyerrlab1; | ||
| 1217 | |||
| 1218 | |||
| 1219 | /*----------------------------------------------------. | ||
| 1220 | | yyerrlab1 -- error raised explicitly by an action. | | ||
| 1221 | `----------------------------------------------------*/ | ||
| 1222 | yyerrlab1: | ||
| 1223 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | ||
| 1224 | |||
| 1225 | for (;;) | ||
| 1226 | { | ||
| 1227 | yyn = yypact[yystate]; | ||
| 1228 | if (yyn != YYPACT_NINF) | ||
| 1229 | { | ||
| 1230 | yyn += YYTERROR; | ||
| 1231 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) | ||
| 1232 | { | ||
| 1233 | yyn = yytable[yyn]; | ||
| 1234 | if (0 < yyn) | ||
| 1235 | break; | ||
| 1236 | } | ||
| 1237 | } | ||
| 1238 | |||
| 1239 | /* Pop the current state because it cannot handle the error token. */ | ||
| 1240 | if (yyssp == yyss) | ||
| 1241 | YYABORT; | ||
| 1242 | |||
| 1243 | YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); | ||
| 1244 | yydestruct (yystos[yystate], yyvsp); | ||
| 1245 | yyvsp--; | ||
| 1246 | yystate = *--yyssp; | ||
| 1247 | |||
| 1248 | YY_STACK_PRINT (yyss, yyssp); | ||
| 1249 | } | ||
| 1250 | |||
| 1251 | if (yyn == YYFINAL) | ||
| 1252 | YYACCEPT; | ||
| 1253 | |||
| 1254 | YYDPRINTF ((stderr, "Shifting error token, ")); | ||
| 1255 | |||
| 1256 | *++yyvsp = yylval; | ||
| 1257 | |||
| 1258 | |||
| 1259 | yystate = yyn; | ||
| 1260 | goto yynewstate; | ||
| 1261 | |||
| 1262 | |||
| 1263 | /*-------------------------------------. | ||
| 1264 | | yyacceptlab -- YYACCEPT comes here. | | ||
| 1265 | `-------------------------------------*/ | ||
| 1266 | yyacceptlab: | ||
| 1267 | yyresult = 0; | ||
| 1268 | goto yyreturn; | ||
| 1269 | |||
| 1270 | /*-----------------------------------. | ||
| 1271 | | yyabortlab -- YYABORT comes here. | | ||
| 1272 | `-----------------------------------*/ | ||
| 1273 | yyabortlab: | ||
| 1274 | yyresult = 1; | ||
| 1275 | goto yyreturn; | ||
| 1276 | |||
| 1277 | #ifndef yyoverflow | ||
| 1278 | /*----------------------------------------------. | ||
| 1279 | | yyoverflowlab -- parser overflow comes here. | | ||
| 1280 | `----------------------------------------------*/ | ||
| 1281 | yyoverflowlab: | ||
| 1282 | yyerror ("parser stack overflow"); | ||
| 1283 | yyresult = 2; | ||
| 1284 | /* Fall through. */ | ||
| 1285 | #endif | ||
| 1286 | |||
| 1287 | yyreturn: | ||
| 1288 | #ifndef yyoverflow | ||
| 1289 | if (yyss != yyssa) | ||
| 1290 | YYSTACK_FREE (yyss); | ||
| 1291 | #endif | ||
| 1292 | return yyresult; | ||
| 1293 | } | ||
| 1294 | |||
| 1295 | |||
| 1296 | #line 105 "input.y" | ||
| 1297 | |||
| 1298 | |||
| 1299 | /* TODO: includes in parser come here | ||
| 1300 | */ | ||
| 1301 | |||
| 1302 | |||
| 1303 | |||
diff --git a/other/gramble/y.tab.h b/other/gramble/y.tab.h new file mode 100644 index 0000000..b9df23b --- /dev/null +++ b/other/gramble/y.tab.h | |||
| @@ -0,0 +1,71 @@ | |||
| 1 | /* A Bison parser, made by GNU Bison 1.875a. */ | ||
| 2 | |||
| 3 | /* Skeleton parser for Yacc-like parsing with Bison, | ||
| 4 | Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. | ||
| 5 | |||
| 6 | This program is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | any later version. | ||
| 10 | |||
| 11 | This program is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with this program; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 59 Temple Place - Suite 330, | ||
| 19 | Boston, MA 02111-1307, USA. */ | ||
| 20 | |||
| 21 | /* As a special exception, when this file is copied by Bison into a | ||
| 22 | Bison output file, you may use that output file without restriction. | ||
| 23 | This special exception was added by the Free Software Foundation | ||
| 24 | in version 1.24 of Bison. */ | ||
| 25 | |||
| 26 | /* Tokens. */ | ||
| 27 | #ifndef YYTOKENTYPE | ||
| 28 | # define YYTOKENTYPE | ||
| 29 | /* Put the tokens into the symbol table, so that GDB and other debuggers | ||
| 30 | know about them. */ | ||
| 31 | enum yytokentype { | ||
| 32 | STR = 258, | ||
| 33 | NSSTR = 259, | ||
| 34 | NTERM = 260, | ||
| 35 | TERM = 261, | ||
| 36 | FILTER = 262, | ||
| 37 | NEGFILTER = 263, | ||
| 38 | SIZE = 264, | ||
| 39 | NUM = 265 | ||
| 40 | }; | ||
| 41 | #endif | ||
| 42 | #define STR 258 | ||
| 43 | #define NSSTR 259 | ||
| 44 | #define NTERM 260 | ||
| 45 | #define TERM 261 | ||
| 46 | #define FILTER 262 | ||
| 47 | #define NEGFILTER 263 | ||
| 48 | #define SIZE 264 | ||
| 49 | #define NUM 265 | ||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | |||
| 54 | #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) | ||
| 55 | #line 18 "input.y" | ||
| 56 | typedef union YYSTYPE { | ||
| 57 | unsigned int uint; /* unsigned number (length) */ | ||
| 58 | unsigned char * str; /* generic ASCIIZ string pointer */ | ||
| 59 | void * ugly; | ||
| 60 | } YYSTYPE; | ||
| 61 | /* Line 1240 of yacc.c. */ | ||
| 62 | #line 63 "y.tab.h" | ||
| 63 | # define yystype YYSTYPE /* obsolescent; will be withdrawn */ | ||
| 64 | # define YYSTYPE_IS_DECLARED 1 | ||
| 65 | # define YYSTYPE_IS_TRIVIAL 1 | ||
| 66 | #endif | ||
| 67 | |||
| 68 | extern YYSTYPE yylval; | ||
| 69 | |||
| 70 | |||
| 71 | |||
diff --git a/other/gramble/y.tab.o b/other/gramble/y.tab.o new file mode 100644 index 0000000..c41fd37 --- /dev/null +++ b/other/gramble/y.tab.o | |||
| Binary files differ | |||
