Common subdirectories: ../aslc-20001128/CVS and ./CVS diff -uN ../aslc-20001128/Makefile ./Makefile --- ../aslc-20001128/Makefile Tue Nov 28 10:10:32 2000 +++ ./Makefile Wed Nov 29 10:11:44 2000 @@ -1,7 +1,7 @@ # $FreeBSD$ PROG= aslc -SRCS= aslc.c aslcsymtab.c aslclex.l aslcparse.y y.tab.h +SRCS= aslc.c aslcsymtab.c aslcsymtree.c aslclex.l aslcparse.y y.tab.h DPADD= ${LIBL} LDADD= -ll Binary files ../aslc-20001128/aslc and ./aslc differ Binary files ../aslc-20001128/aslc.o and ./aslc.o differ diff -uN ../aslc-20001128/aslclex.c ./aslclex.c --- ../aslc-20001128/aslclex.c Thu Jan 1 09:00:00 1970 +++ ./aslclex.c Wed Nov 29 12:41:42 2000 @@ -0,0 +1,1896 @@ +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $ + * $FreeBSD: src/usr.bin/lex/flex.skl,v 1.4 1999/10/27 07:56:44 obrien Exp $ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 31 +#define YY_END_OF_BUFFER 32 +static yyconst short int yy_accept[154] = + { 0, + 0, 0, 0, 0, 4, 4, 32, 31, 30, 7, + 1, 31, 8, 27, 31, 23, 23, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 27, 4, 5, 30, 7, 0, 24, 3, 0, 23, + 0, 28, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 4, 5, 5, 6, 0, + 2, 22, 28, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 28, 19, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 29, 0, 0, 21, 0, 0, + + 14, 0, 0, 0, 0, 15, 0, 16, 12, 29, + 25, 0, 0, 0, 20, 11, 0, 0, 0, 0, + 0, 0, 0, 26, 0, 0, 0, 0, 0, 0, + 0, 13, 0, 0, 0, 0, 0, 0, 17, 0, + 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, + 10, 9, 0 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 4, 1, 1, 1, 1, 1, 5, + 5, 6, 1, 5, 1, 7, 8, 9, 10, 10, + 10, 10, 10, 10, 11, 12, 12, 1, 1, 1, + 1, 1, 1, 1, 13, 14, 15, 16, 17, 18, + 19, 19, 20, 19, 19, 21, 22, 23, 24, 25, + 19, 26, 27, 19, 19, 19, 28, 19, 19, 19, + 1, 29, 1, 7, 19, 1, 30, 31, 32, 33, + + 34, 35, 36, 37, 38, 1, 39, 40, 41, 42, + 43, 1, 1, 44, 1, 45, 46, 1, 1, 47, + 48, 49, 5, 1, 5, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[50] = + { 0, + 1, 2, 3, 2, 2, 4, 2, 2, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 1, 7, + 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, + 1, 1, 1, 8, 1, 1, 1, 1, 1 + } ; + +static yyconst short int yy_base[167] = + { 0, + 0, 0, 0, 0, 47, 48, 254, 255, 0, 251, + 255, 248, 255, 255, 49, 49, 53, 207, 22, 206, + 33, 205, 27, 29, 36, 31, 46, 44, 47, 42, + 0, 0, 76, 0, 246, 243, 255, 255, 243, 88, + 0, 0, 209, 209, 209, 70, 209, 209, 195, 194, + 206, 202, 192, 192, 196, 0, 77, 81, 255, 230, + 255, 0, 0, 84, 197, 201, 184, 185, 190, 193, + 196, 188, 197, 184, 198, 183, 176, 179, 0, 255, + 184, 172, 180, 181, 172, 166, 172, 168, 176, 179, + 173, 177, 172, 171, 0, 160, 169, 255, 161, 163, + + 255, 97, 167, 155, 162, 255, 157, 255, 255, 0, + 255, 182, 161, 149, 255, 255, 155, 158, 153, 142, + 147, 150, 157, 255, 137, 140, 139, 140, 142, 147, + 146, 255, 128, 117, 115, 129, 129, 82, 255, 92, + 89, 94, 93, 83, 71, 63, 63, 255, 23, 13, + 255, 255, 255, 108, 116, 124, 132, 136, 144, 152, + 160, 164, 167, 169, 171, 173 + } ; + +static yyconst short int yy_def[167] = + { 0, + 154, 154, 153, 3, 155, 155, 153, 153, 156, 153, + 153, 157, 153, 153, 153, 153, 153, 158, 158, 158, + 158, 158, 158, 158, 158, 158, 158, 158, 158, 158, + 156, 159, 160, 156, 153, 157, 153, 153, 161, 153, + 162, 163, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 159, 160, 160, 153, 161, + 153, 162, 164, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 165, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 166, 153, 153, 153, 153, 153, + + 153, 153, 153, 153, 153, 153, 153, 153, 153, 166, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 0, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153 + } ; + +static yyconst short int yy_nxt[305] = + { 0, + 9, 10, 11, 12, 13, 8, 14, 15, 16, 17, + 17, 17, 18, 19, 20, 21, 22, 22, 22, 23, + 24, 25, 26, 22, 27, 28, 29, 30, 31, 8, + 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 9, 11, + 11, 152, 33, 33, 38, 151, 39, 40, 40, 40, + 40, 40, 40, 40, 40, 153, 46, 44, 47, 49, + 153, 48, 153, 50, 153, 51, 153, 52, 55, 153, + 53, 58, 153, 59, 153, 153, 58, 153, 59, 153, + 153, 54, 80, 80, 150, 41, 40, 40, 40, 40, + + 67, 68, 149, 148, 69, 115, 115, 115, 8, 8, + 8, 8, 8, 8, 8, 8, 32, 32, 32, 32, + 32, 32, 32, 32, 34, 147, 146, 145, 144, 143, + 142, 34, 36, 36, 36, 36, 36, 36, 36, 36, + 42, 42, 141, 42, 56, 56, 140, 139, 56, 56, + 56, 56, 57, 57, 138, 57, 57, 57, 57, 57, + 60, 60, 60, 60, 60, 60, 60, 60, 62, 137, + 62, 63, 63, 79, 79, 95, 95, 110, 110, 136, + 135, 134, 133, 132, 131, 130, 129, 128, 127, 126, + 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, + + 114, 113, 112, 111, 109, 108, 107, 106, 105, 104, + 103, 102, 101, 100, 99, 98, 97, 96, 94, 93, + 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, + 82, 81, 61, 78, 77, 76, 75, 74, 73, 72, + 71, 70, 66, 65, 64, 61, 37, 35, 153, 45, + 43, 37, 35, 153, 7, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + + 153, 153, 153, 153 + } ; + +static yyconst short int yy_chk[305] = + { 0, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, + 6, 150, 5, 6, 15, 149, 15, 16, 16, 16, + 16, 17, 17, 17, 17, 19, 21, 19, 23, 25, + 23, 24, 24, 26, 26, 27, 21, 28, 30, 25, + 29, 33, 57, 33, 57, 30, 58, 28, 58, 27, + 29, 29, 64, 64, 147, 16, 40, 40, 40, 40, + + 46, 46, 146, 145, 46, 102, 102, 102, 154, 154, + 154, 154, 154, 154, 154, 154, 155, 155, 155, 155, + 155, 155, 155, 155, 156, 144, 143, 142, 141, 140, + 138, 156, 157, 157, 157, 157, 157, 157, 157, 157, + 158, 158, 137, 158, 159, 159, 136, 135, 159, 159, + 159, 159, 160, 160, 134, 160, 160, 160, 160, 160, + 161, 161, 161, 161, 161, 161, 161, 161, 162, 133, + 162, 163, 163, 164, 164, 165, 165, 166, 166, 131, + 130, 129, 128, 127, 126, 125, 123, 122, 121, 120, + 119, 118, 117, 114, 113, 112, 107, 105, 104, 103, + + 100, 99, 97, 96, 94, 93, 92, 91, 90, 89, + 88, 87, 86, 85, 84, 83, 82, 81, 78, 77, + 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, + 66, 65, 60, 55, 54, 53, 52, 51, 50, 49, + 48, 47, 45, 44, 43, 39, 36, 35, 22, 20, + 18, 12, 10, 7, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + 153, 153, 153, 153, 153, 153, 153, 153, 153, 153, + + 153, 153, 153, 153 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "aslclex.l" +#define INITIAL 0 +#line 2 "aslclex.l" +/*- + * ACPI Source Language Compiler + * + * Copyright (c) 2000 Mitsuru IWASAKI + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include + +#include "aslc.h" +#include "y.tab.h" + +#define ACTION_SERIALIZERULE(value) do { \ + yylval.num = value; \ + return(TOK_SERIALIZERULEKEYWORD); \ +} while (0) + +#define ACTION_VARIABLE(pos, token) do { \ + yylval.num = strtol(&yytext[pos], NULL, 10); \ + return(token); \ +} while (0) + +#define ACTION_INTEGER(base) do { \ + yylval.lit.type = LITERAL_INTEGER; \ + yylval.lit.num.val = strtol(yytext, NULL, base); \ + if (yylval.lit.num.val < 0xff) { \ + return(TOK_BYTECONST); \ + } \ + if (yylval.lit.num.val < 0xffff) { \ + return(TOK_WORDCONST); \ + } \ + return(TOK_DWORDCONST); \ +} while (0) + +int parser_lineno; + +static int comment_start = 1; + +#define CODE 1 + +#define COMMENT 2 + + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 71 "aslclex.l" + + + + if (parser_not_initialized) { + BEGIN(CODE); + parser_lineno = 1; + parser_not_initialized = 0; + } + + + /* + * Newline + */ + + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 154 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 255 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + +do_action: /* This label is used only to access EOF actions. */ + + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yy_hold_char; + yy_cp = yy_last_accepting_cpos; + yy_current_state = yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 85 "aslclex.l" +{ parser_lineno++; } + YY_BREAK +/* + * Comment + */ +/* one-line omment */ +case 2: +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ +yy_c_buf_p = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up yytext again */ +YY_RULE_SETUP +#line 92 "aslclex.l" +; + YY_BREAK +/* normal style comment */ +case 3: +YY_RULE_SETUP +#line 95 "aslclex.l" +{ comment_start = parser_lineno; BEGIN(COMMENT); } + YY_BREAK +case 4: +YY_RULE_SETUP +#line 96 "aslclex.l" +; /* eat anything that's not a '*' */ + YY_BREAK +case 5: +YY_RULE_SETUP +#line 97 "aslclex.l" +; /* eat up '*'s not followed by '/'s */ + YY_BREAK +case 6: +YY_RULE_SETUP +#line 98 "aslclex.l" +{ BEGIN(CODE); } + YY_BREAK +case YY_STATE_EOF(COMMENT): +#line 99 "aslclex.l" +{ + parser_error("unterminated comment " + "beginning from line %d\n", comment_start); + yyterminate(); + } + YY_BREAK +/* + * ASL code + */ +case 7: +YY_RULE_SETUP +#line 109 "aslclex.l" +; + YY_BREAK +case 8: +YY_RULE_SETUP +#line 110 "aslclex.l" +{ return(yytext[0]); } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 112 "aslclex.l" +{ return(TOK_DEFINITIONBLOCK); } + YY_BREAK +/* Named Object */ +case 10: +YY_RULE_SETUP +#line 115 "aslclex.l" +{ return(TOK_CREATEBYTEFIELD); } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 116 "aslclex.l" +{ return(TOK_METHOD); } + YY_BREAK +/* Type1Opcode */ +case 12: +YY_RULE_SETUP +#line 119 "aslclex.l" +{ return(TOK_WHILE); } + YY_BREAK +/* Type2Opcode */ +case 13: +YY_RULE_SETUP +#line 122 "aslclex.l" +{ return(TOK_DECREMENT); } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 123 "aslclex.l" +{ return(TOK_INDEX); } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 124 "aslclex.l" +{ return(TOK_REFOF); } + YY_BREAK +case 16: +YY_RULE_SETUP +#line 125 "aslclex.l" +{ return(TOK_STORE); } + YY_BREAK +/* Keyword */ +case 17: +YY_RULE_SETUP +#line 128 "aslclex.l" +{ ACTION_SERIALIZERULE(1); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 129 "aslclex.l" +{ ACTION_SERIALIZERULE(0); } + YY_BREAK +/* SuperName */ +case 19: +YY_RULE_SETUP +#line 132 "aslclex.l" +{ ACTION_VARIABLE(3, TOK_ARGTERM); } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 133 "aslclex.l" +{ ACTION_VARIABLE(5, TOK_LOCALTERM); } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 134 "aslclex.l" +{ return(TOK_DEBUGTERM); } + YY_BREAK +/* Integer */ +case 22: +YY_RULE_SETUP +#line 137 "aslclex.l" +{ ACTION_INTEGER(16); } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 138 "aslclex.l" +{ ACTION_INTEGER(10); } + YY_BREAK +/* String */ +case 24: +YY_RULE_SETUP +#line 141 "aslclex.l" +{ + size_t i, len; + + len = yyleng - 2; + yylval.lit.type = LITERAL_STRING; + yylval.lit.str.ptr = (char *)malloc(len + 1); + if (yylval.lit.str.ptr == NULL) { + parser_fatal("No more room for String"); + } + strncpy(yylval.lit.str.ptr, &yytext[1], len); + yylval.lit.str.ptr[len] = '\0'; + for (i = 0; i < len; i++) { + if (yylval.lit.str.ptr[i] == '\n') { + parser_lineno++; + } + } + return(TOK_STRING); + } + YY_BREAK +/* DataObject */ +case 25: +YY_RULE_SETUP +#line 161 "aslclex.l" +{ return(TOK_BUFFER); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 162 "aslclex.l" +{ return(TOK_PACKAGE); } + YY_BREAK +/* ASL Names */ +case 27: +YY_RULE_SETUP +#line 165 "aslclex.l" +{ return(yytext[0]); } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 166 "aslclex.l" +{ + yylval.str = strdup(yytext); + return(TOK_NAMESEG); + } + YY_BREAK +/* Error */ +case 29: +YY_RULE_SETUP +#line 171 "aslclex.l" +{ + parser_error("<%s> is too long", yytext); + return(TOK_ERROR); +} + YY_BREAK +case 30: +YY_RULE_SETUP +#line 175 "aslclex.l" +{ + parser_error("<%s> is unexpected", yytext); + return(TOK_ERROR); + } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 179 "aslclex.l" +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(CODE): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 154 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + register char *yy_cp = yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yy_last_accepting_state = yy_current_state; + yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 154 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 153); + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 179 "aslclex.l" + Binary files ../aslc-20001128/aslclex.o and ./aslclex.o differ diff -uN ../aslc-20001128/aslcparse.c ./aslcparse.c --- ../aslc-20001128/aslcparse.c Thu Jan 1 09:00:00 1970 +++ ./aslcparse.c Wed Nov 29 12:41:37 2000 @@ -0,0 +1,1558 @@ +#ifndef lint +static char const +yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $"; +#endif +#include +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYLEX yylex() +#define YYEMPTY -1 +#define yyclearin (yychar=(YYEMPTY)) +#define yyerrok (yyerrflag=0) +#define YYRECOVERING() (yyerrflag!=0) +static int yygrowstack(); +#define YYPREFIX "yy" +#line 2 "aslcparse.y" +/*- + * ACPI Source Language Compiler + * + * Copyright (c) 2000 Mitsuru IWASAKI + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include +#include +#include + +#include "aslc.h" +#include "aslcsymtree.h" + +#ifdef DEBUG +#define YYDEBUG 1 +#define PARSER_DEBUGPRINT(phase, x...) do { \ + if (parser_phase <= phase && parser_debuglevel) { \ + printf(x); \ + } \ +} while (0) + +#else +#define PARSER_DEBUGPRINT(phase, x...) +#endif + +#define PARSER_ENCODING_TERM(code, term...) do { \ + if (parser_phase == 1) { \ + current_state->pkglength++; \ + } \ + snprintf(parser_msgbuf, PARSER_MSGBUFSIZE, term); \ + PARSER_DEBUGPRINT(2, "0x%02x:\t%s:\tat line %d\n", \ + code, parser_msgbuf, parser_lineno); \ +} while (0) + +#define PARSER_ENCODING_PREFIX(val, type) do { \ + int prefix; \ + if (parser_phase == 1) { \ + current_state->pkglength++; \ + } \ + if (type == LITERAL_INTEGER) { \ + if (val < 0xff) { \ + prefix = 0x0a; \ + } else if (val < 0xffff) { \ + prefix = 0x0b; \ + } else { \ + prefix = 0x0c; \ + } \ + } else { \ + prefix = 0x0d; \ + } \ + PARSER_DEBUGPRINT(2, "0x%02x:\tPrefix:\tat line %d\n", \ + prefix, parser_lineno); \ +} while (0) + +#define PARSER_ENCODING_INTEGER(val, bytes, term) do { \ + if (current_state->prefix_expected) { \ + PARSER_ENCODING_PREFIX(val, LITERAL_INTEGER); \ + } \ + switch (bytes) { \ + case 1: \ + PARSER_ENCODING_TERM(val, term); \ + break; \ + case 2: \ + PARSER_ENCODING_TERM((val >> 8) & 0xff, term); \ + PARSER_ENCODING_TERM((val & 0xff), term); \ + break; \ + case 4: \ + PARSER_ENCODING_TERM((val >> 24) & 0xff, term); \ + PARSER_ENCODING_TERM((val >> 16) & 0xff, term); \ + PARSER_ENCODING_TERM((val >> 8) & 0xff, term); \ + PARSER_ENCODING_TERM((val & 0xff), term); \ + break; \ + default: \ + break; \ + } \ +} while (0) + +#define PARSER_BEGINPACKAGE(x...) do { \ + PARSER_DEBUGPRINT(2, "\t<==\t"); \ + PARSER_DEBUGPRINT(2, x); \ + PARSER_DEBUGPRINT(2, "\n"); \ +} while (0) + +#define PARSER_ENDPACKAGE(term) do { \ + u_int8_t code[4]; \ + int len, i; \ + \ + parser_pkglength_fixup(); \ + len = current_state->pkglength; \ + len = parser_pkglength_encoding(len, code); \ + for (i = 0; i < len; i++) { \ + PARSER_DEBUGPRINT(2, "\t===>\t%s:0x%x\n", \ + term, code[i]); \ + } \ + parser_state_pop(); \ +} while (0) + +#define PARSER_PKGLENGTH_FLUSH() do { \ + u_int8_t code[4]; \ + int len, i; \ + \ + len = current_state->pkglength; \ + len = parser_pkglength_encoding(len, code); \ + for (i = 0; i < len; i++) { \ + PARSER_ENCODING_TERM(code[i], "PkgLength"); \ + } \ + if (parser_phase == 1) { \ + current_state->pkglength -= len; \ + } \ +} while (0) + +#define PARSER_SYMTAB_NEW(dest, name, type) do { \ + dest = symtab_find((const char *)name); \ + if (dest != NULL) { \ + snprintf(parser_msgbuf, PARSER_MSGBUFSIZE, \ + "<%s> is already defined", name); \ + yyerror(parser_msgbuf); \ + exit(1); \ + } else { \ + dest = symtab_new((const char *)name, type); \ + } \ +} while (0) + +#define PARSER_SYMTAB_FIND(dest, name, typestr) do { \ + dest = symtab_find((const char *)name); \ + if (dest == NULL) { \ + snprintf(parser_msgbuf, PARSER_MSGBUFSIZE, \ + "%s<%s> is not defined", typestr, name); \ + yyerror(parser_msgbuf); \ + } \ +} while (0) + +#define PARSER_PHASE_FINAL 1 +int parser_phase = 0; +int parser_debuglevel = 0; +int parser_not_initialized = 1; + +#define PARSER_MSGBUFSIZE 256 +static char parser_msgbuf[PARSER_MSGBUFSIZE]; + +static char *aml_filename = NULL; + +struct parser_state { + int method_numargs; + int pkglength; + int pkglength_fixed; + int buffersize; + int buffersize_unknown; + int in_method_interface; + int prefix_expected; +}; + +struct parser_state_list { + TAILQ_ENTRY(parser_state_list) links; + struct parser_state *state; +}; + +TAILQ_HEAD(, parser_state_list)state_list, state_log; +struct parser_state *current_state = NULL; +static void parser_state_push(void); +static void parser_state_pop(void); + +static char *parser_strcat(const char *str1, const char *str2); + +static void parser_scope_enter(const char *name); +static void parser_scope_exit(void); +static char *parser_scope_fullpath(const char *name); + +static int parser_pkglength_encoding(int pkglength, u_int8_t *encoding); +static void parser_pkglength_fixup(void); + +#line 203 "aslcparse.y" +typedef union { + char *str; + u_int32_t num; + union asl_literal lit; + struct asl_symtab *sym; +} YYSTYPE; +#line 224 "y.tab.c" +#define YYERRCODE 256 +#define TOK_DEFINITIONBLOCK 257 +#define TOK_CREATEBYTEFIELD 258 +#define TOK_METHOD 259 +#define TOK_WHILE 260 +#define TOK_DECREMENT 261 +#define TOK_INDEX 262 +#define TOK_REFOF 263 +#define TOK_STORE 264 +#define TOK_SERIALIZERULEKEYWORD 265 +#define TOK_ARGTERM 266 +#define TOK_LOCALTERM 267 +#define TOK_DEBUGTERM 268 +#define TOK_BYTECONST 269 +#define TOK_WORDCONST 270 +#define TOK_DWORDCONST 271 +#define TOK_STRING 272 +#define TOK_BUFFER 273 +#define TOK_PACKAGE 274 +#define TOK_NAMESEG 275 +#define TOK_ERROR 276 +const short yylhs[] = { -1, + 18, 0, 17, 21, 19, 20, 20, 23, 23, 23, + 27, 27, 24, 24, 29, 29, 29, 32, 32, 35, + 1, 1, 34, 34, 37, 37, 36, 36, 36, 36, + 36, 25, 26, 26, 26, 28, 28, 2, 44, 45, + 3, 4, 46, 5, 5, 6, 6, 48, 40, 47, + 41, 49, 51, 52, 53, 53, 42, 54, 43, 55, + 7, 50, 50, 50, 50, 50, 38, 39, 56, 33, + 33, 33, 8, 9, 10, 11, 60, 30, 57, 58, + 58, 59, 59, 61, 61, 62, 62, 31, 63, 64, + 64, 65, 65, 67, 67, 66, 66, 68, 12, 13, + 13, 14, 14, 15, 15, 16, 16, 22, +}; +const short yylen[] = { 2, + 0, 5, 14, 0, 2, 1, 2, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 0, + 5, 1, 1, 2, 1, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 8, 1, 0, + 5, 6, 1, 1, 2, 1, 2, 0, 8, 1, + 4, 1, 7, 1, 1, 2, 4, 1, 6, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 8, 1, 1, + 1, 1, 1, 1, 2, 1, 3, 7, 1, 1, + 1, 1, 2, 1, 3, 1, 1, 1, 1, 2, + 2, 1, 2, 1, 2, 1, 3, 0, +}; +const short yydefred[] = { 1, + 0, 0, 0, 0, 0, 4, 76, 0, 0, 0, + 0, 2, 39, 43, 50, 52, 58, 60, 98, 0, + 14, 36, 37, 0, 0, 0, 5, 0, 0, 8, + 9, 10, 13, 32, 33, 34, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 103, 102, 40, 20, 99, + 0, 101, 104, 7, 0, 0, 0, 0, 0, 0, + 100, 0, 0, 0, 0, 105, 106, 67, 68, 73, + 74, 75, 79, 89, 29, 70, 71, 72, 19, 27, + 28, 15, 16, 17, 18, 0, 30, 31, 0, 0, + 0, 0, 54, 69, 62, 63, 64, 0, 66, 0, + 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 44, 0, 51, 0, 57, 0, + 0, 41, 21, 0, 25, 24, 107, 0, 0, 81, + 0, 91, 90, 0, 45, 0, 0, 46, 48, 0, + 0, 0, 0, 0, 0, 0, 61, 47, 42, 0, + 0, 59, 0, 26, 0, 77, 0, 0, 0, 0, + 38, 0, 97, 0, 96, 0, 0, 49, 0, 55, + 0, 0, 0, 82, 84, 0, 83, 88, 0, 94, + 93, 56, 53, 0, 0, 86, 85, 78, 0, 3, + 0, 95, 87, +}; +const short yydgoto[] = { 1, + 75, 22, 23, 24, 114, 137, 148, 76, 77, 78, + 79, 51, 25, 26, 52, 66, 4, 2, 9, 27, + 10, 47, 29, 30, 31, 80, 0, 33, 81, 82, + 83, 84, 85, 107, 64, 86, 126, 87, 88, 34, + 35, 36, 37, 38, 63, 39, 40, 150, 41, 98, + 99, 100, 171, 42, 43, 101, 89, 131, 176, 162, + 177, 187, 90, 134, 166, 167, 181, 44, +}; +const short yysindex[] = { 0, + 0, -223, 15, -83, -231, 0, 0, 16, -81, 26, + -231, 0, 0, 0, 0, 0, 0, 0, 0, -21, + 0, 0, 0, -57, 29, -208, 0, 0, 26, 0, + 0, 0, 0, 0, 0, 0, 0, 30, 39, 41, + 42, 43, 44, -208, 45, 0, 0, 0, 0, 0, + 51, 0, 0, 0, -65, -29, -65, -14, -14, -65, + 0, -182, 26, -65, -208, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 54, 0, 0, 48, 59, + 58, 63, 0, 0, 0, 0, 0, 65, 0, 67, + 0, 69, 64, 70, -12, 0, 74, 72, 51, -65, + -65, -182, -182, 73, 0, -4, 0, -65, 0, -14, + -231, 0, 0, -65, 0, 0, 0, 80, 0, 0, + 87, 0, 0, 89, 0, -154, 90, 0, 0, 88, + 95, 93, 72, -29, 17, 18, 0, 0, 0, 26, + -65, 0, -231, 0, 97, 0, -59, 14, 99, 100, + 0, -230, 0, 0, 0, 20, 103, 0, -14, 0, + 107, -119, 106, 0, 0, 31, 0, 0, -59, 0, + 0, 0, 0, 112, -182, 0, 0, 0, 103, 0, + 106, 0, 0, +}; +const short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -30, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -33, + 0, 0, 0, 0, 2, 9, 0, -20, -30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, + -40, 0, 0, 0, -26, -16, -19, -24, -24, -26, + 0, 0, -30, -38, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -28, 0, 113, -40, -26, + -19, 113, 0, 113, 0, 0, 0, -26, 0, -24, + 0, 0, 0, -38, 0, 0, 0, 0, -17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 113, -24, 0, 0, 0, 0, 0, -30, + -38, 0, 0, 0, 0, 0, -39, 0, 113, 0, + 0, 34, 0, -25, 0, 0, 34, 0, -24, 0, + 0, 0, 34, 0, 0, 0, 0, 0, -39, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, + 34, 0, 0, +}; +const short yygindex[] = { 0, + 27, 0, 0, 0, 0, 0, 0, -36, 0, -9, + 4, 102, -11, 135, 116, 55, 0, 0, 0, 1, + 0, 254, 0, 0, 0, 28, 0, 0, -121, 0, + 0, 0, 0, 0, 0, 11, 22, -27, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -22, 0, 0, 0, -6, -18, 0, +}; +#define YYTABLESIZE 445 +const short yytable[] = { 108, + 108, 108, 108, 108, 108, 108, 108, 108, 8, 108, + 108, 102, 23, 108, 45, 102, 108, 108, 102, 102, + 108, 108, 102, 80, 108, 104, 19, 108, 20, 54, + 96, 96, 19, 3, 20, 165, 21, 32, 70, 6, + 7, 7, 22, 12, 91, 22, 95, 95, 108, 108, + 102, 108, 108, 108, 5, 21, 32, 165, 108, 11, + 97, 97, 19, 105, 20, 48, 50, 92, 49, 55, + 103, 102, 20, 102, 108, 132, 135, 19, 56, 20, + 57, 58, 59, 60, 108, 108, 70, 111, 62, 21, + 32, 108, 96, 22, 108, 22, 65, 110, 112, 92, + 108, 113, 108, 116, 6, 117, 118, 120, 95, 119, + 147, 141, 122, 121, 123, 124, 136, 19, 139, 20, + 128, 130, 97, 144, 142, 173, 22, 145, 140, 146, + 149, 151, 155, 108, 143, 152, 153, 161, 168, 156, + 157, 96, 169, 172, 178, 163, 179, 183, 191, 185, + 158, 72, 190, 108, 46, 188, 160, 95, 108, 61, + 182, 159, 184, 127, 154, 174, 109, 163, 193, 0, + 192, 97, 189, 0, 0, 0, 21, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 17, 18, 0, + 68, 69, 0, 70, 71, 72, 7, 73, 74, 70, + 71, 72, 7, 73, 74, 0, 0, 108, 108, 108, + 108, 0, 108, 108, 108, 108, 108, 108, 0, 108, + 108, 0, 0, 0, 108, 108, 108, 102, 102, 102, + 102, 108, 102, 102, 108, 0, 102, 93, 108, 102, + 108, 68, 69, 94, 102, 108, 0, 102, 108, 22, + 22, 22, 22, 28, 22, 22, 108, 108, 108, 108, + 0, 108, 108, 0, 0, 0, 22, 0, 0, 53, + 0, 0, 28, 13, 14, 15, 16, 0, 17, 18, + 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, + 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 28, 106, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 115, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 125, 67, 0, 129, 133, 0, 138, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 125, 0, 0, 0, + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + 164, 0, 170, 0, 0, 175, 0, 0, 0, 0, + 180, 0, 0, 0, 0, 0, 186, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 180, 0, 186, +}; +const short yycheck[] = { 40, + 41, 40, 41, 44, 44, 44, 40, 41, 5, 40, + 44, 40, 41, 40, 11, 44, 41, 44, 44, 40, + 40, 41, 40, 41, 41, 62, 92, 44, 94, 29, + 58, 59, 92, 257, 94, 157, 10, 10, 269, 123, + 272, 272, 41, 125, 56, 44, 58, 59, 40, 41, + 59, 92, 44, 94, 40, 29, 29, 179, 92, 44, + 58, 59, 92, 63, 94, 123, 275, 57, 40, 40, + 60, 92, 94, 94, 64, 112, 113, 92, 40, 94, + 40, 40, 40, 40, 125, 125, 269, 40, 44, 63, + 63, 125, 120, 92, 125, 94, 46, 44, 40, 125, + 92, 44, 94, 41, 125, 41, 40, 44, 120, 41, + 265, 120, 125, 44, 41, 44, 44, 92, 123, 94, + 110, 111, 120, 44, 121, 162, 125, 41, 118, 41, + 41, 44, 144, 125, 124, 41, 44, 41, 125, 123, + 123, 169, 44, 44, 125, 157, 44, 41, 185, 44, + 150, 271, 41, 41, 20, 125, 153, 169, 125, 44, + 169, 151, 172, 109, 143, 162, 65, 179, 191, -1, + 189, 169, 179, -1, -1, -1, 150, 150, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 261, -1, 263, 264, -1, + 266, 267, -1, 269, 270, 271, 272, 273, 274, 269, + 270, 271, 272, 273, 274, -1, -1, 258, 259, 260, + 261, -1, 263, 264, 258, 259, 260, 261, -1, 263, + 264, -1, -1, -1, 275, 275, 275, 258, 259, 260, + 261, 275, 263, 264, 275, -1, 275, 262, 275, 275, + 275, 266, 267, 268, 275, 275, -1, 275, 275, 258, + 259, 260, 261, 10, 263, 264, 258, 259, 260, 261, + -1, 263, 264, -1, -1, -1, 275, -1, -1, 26, + -1, -1, 29, 258, 259, 260, 261, -1, 263, 264, + -1, -1, -1, -1, -1, -1, -1, 44, -1, -1, + -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 63, 64, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 108, 109, -1, 111, 112, -1, 114, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, + -1, -1, -1, 150, -1, -1, -1, -1, -1, -1, + 157, -1, 159, -1, -1, 162, -1, -1, -1, -1, + 167, -1, -1, -1, -1, -1, 173, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 189, -1, 191, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 276 +#if YYDEBUG +const char * const yyname[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'('","')'",0,0,"','",0,"'.'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'\\\\'",0,"'^'",0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,"TOK_DEFINITIONBLOCK","TOK_CREATEBYTEFIELD","TOK_METHOD","TOK_WHILE", +"TOK_DECREMENT","TOK_INDEX","TOK_REFOF","TOK_STORE","TOK_SERIALIZERULEKEYWORD", +"TOK_ARGTERM","TOK_LOCALTERM","TOK_DEBUGTERM","TOK_BYTECONST","TOK_WORDCONST", +"TOK_DWORDCONST","TOK_STRING","TOK_BUFFER","TOK_PACKAGE","TOK_NAMESEG", +"TOK_ERROR", +}; +const char * const yyrule[] = { +"$accept : ASLCode", +"$$1 :", +"ASLCode : $$1 DefinitionBlockTerm '{' ASLTermList '}'", +"DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' String ',' DWordConst ')'", +"$$2 :", +"ASLTermList : $$2 TermList", +"TermList : Nothing", +"TermList : Term TermList", +"Term : Object", +"Term : Type1Opcode", +"Term : Type2Opcode", +"ObjectList : Nothing", +"ObjectList : Object ObjectList", +"Object : NamedObject", +"Object : UserTerm", +"DataObject : BufferTerm", +"DataObject : PackageTerm", +"DataObject : LiteralData", +"LiteralData : Integer", +"LiteralData : String", +"$$3 :", +"UserTerm : NameString '(' $$3 ArgList ')'", +"UserTerm : NameString", +"ArgList : Nothing", +"ArgList : TermArg ArgListTail", +"ArgListTail : Nothing", +"ArgListTail : ',' TermArg ArgListTail", +"TermArg : Type2Opcode", +"TermArg : DataObject", +"TermArg : UserTerm", +"TermArg : ArgTerm", +"TermArg : LocalTerm", +"Type1Opcode : WhileTerm", +"Type2Opcode : DecTerm", +"Type2Opcode : RefOfTerm", +"Type2Opcode : StoreTerm", +"NamedObject : CreateByteFieldTerm", +"NamedObject : MethodTerm", +"CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' TermArg ',' NameString ')'", +"CreateByteFieldDenotation : TOK_CREATEBYTEFIELD", +"$$4 :", +"MethodTerm : MethodInterface '{' $$4 TermList '}'", +"MethodInterface : MethodDenotation '(' NameString MethodNumArgs MethodSerializeRule ')'", +"MethodDenotation : TOK_METHOD", +"MethodNumArgs : Nothing", +"MethodNumArgs : ',' ByteConst", +"MethodSerializeRule : Nothing", +"MethodSerializeRule : ',' SerializeRuleKeyword", +"$$5 :", +"WhileTerm : WhileDenotation '(' TermArg ')' '{' $$5 TermList '}'", +"WhileDenotation : TOK_WHILE", +"DecTerm : DecrementDenotation '(' SuperName ')'", +"DecrementDenotation : TOK_DECREMENT", +"IndexTerm : IndexDenotation '(' TermArg ',' TermArg IndexDestination ')'", +"IndexDenotation : TOK_INDEX", +"IndexDestination : Nothing", +"IndexDestination : ',' SuperName", +"RefOfTerm : RefOfDenotation '(' SuperName ')'", +"RefOfDenotation : TOK_REFOF", +"StoreTerm : StoreDenotation '(' TermArg ',' SuperName ')'", +"StoreDenotation : TOK_STORE", +"SerializeRuleKeyword : TOK_SERIALIZERULEKEYWORD", +"SuperName : NameString", +"SuperName : ArgTerm", +"SuperName : LocalTerm", +"SuperName : DebugTerm", +"SuperName : IndexTerm", +"ArgTerm : TOK_ARGTERM", +"LocalTerm : TOK_LOCALTERM", +"DebugTerm : TOK_DEBUGTERM", +"Integer : ByteConst", +"Integer : WordConst", +"Integer : DWordConst", +"ByteConst : TOK_BYTECONST", +"WordConst : TOK_WORDCONST", +"DWordConst : TOK_DWORDCONST", +"String : TOK_STRING", +"$$6 :", +"BufferTerm : BufferDenotation '(' BufferSize ')' '{' $$6 BufferBlock '}'", +"BufferDenotation : TOK_BUFFER", +"BufferSize : Nothing", +"BufferSize : TermArg", +"BufferBlock : String", +"BufferBlock : ByteList", +"ByteList : Nothing", +"ByteList : ByteConst ByteListTail", +"ByteListTail : Nothing", +"ByteListTail : ',' ByteConst ByteListTail", +"PackageTerm : PackageDenotation '(' PackageNumElements ')' '{' PackageList '}'", +"PackageDenotation : TOK_PACKAGE", +"PackageNumElements : Nothing", +"PackageNumElements : ByteConst", +"PackageList : Nothing", +"PackageList : PackageElement PackageListTail", +"PackageListTail : Nothing", +"PackageListTail : ',' PackageElement PackageListTail", +"PackageElement : DataObject", +"PackageElement : NameString", +"RootChar : '\\\\'", +"NameSeg : TOK_NAMESEG", +"NameString : RootChar NamePath", +"NameString : PrefixPath NamePath", +"PrefixPath : Nothing", +"PrefixPath : '^' PrefixPath", +"NamePath : Nothing", +"NamePath : NameSeg NamePathTail", +"NamePathTail : Nothing", +"NamePathTail : '.' NameSeg NamePathTail", +"Nothing :", +}; +#endif +#if YYDEBUG +#include +#endif +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif +#define YYINITSTACKSIZE 200 +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short *yyss; +short *yysslim; +YYSTYPE *yyvs; +int yystacksize; +#line 834 "aslcparse.y" + +static char * +parser_strcat(const char *str1, const char *str2) +{ + char *str; + size_t len; + + len = ((str1 == NULL) ? 0 : strlen(str1)) + + ((str2 == NULL) ? 0 : strlen(str2)) + 1; + + if ((str = (char *)malloc(len)) == NULL) { + parser_fatal("No more room for strcat"); + } + + bzero(str, len); + if (str1 != NULL) { + strncpy(str, str1, strlen(str1)); + } + if (str2 != NULL) { + strcat(str, str2); + } + + return(str); +} + +static int +parser_pkglength_encoding(int pkglength, u_int8_t *encoding) +{ + int len; + u_int8_t code[4]; + + len = 0; + bzero(code, sizeof(code)); + if (pkglength <= 0x0000003f) { /* 6bit */ + len = 1; + code[0] = pkglength; + goto out; + } + if (pkglength <= 0x00000fff) { /* 12bit */ + len = 2; + code[0] = (1 << 6) + (pkglength & 0xf); + code[1] = (pkglength >> 4) & 0xff; + goto out; + } + if (pkglength <= 0x000fffff) { /* 20bit */ + len = 3; + code[0] = (2 << 6) + (pkglength & 0xf); + code[1] = (pkglength >> 4) & 0xff; + code[2] = (pkglength >> 12) & 0xff; + goto out; + } + if (pkglength <= 0x0fffffff) { /* 28bit */ + len = 4; + code[0] = (3 << 6) + (pkglength & 0xf); + code[1] = (pkglength >> 4) & 0xff; + code[2] = (pkglength >> 12) & 0xff; + code[3] = (pkglength >> 20) & 0xff; + goto out; + } +out: + if (encoding != NULL) { + bcopy(code, encoding, sizeof(code)); + } + return(len); +} + +static void +parser_pkglength_fixup(void) +{ + int pkglength; + + if (current_state->pkglength_fixed == 0) { + pkglength = current_state->pkglength; + pkglength += parser_pkglength_encoding(pkglength, NULL); + current_state->pkglength = pkglength; + current_state->pkglength_fixed = 1; + } +} + +static __inline void +parser_state_init() +{ + static int first = 1; + + if (first) { + TAILQ_INIT(&state_list); + TAILQ_INIT(&state_log); + first = 0; + } +} + +static void +parser_state_push(void) +{ + struct parser_state *new_state; + struct parser_state_list *state_entry, *entry_log; + + parser_state_init(); + switch (parser_phase) { + case 1: + new_state = (struct parser_state *)malloc(sizeof(struct parser_state)); + if (new_state == NULL) { + parser_fatal("No room for parser_state."); + } + bzero(new_state, sizeof(struct parser_state)); + state_entry = (struct parser_state_list *)malloc(sizeof(struct parser_state_list)); + if (state_entry == NULL) { + parser_fatal("No room for parser_state_list."); + } + entry_log = (struct parser_state_list *)malloc(sizeof(struct parser_state_list)); + if (entry_log == NULL) { + parser_fatal("No room for parser_state_list."); + } + + state_entry->state = entry_log->state = new_state; + + TAILQ_INSERT_TAIL(&state_log, entry_log, links); + break; + default: + state_entry = TAILQ_FIRST(&state_log); + TAILQ_REMOVE(&state_log, state_entry, links); + TAILQ_INSERT_TAIL(&state_log, state_entry, links); + break; + } + TAILQ_INSERT_HEAD(&state_list, state_entry, links); + current_state = state_entry->state; +} + +static void +parser_state_pop(void) +{ + int pkglength; + struct parser_state_list *state_entry; + + parser_state_init(); + pkglength = current_state->pkglength; + state_entry = TAILQ_FIRST(&state_list); + TAILQ_REMOVE(&state_list, state_entry, links); + if (parser_phase == 1) { + free(state_entry); + } + + state_entry = TAILQ_FIRST(&state_list); + current_state = state_entry->state; + if (parser_phase == 1) { + current_state->pkglength += pkglength; + } +} + +struct parser_scope { + TAILQ_ENTRY(parser_scope) links; + char *name; +}; +TAILQ_HEAD(, parser_scope) scope_list; + +static __inline void +parser_scope_init() +{ + static int first = 1; + + if (first) { + TAILQ_INIT(&scope_list); + first = 0; + } +} + +static void +parser_scope_enter(const char *name) +{ + struct parser_scope *new_entry; + + parser_scope_init(); + + if ((new_entry = malloc(sizeof(struct parser_scope))) == NULL) { + parser_fatal("No more room for parser_scope."); + } + + bzero(new_entry, sizeof(struct parser_scope)); + new_entry->name = strdup(name); + TAILQ_INSERT_HEAD(&scope_list, new_entry, links); +} + +static void +parser_scope_exit(void) +{ + struct parser_scope *entry; + + parser_scope_init(); + entry = TAILQ_FIRST(&scope_list); + TAILQ_REMOVE(&scope_list, entry, links); + free(entry->name); + free(entry); +} + +static char * +parser_scope_fullpath(const char *name) +{ + struct parser_scope *entry; + static char fullpath[PARSER_MSGBUFSIZE]; + + parser_scope_init(); + bzero(fullpath, sizeof(fullpath)); + TAILQ_FOREACH(entry, &scope_list, links) { + snprintf(fullpath, sizeof(fullpath), "%s%s.", fullpath, entry->name); + } + snprintf(fullpath, sizeof(fullpath), "%s%s", fullpath, name); + return(fullpath); +} + +void +yyerror(const char *msg) +{ + + fprintf(stderr, "line %d: %s\n", parser_lineno, msg); +} + +#define PARSER_WARN(msg) do { \ + va_list ap; \ + va_start(ap, msg); \ + vsnprintf(parser_msgbuf, PARSER_MSGBUFSIZE, msg, ap); \ + va_end(ap); \ + yyerror(parser_msgbuf); \ +} while (0) + +void +parser_warn(const char *msg, ...) +{ + PARSER_WARN(msg); +} + +void +parser_error(const char *msg, ...) +{ + PARSER_WARN(msg); + exit(1); +} + +void +parser_fatal(const char *msg, ...) +{ + PARSER_WARN(msg); + abort(); +} + +extern FILE *yyin; + +void +parser_main(const char *asl_filename) +{ + + if ((yyin = fopen(asl_filename, "r")) == NULL) { + (void) err(1, "cannot open ASL file"); + } + + for (parser_phase = 1; parser_phase <= PARSER_PHASE_FINAL; parser_phase++) { + parser_lineno = 1; + if (parser_debuglevel) { + printf("==== PARSER PHASE %d ====\n", parser_phase); + } + + if (yyparse() != 0) { + fprintf(stderr, "ASL parser errors in phase %d\n", parser_phase); + exit(1); + } + + switch (parser_phase) { + case 1: + symtab_dump(); + symtree_dump(symtree_getroot(), 0); + break; + default: + break; + } + + rewind(yyin); + } + + fclose(yyin); + symtab_destroy(); +} +#line 891 "y.tab.c" +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack() +{ + int newsize, i; + short *newss; + YYSTYPE *newvs; + + if ((newsize = yystacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return -1; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + i = yyssp - yyss; + newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : + (short *)malloc(newsize * sizeof *newss); + if (newss == NULL) + return -1; + yyss = newss; + yyssp = newss + i; + newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : + (YYSTYPE *)malloc(newsize * sizeof *newvs); + if (newvs == NULL) + return -1; + yyvs = newvs; + yyvsp = newvs + i; + yystacksize = newsize; + yysslim = yyss + newsize - 1; + return 0; +} + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab + +#ifndef YYPARSE_PARAM +#if defined(__cplusplus) || __STDC__ +#define YYPARSE_PARAM_ARG void +#define YYPARSE_PARAM_DECL +#else /* ! ANSI-C/C++ */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* ANSI-C/C++ */ +#else /* YYPARSE_PARAM */ +#ifndef YYPARSE_PARAM_TYPE +#define YYPARSE_PARAM_TYPE void * +#endif +#if defined(__cplusplus) || __STDC__ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* ! ANSI-C/C++ */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM; +#endif /* ANSI-C/C++ */ +#endif /* ! YYPARSE_PARAM */ + +int +yyparse (YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yym, yyn, yystate; +#if YYDEBUG + register const char *yys; + + if ((yys = getenv("YYDEBUG"))) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + if (yyss == NULL && yygrowstack()) goto yyoverflow; + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if ((yyn = yydefred[yystate])) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#if defined(lint) || defined(__GNUC__) + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#if defined(lint) || defined(__GNUC__) + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 1: +#line 271 "aslcparse.y" +{ + parser_state_push(); + + symtree_moveptr(symtree_new(0, "DefinitionBlockTerm")); + } +break; +case 2: +#line 277 "aslcparse.y" +{ + PARSER_ENDPACKAGE("ASLTermList"); + + symtree_upptr(); + } +break; +case 3: +#line 286 "aslcparse.y" +{ + PARSER_DEBUGPRINT(1, "DefinitionBlock ("); + PARSER_DEBUGPRINT(1, "\"%s\", \"%s\", 0x%x, \"%s\", \"%s\", 0x%x)\n", + yyvsp[-11].lit.str.ptr, yyvsp[-9].lit.str.ptr, + yyvsp[-7].lit.num.val, yyvsp[-5].lit.str.ptr, + yyvsp[-3].lit.str.ptr, yyvsp[-1].lit.num.val); + + switch (parser_phase) { + case 1: + aml_filename = strdup(yyvsp[-11].lit.str.ptr); + break; + default: + break; + } + + free(yyvsp[-11].lit.str.ptr); + free(yyvsp[-9].lit.str.ptr); + free(yyvsp[-5].lit.str.ptr); + free(yyvsp[-3].lit.str.ptr); + + symtree_upptr(); + } +break; +case 4: +#line 311 "aslcparse.y" +{ + parser_state_push(); + PARSER_BEGINPACKAGE("ASLTermList"); + + symtree_moveptr(symtree_new(0, "ASLTermList")); + } +break; +case 20: +#line 346 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "UserTermMethod")); } +break; +case 21: +#line 348 "aslcparse.y" +{ + int numargs; + if (parser_phase == 2) { + PARSER_SYMTAB_FIND(yyval.sym, yyvsp[-4].str, "Method"); + if (yyval.sym == NULL) { + goto userterm_out; + } + numargs = symtab_method_getnumargs(yyval.sym); + if (numargs != current_state->method_numargs) { + parser_error("number of args is wrong for %s\n", yyvsp[-4].str); + } + } + userterm_out: + current_state->method_numargs = 0; + free(yyvsp[-4].str); + + symtree_upptr(); + } +break; +case 22: +#line 367 "aslcparse.y" +{ + if (parser_phase == 2) { + PARSER_SYMTAB_FIND(yyval.sym, + parser_scope_fullpath(yyvsp[0].str), "Object"); + } + free(yyvsp[0].str); + } +break; +case 24: +#line 378 "aslcparse.y" +{ current_state->method_numargs++; } +break; +case 26: +#line 383 "aslcparse.y" +{ current_state->method_numargs++; } +break; +case 38: +#line 408 "aslcparse.y" +{ + if (parser_phase == 1) { + PARSER_SYMTAB_NEW(yyval.sym, parser_scope_fullpath(yyvsp[-1].str), SYM_FIELD); + } + free(yyvsp[-1].str); + + symtree_upptr(); + } +break; +case 39: +#line 420 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x8c, "CreateByteField"); + + symtree_moveptr(symtree_new(0, "CreateByteField")); + } +break; +case 40: +#line 429 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "MethodTermList")); } +break; +case 41: +#line 431 "aslcparse.y" +{ + yyval.sym = yyvsp[-4].sym; + PARSER_ENDPACKAGE("Method"); + parser_scope_exit(); + + symtree_upptr(); + symtree_upptr(); + } +break; +case 42: +#line 443 "aslcparse.y" +{ + current_state->in_method_interface = 0; + PARSER_ENCODING_TERM((yyvsp[-2].num | yyvsp[-1].num << 3), "MethodFlags"); + if (parser_phase == 1) { + PARSER_SYMTAB_NEW(yyval.sym, parser_scope_fullpath(yyvsp[-3].str), SYM_METHOD); + symtab_method_setflags(yyval.sym, (int)(yyvsp[-2].num | yyvsp[-1].num << 3)); + } + parser_scope_enter(yyvsp[-3].str); + free(yyvsp[-3].str); + } +break; +case 43: +#line 457 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x14, "Method"); + PARSER_BEGINPACKAGE("Method"); + parser_state_push(); + PARSER_PKGLENGTH_FLUSH(); + current_state->in_method_interface = 1; + + symtree_moveptr(symtree_new(0, "Method")); + + } +break; +case 44: +#line 470 "aslcparse.y" +{ yyval.num = 0; } +break; +case 45: +#line 471 "aslcparse.y" +{ yyval.num = yyvsp[0].lit.num.val; } +break; +case 46: +#line 475 "aslcparse.y" +{ yyval.num = 0; } +break; +case 47: +#line 476 "aslcparse.y" +{ yyval.num = yyvsp[0].num; } +break; +case 48: +#line 485 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "WhileTermList")); } +break; +case 49: +#line 487 "aslcparse.y" +{ + PARSER_ENDPACKAGE("While"); + + symtree_upptr(); + symtree_upptr(); + } +break; +case 50: +#line 497 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0xa2, "While"); + PARSER_BEGINPACKAGE("While"); + parser_state_push(); + PARSER_PKGLENGTH_FLUSH(); + + symtree_moveptr(symtree_new(0, "While")); + } +break; +case 51: +#line 513 "aslcparse.y" +{ + symtree_upptr(); + } +break; +case 52: +#line 520 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x76, "Decrement"); + + symtree_moveptr(symtree_new(0, "Decrement")); + } +break; +case 54: +#line 533 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x88, "Index"); + } +break; +case 58: +#line 549 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x71, "RefOf"); + } +break; +case 59: +#line 556 "aslcparse.y" +{ + current_state->prefix_expected = 0; + + symtree_upptr(); + } +break; +case 60: +#line 565 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x70, "Store"); + current_state->prefix_expected = 1; + + symtree_moveptr(symtree_new(0, "Store")); + } +break; +case 61: +#line 578 "aslcparse.y" +{ yyval.num = yyvsp[0].num; } +break; +case 67: +#line 591 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x68 + yyvsp[0].num, "Arg%d", yyvsp[0].num); + + symtree_new(0, "ArgX"); + } +break; +case 68: +#line 600 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x60 + yyvsp[0].num, "Local%d", yyvsp[0].num); + + symtree_new(0, "LocalX"); + } +break; +case 73: +#line 621 "aslcparse.y" +{ + yyval.lit = yyvsp[0].lit; + if (current_state->in_method_interface == 0) { + PARSER_ENCODING_INTEGER(yyval.lit.num.val, + 1, "ByteConst"); + } + + symtree_new(0, "ByteConst"); + } +break; +case 74: +#line 634 "aslcparse.y" +{ + yyval.lit = yyvsp[0].lit; + PARSER_ENCODING_INTEGER(yyval.lit.num.val, 2, "WordConst"); + + symtree_new(0, "WordConst"); + } +break; +case 75: +#line 644 "aslcparse.y" +{ + yyval.lit = yyvsp[0].lit; + PARSER_ENCODING_INTEGER(yyval.lit.num.val, 4, "DWordConst"); + + symtree_new(0, "DWordConst"); + } +break; +case 76: +#line 658 "aslcparse.y" +{ + char *ptr; + yyval.lit = yyvsp[0].lit; + PARSER_DEBUGPRINT(2, "\tString<%s>:\tat line %d\n", + yyval.lit.str.ptr, parser_lineno); + if (current_state->prefix_expected) { + PARSER_ENCODING_PREFIX(0, LITERAL_STRING); + } + ptr = yyval.lit.str.ptr; + while (*ptr) { + PARSER_ENCODING_TERM(*ptr, "String"); + ptr++; + } + PARSER_ENCODING_TERM(0x00, "StringTermination"); + + symtree_new(0, yyval.lit.str.ptr); + } +break; +case 77: +#line 683 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "BufferBlock")); } +break; +case 78: +#line 685 "aslcparse.y" +{ + if (parser_phase == 1 && current_state->buffersize_unknown) { + current_state->buffersize = current_state->pkglength; + /* to adjust pkglength of the Buffer */ + current_state->prefix_expected = 1; + PARSER_ENCODING_INTEGER(current_state->buffersize, + 1, "BufferSize"); /* XXX */ + current_state->prefix_expected = 0; + } + + PARSER_ENDPACKAGE("Buffer"); + + symtree_upptr(); + symtree_upptr(); + } +break; +case 79: +#line 704 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x11, "Buffer"); + PARSER_BEGINPACKAGE("Buffer"); + parser_state_push(); + PARSER_PKGLENGTH_FLUSH(); + if (current_state->buffersize) { + current_state->prefix_expected = 1; + PARSER_ENCODING_INTEGER(current_state->buffersize, + 1, "BufferSize"); /* XXX */ + current_state->prefix_expected = 0; + } else { + current_state->prefix_expected = 1; + } + + symtree_moveptr(symtree_new(0, "Buffer")); + } +break; +case 80: +#line 724 "aslcparse.y" +{ + current_state->buffersize_unknown = 1; + current_state->prefix_expected = 0; + } +break; +case 81: +#line 728 "aslcparse.y" +{ current_state->prefix_expected = 0; } +break; +case 99: +#line 776 "aslcparse.y" +{ yyval.str = yyvsp[0].str; } +break; +case 100: +#line 781 "aslcparse.y" +{ + yyval.str = parser_strcat("\\", yyvsp[0].str); + free(yyvsp[0].str); + goto namestring_out; + } +break; +case 101: +#line 787 "aslcparse.y" +{ + char *ptr; + yyval.str = parser_strcat(yyvsp[-1].str, yyvsp[0].str); + free(yyvsp[-1].str); + free(yyvsp[0].str); + namestring_out: + PARSER_DEBUGPRINT(2, "\tNameString<%s>:\tat line %d\n", + yyval.str, parser_lineno); + ptr = yyval.str; + while (*ptr) { + PARSER_ENCODING_TERM(*ptr, "NameString"); + ptr++; + } + + symtree_new(0, yyval.str); + } +break; +case 102: +#line 806 "aslcparse.y" +{ yyval.str = NULL; } +break; +case 103: +#line 807 "aslcparse.y" +{ yyval.str = parser_strcat("^", yyvsp[0].str); free(yyvsp[0].str); } +break; +case 104: +#line 811 "aslcparse.y" +{ yyval.str = NULL; } +break; +case 105: +#line 812 "aslcparse.y" +{ yyval.str = parser_strcat(yyvsp[-1].str, yyvsp[0].str); free(yyvsp[-1].str); free(yyvsp[0].str); } +break; +case 106: +#line 816 "aslcparse.y" +{ yyval.str = NULL; } +break; +case 107: +#line 818 "aslcparse.y" +{ + yyval.str = parser_strcat(".", parser_strcat(yyvsp[-1].str, yyvsp[0].str)); + free(yyvsp[-1].str); + free(yyvsp[0].str); + } +break; +#line 1503 "y.tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} Binary files ../aslc-20001128/aslcparse.o and ./aslcparse.o differ diff -uN ../aslc-20001128/aslcparse.y ./aslcparse.y --- ../aslc-20001128/aslcparse.y Tue Nov 28 09:39:05 2000 +++ ./aslcparse.y Wed Nov 29 12:40:08 2000 @@ -38,6 +38,7 @@ #include #include "aslc.h" +#include "aslcsymtree.h" #ifdef DEBUG #define YYDEBUG 1 @@ -158,7 +159,7 @@ } \ } while (0) -#define PARSER_PHASE_FINAL 2 +#define PARSER_PHASE_FINAL 1 int parser_phase = 0; int parser_debuglevel = 0; int parser_not_initialized = 1; @@ -267,10 +268,16 @@ %% ASLCode - : { parser_state_push(); } + : { + parser_state_push(); + + symtree_moveptr(symtree_new(0, "DefinitionBlockTerm")); + } DefinitionBlockTerm '{' ASLTermList '}' { PARSER_ENDPACKAGE("ASLTermList"); + + symtree_upptr(); } ; @@ -295,11 +302,18 @@ free($5.str.ptr); free($9.str.ptr); free($11.str.ptr); + + symtree_upptr(); } ; ASLTermList - : { parser_state_push(); PARSER_BEGINPACKAGE("ASLTermList"); } + : { + parser_state_push(); + PARSER_BEGINPACKAGE("ASLTermList"); + + symtree_moveptr(symtree_new(0, "ASLTermList")); + } TermList ; @@ -328,7 +342,9 @@ ; UserTerm - : NameString '(' ArgList ')' + : NameString '(' + { symtree_moveptr(symtree_new(0, "UserTermMethod")); } + ArgList ')' { int numargs; if (parser_phase == 2) { @@ -344,6 +360,8 @@ userterm_out: current_state->method_numargs = 0; free($1); + + symtree_upptr(); } | NameString /* XXX Named object by user (not in Spec.) */ { @@ -392,6 +410,8 @@ PARSER_SYMTAB_NEW($$, parser_scope_fullpath($7), SYM_FIELD); } free($7); + + symtree_upptr(); } ; @@ -399,15 +419,22 @@ : TOK_CREATEBYTEFIELD { PARSER_ENCODING_TERM(0x8c, "CreateByteField"); + + symtree_moveptr(symtree_new(0, "CreateByteField")); } ; MethodTerm - : MethodInterface '{' TermList '}' + : MethodInterface '{' + { symtree_moveptr(symtree_new(0, "MethodTermList")); } + TermList '}' { $$ = $1; PARSER_ENDPACKAGE("Method"); parser_scope_exit(); + + symtree_upptr(); + symtree_upptr(); } ; @@ -433,6 +460,9 @@ parser_state_push(); PARSER_PKGLENGTH_FLUSH(); current_state->in_method_interface = 1; + + symtree_moveptr(symtree_new(0, "Method")); + } ; @@ -451,9 +481,14 @@ */ WhileTerm - : WhileDenotation '(' TermArg ')' '{' TermList '}' + : WhileDenotation '(' TermArg ')' '{' + { symtree_moveptr(symtree_new(0, "WhileTermList")); } + TermList '}' { PARSER_ENDPACKAGE("While"); + + symtree_upptr(); + symtree_upptr(); } ; @@ -464,6 +499,8 @@ PARSER_BEGINPACKAGE("While"); parser_state_push(); PARSER_PKGLENGTH_FLUSH(); + + symtree_moveptr(symtree_new(0, "While")); } ; @@ -473,12 +510,17 @@ DecTerm : DecrementDenotation '(' SuperName ')' + { + symtree_upptr(); + } ; DecrementDenotation : TOK_DECREMENT { PARSER_ENCODING_TERM(0x76, "Decrement"); + + symtree_moveptr(symtree_new(0, "Decrement")); } ; @@ -513,6 +555,8 @@ : StoreDenotation '(' TermArg ',' SuperName ')' { current_state->prefix_expected = 0; + + symtree_upptr(); } ; @@ -521,6 +565,8 @@ { PARSER_ENCODING_TERM(0x70, "Store"); current_state->prefix_expected = 1; + + symtree_moveptr(symtree_new(0, "Store")); } ; @@ -544,6 +590,8 @@ : TOK_ARGTERM { PARSER_ENCODING_TERM(0x68 + $1, "Arg%d", $1); + + symtree_new(0, "ArgX"); } ; @@ -551,6 +599,8 @@ : TOK_LOCALTERM { PARSER_ENCODING_TERM(0x60 + $1, "Local%d", $1); + + symtree_new(0, "LocalX"); } ; @@ -574,6 +624,8 @@ PARSER_ENCODING_INTEGER($$.num.val, 1, "ByteConst"); } + + symtree_new(0, "ByteConst"); } ; @@ -582,6 +634,8 @@ { $$ = $1; PARSER_ENCODING_INTEGER($$.num.val, 2, "WordConst"); + + symtree_new(0, "WordConst"); } ; @@ -590,6 +644,8 @@ { $$ = $1; PARSER_ENCODING_INTEGER($$.num.val, 4, "DWordConst"); + + symtree_new(0, "DWordConst"); } ; @@ -613,6 +669,8 @@ ptr++; } PARSER_ENCODING_TERM(0x00, "StringTermination"); + + symtree_new(0, $$.str.ptr); } ; @@ -621,7 +679,9 @@ */ BufferTerm - : BufferDenotation '(' BufferSize ')' '{' BufferBlock '}' + : BufferDenotation '(' BufferSize ')' '{' + { symtree_moveptr(symtree_new(0, "BufferBlock")); } + BufferBlock '}' { if (parser_phase == 1 && current_state->buffersize_unknown) { current_state->buffersize = current_state->pkglength; @@ -633,6 +693,9 @@ } PARSER_ENDPACKAGE("Buffer"); + + symtree_upptr(); + symtree_upptr(); } ; @@ -651,6 +714,8 @@ } else { current_state->prefix_expected = 1; } + + symtree_moveptr(symtree_new(0, "Buffer")); } ; @@ -732,6 +797,8 @@ PARSER_ENCODING_TERM(*ptr, "NameString"); ptr++; } + + symtree_new(0, $$); } ; @@ -1032,6 +1099,7 @@ switch (parser_phase) { case 1: symtab_dump(); + symtree_dump(symtree_getroot(), 0); break; default: break; Binary files ../aslc-20001128/aslcsymtab.o and ./aslcsymtab.o differ diff -uN ../aslc-20001128/aslcsymtree.c ./aslcsymtree.c --- ../aslc-20001128/aslcsymtree.c Thu Jan 1 09:00:00 1970 +++ ./aslcsymtree.c Wed Nov 29 12:49:23 2000 @@ -0,0 +1,128 @@ +/*- + * ACPI Source Language Compiler + * + * Copyright (c) 2000 Mitsuru IWASAKI + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include + +#include "aslc.h" +#include "aslcsymtree.h" + +static struct asl_symtree symtree_root; +static struct asl_symtree *symtree_curptr = &symtree_root; + +static __inline void +symtree_init() +{ + static int first = 1; + + if (first) { + bzero(&symtree_root, sizeof(symtree_root)); + symtree_root.symbol.common.symbol = "ASLCode"; + first = 0; + } +} + +struct asl_symtree * +symtree_new(int type, char *symbol) +{ + struct asl_symtree *new_entry, *brother; + + symtree_init(); + if ((new_entry = malloc(sizeof(struct asl_symtree))) == NULL) { + parser_fatal("No more room for symbols."); + } + + bzero(new_entry, sizeof(struct asl_symtree)); + new_entry->symbol.common.type = type; + new_entry->symbol.common.symbol = strdup(symbol); + new_entry->parent = symtree_curptr; + new_entry->child = NULL; + if (symtree_curptr->child != NULL) { + brother = symtree_curptr->child; + while (brother) { + if (brother->brother == NULL) { + brother->brother = new_entry; + break; + } + brother = brother->brother; + } + } else { + symtree_curptr->child = new_entry; + } + + return(new_entry); +} + +void +symtree_moveptr(struct asl_symtree *symbol) +{ + symtree_init(); + if (symbol != NULL) { + symtree_curptr = symbol; + } +} + +void +symtree_upptr() +{ + symtree_init(); + symtree_moveptr(symtree_curptr->parent); +} + +struct asl_symtree * +symtree_getroot(void) +{ + symtree_init(); + return(&symtree_root); +} + +void +symtree_dump(struct asl_symtree *start, int depth) +{ + int i; + struct asl_symtree *entry; + + symtree_init(); + for (i = 0; i < depth; i++) { + printf("\t"); + } + printf("<%s>\n", start->symbol.common.symbol); + if (start->child != NULL) { + symtree_dump(start->child, depth + 1); + } + + if (start->brother != NULL) { + symtree_dump(start->brother, depth); + } +} + diff -uN ../aslc-20001128/aslcsymtree.h ./aslcsymtree.h --- ../aslc-20001128/aslcsymtree.h Thu Jan 1 09:00:00 1970 +++ ./aslcsymtree.h Wed Nov 29 12:14:11 2000 @@ -0,0 +1,78 @@ +/*- + * ACPI Source Language Compiler + * + * Copyright (c) 2000 Mitsuru IWASAKI + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _ASLCSYMTREE_H_ +#define _ASLCSYMTREE_H_ + +#define SYMBOL_COMMON \ + int type; \ + char *symbol; \ + char encoding + +union symtree_symbol { + struct { + SYMBOL_COMMON; + } common; + + struct { + SYMBOL_COMMON; + char *name; + int flags; + int pkglength; + } sym_method; + + struct { + SYMBOL_COMMON; + int size; + int pkglength; + } sym_buffer; + + struct { + SYMBOL_COMMON; + int pkglength; + } sym_while; + + /* and more... */ +}; + +struct asl_symtree { + union symtree_symbol symbol; + struct asl_symtree *parent; + struct asl_symtree *brother; + struct asl_symtree *child; +}; + +extern struct asl_symtree *symtree_new(int type, char *symbol); +extern void symtree_moveptr(struct asl_symtree *symbol); +extern void symtree_upptr(void); +extern struct asl_symtree *symtree_getroot(void); +extern void symtree_dump(struct asl_symtree *start, int depth); + +#endif /* !_ASLCSYMTREE_H_ */ Binary files ../aslc-20001128/aslcsymtree.o and ./aslcsymtree.o differ diff -uN ../aslc-20001128/y.output ./y.output --- ../aslc-20001128/y.output Thu Jan 1 09:00:00 1970 +++ ./y.output Wed Nov 29 12:41:37 2000 @@ -0,0 +1,2365 @@ + 0 $accept : ASLCode $end + + 1 $$1 : + + 2 ASLCode : $$1 DefinitionBlockTerm '{' ASLTermList '}' + + 3 DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' String ',' DWordConst ')' + + 4 $$2 : + + 5 ASLTermList : $$2 TermList + + 6 TermList : Nothing + 7 | Term TermList + + 8 Term : Object + 9 | Type1Opcode + 10 | Type2Opcode + + 11 ObjectList : Nothing + 12 | Object ObjectList + + 13 Object : NamedObject + 14 | UserTerm + + 15 DataObject : BufferTerm + 16 | PackageTerm + 17 | LiteralData + + 18 LiteralData : Integer + 19 | String + + 20 $$3 : + + 21 UserTerm : NameString '(' $$3 ArgList ')' + 22 | NameString + + 23 ArgList : Nothing + 24 | TermArg ArgListTail + + 25 ArgListTail : Nothing + 26 | ',' TermArg ArgListTail + + 27 TermArg : Type2Opcode + 28 | DataObject + 29 | UserTerm + 30 | ArgTerm + 31 | LocalTerm + + 32 Type1Opcode : WhileTerm + + 33 Type2Opcode : DecTerm + 34 | RefOfTerm + 35 | StoreTerm + + 36 NamedObject : CreateByteFieldTerm + 37 | MethodTerm + + 38 CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' TermArg ',' NameString ')' + + 39 CreateByteFieldDenotation : TOK_CREATEBYTEFIELD + + 40 $$4 : + + 41 MethodTerm : MethodInterface '{' $$4 TermList '}' + + 42 MethodInterface : MethodDenotation '(' NameString MethodNumArgs MethodSerializeRule ')' + + 43 MethodDenotation : TOK_METHOD + + 44 MethodNumArgs : Nothing + 45 | ',' ByteConst + + 46 MethodSerializeRule : Nothing + 47 | ',' SerializeRuleKeyword + + 48 $$5 : + + 49 WhileTerm : WhileDenotation '(' TermArg ')' '{' $$5 TermList '}' + + 50 WhileDenotation : TOK_WHILE + + 51 DecTerm : DecrementDenotation '(' SuperName ')' + + 52 DecrementDenotation : TOK_DECREMENT + + 53 IndexTerm : IndexDenotation '(' TermArg ',' TermArg IndexDestination ')' + + 54 IndexDenotation : TOK_INDEX + + 55 IndexDestination : Nothing + 56 | ',' SuperName + + 57 RefOfTerm : RefOfDenotation '(' SuperName ')' + + 58 RefOfDenotation : TOK_REFOF + + 59 StoreTerm : StoreDenotation '(' TermArg ',' SuperName ')' + + 60 StoreDenotation : TOK_STORE + + 61 SerializeRuleKeyword : TOK_SERIALIZERULEKEYWORD + + 62 SuperName : NameString + 63 | ArgTerm + 64 | LocalTerm + 65 | DebugTerm + 66 | IndexTerm + + 67 ArgTerm : TOK_ARGTERM + + 68 LocalTerm : TOK_LOCALTERM + + 69 DebugTerm : TOK_DEBUGTERM + + 70 Integer : ByteConst + 71 | WordConst + 72 | DWordConst + + 73 ByteConst : TOK_BYTECONST + + 74 WordConst : TOK_WORDCONST + + 75 DWordConst : TOK_DWORDCONST + + 76 String : TOK_STRING + + 77 $$6 : + + 78 BufferTerm : BufferDenotation '(' BufferSize ')' '{' $$6 BufferBlock '}' + + 79 BufferDenotation : TOK_BUFFER + + 80 BufferSize : Nothing + 81 | TermArg + + 82 BufferBlock : String + 83 | ByteList + + 84 ByteList : Nothing + 85 | ByteConst ByteListTail + + 86 ByteListTail : Nothing + 87 | ',' ByteConst ByteListTail + + 88 PackageTerm : PackageDenotation '(' PackageNumElements ')' '{' PackageList '}' + + 89 PackageDenotation : TOK_PACKAGE + + 90 PackageNumElements : Nothing + 91 | ByteConst + + 92 PackageList : Nothing + 93 | PackageElement PackageListTail + + 94 PackageListTail : Nothing + 95 | ',' PackageElement PackageListTail + + 96 PackageElement : DataObject + 97 | NameString + + 98 RootChar : '\\' + + 99 NameSeg : TOK_NAMESEG + + 100 NameString : RootChar NamePath + 101 | PrefixPath NamePath + + 102 PrefixPath : Nothing + 103 | '^' PrefixPath + + 104 NamePath : Nothing + 105 | NameSeg NamePathTail + + 106 NamePathTail : Nothing + 107 | '.' NameSeg NamePathTail + + 108 Nothing : + +state 0 + $accept : . ASLCode $end (0) + $$1 : . (1) + + . reduce 1 + + ASLCode goto 1 + $$1 goto 2 + + +state 1 + $accept : ASLCode . $end (0) + + $end accept + + +state 2 + ASLCode : $$1 . DefinitionBlockTerm '{' ASLTermList '}' (2) + + TOK_DEFINITIONBLOCK shift 3 + . error + + DefinitionBlockTerm goto 4 + + +state 3 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK . '(' String ',' String ',' ByteConst ',' String ',' String ',' DWordConst ')' (3) + + '(' shift 5 + . error + + +state 4 + ASLCode : $$1 DefinitionBlockTerm . '{' ASLTermList '}' (2) + + '{' shift 6 + . error + + +state 5 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' . String ',' String ',' ByteConst ',' String ',' String ',' DWordConst ')' (3) + + TOK_STRING shift 7 + . error + + String goto 8 + + +state 6 + ASLCode : $$1 DefinitionBlockTerm '{' . ASLTermList '}' (2) + $$2 : . (4) + + . reduce 4 + + ASLTermList goto 9 + $$2 goto 10 + + +state 7 + String : TOK_STRING . (76) + + . reduce 76 + + +state 8 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String . ',' String ',' ByteConst ',' String ',' String ',' DWordConst ')' (3) + + ',' shift 11 + . error + + +state 9 + ASLCode : $$1 DefinitionBlockTerm '{' ASLTermList . '}' (2) + + '}' shift 12 + . error + + +10: shift/reduce conflict (shift 13, reduce 108) on TOK_CREATEBYTEFIELD +10: shift/reduce conflict (shift 14, reduce 108) on TOK_METHOD +10: shift/reduce conflict (shift 15, reduce 108) on TOK_WHILE +10: shift/reduce conflict (shift 16, reduce 108) on TOK_DECREMENT +10: shift/reduce conflict (shift 17, reduce 108) on TOK_REFOF +10: shift/reduce conflict (shift 18, reduce 108) on TOK_STORE +10: shift/reduce conflict (shift 19, reduce 108) on '\\' +10: shift/reduce conflict (shift 20, reduce 108) on '^' +state 10 + ASLTermList : $$2 . TermList (5) + Nothing : . (108) + + TOK_CREATEBYTEFIELD shift 13 + TOK_METHOD shift 14 + TOK_WHILE shift 15 + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '}' reduce 108 + '(' reduce 108 + + UserTerm goto 21 + CreateByteFieldTerm goto 22 + MethodTerm goto 23 + MethodInterface goto 24 + NameString goto 25 + PrefixPath goto 26 + TermList goto 27 + Nothing goto 28 + Term goto 29 + Object goto 30 + Type1Opcode goto 31 + Type2Opcode goto 32 + NamedObject goto 33 + WhileTerm goto 34 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + CreateByteFieldDenotation goto 38 + MethodDenotation goto 39 + WhileDenotation goto 40 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + RootChar goto 44 + + +state 11 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' . String ',' ByteConst ',' String ',' String ',' DWordConst ')' (3) + + TOK_STRING shift 7 + . error + + String goto 45 + + +state 12 + ASLCode : $$1 DefinitionBlockTerm '{' ASLTermList '}' . (2) + + . reduce 2 + + +state 13 + CreateByteFieldDenotation : TOK_CREATEBYTEFIELD . (39) + + . reduce 39 + + +state 14 + MethodDenotation : TOK_METHOD . (43) + + . reduce 43 + + +state 15 + WhileDenotation : TOK_WHILE . (50) + + . reduce 50 + + +state 16 + DecrementDenotation : TOK_DECREMENT . (52) + + . reduce 52 + + +state 17 + RefOfDenotation : TOK_REFOF . (58) + + . reduce 58 + + +state 18 + StoreDenotation : TOK_STORE . (60) + + . reduce 60 + + +state 19 + RootChar : '\\' . (98) + + . reduce 98 + + +20: shift/reduce conflict (shift 20, reduce 108) on '^' +state 20 + PrefixPath : '^' . PrefixPath (103) + Nothing : . (108) + + '^' shift 20 + TOK_CREATEBYTEFIELD reduce 108 + TOK_METHOD reduce 108 + TOK_WHILE reduce 108 + TOK_DECREMENT reduce 108 + TOK_REFOF reduce 108 + TOK_STORE reduce 108 + TOK_NAMESEG reduce 108 + '}' reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + '\\' reduce 108 + + PrefixPath goto 46 + Nothing goto 47 + + +state 21 + Object : UserTerm . (14) + + . reduce 14 + + +state 22 + NamedObject : CreateByteFieldTerm . (36) + + . reduce 36 + + +state 23 + NamedObject : MethodTerm . (37) + + . reduce 37 + + +state 24 + MethodTerm : MethodInterface . '{' $$4 TermList '}' (41) + + '{' shift 48 + . error + + +25: shift/reduce conflict (shift 49, reduce 22) on '(' +state 25 + UserTerm : NameString . '(' $$3 ArgList ')' (21) + UserTerm : NameString . (22) + + '(' shift 49 + TOK_CREATEBYTEFIELD reduce 22 + TOK_METHOD reduce 22 + TOK_WHILE reduce 22 + TOK_DECREMENT reduce 22 + TOK_REFOF reduce 22 + TOK_STORE reduce 22 + TOK_NAMESEG reduce 22 + '}' reduce 22 + ',' reduce 22 + ')' reduce 22 + '\\' reduce 22 + '^' reduce 22 + + +26: shift/reduce conflict (shift 50, reduce 108) on TOK_NAMESEG +state 26 + NameString : PrefixPath . NamePath (101) + Nothing : . (108) + + TOK_NAMESEG shift 50 + TOK_CREATEBYTEFIELD reduce 108 + TOK_METHOD reduce 108 + TOK_WHILE reduce 108 + TOK_DECREMENT reduce 108 + TOK_REFOF reduce 108 + TOK_STORE reduce 108 + '}' reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + '\\' reduce 108 + '^' reduce 108 + + NameSeg goto 51 + NamePath goto 52 + Nothing goto 53 + + +state 27 + ASLTermList : $$2 TermList . (5) + + . reduce 5 + + +28: reduce/reduce conflict (reduce 6, reduce 102) on '}' +state 28 + TermList : Nothing . (6) + PrefixPath : Nothing . (102) + + TOK_CREATEBYTEFIELD reduce 102 + TOK_METHOD reduce 102 + TOK_WHILE reduce 102 + TOK_DECREMENT reduce 102 + TOK_REFOF reduce 102 + TOK_STORE reduce 102 + TOK_NAMESEG reduce 102 + '}' reduce 6 + '(' reduce 102 + '\\' reduce 102 + '^' reduce 102 + + +29: shift/reduce conflict (shift 13, reduce 108) on TOK_CREATEBYTEFIELD +29: shift/reduce conflict (shift 14, reduce 108) on TOK_METHOD +29: shift/reduce conflict (shift 15, reduce 108) on TOK_WHILE +29: shift/reduce conflict (shift 16, reduce 108) on TOK_DECREMENT +29: shift/reduce conflict (shift 17, reduce 108) on TOK_REFOF +29: shift/reduce conflict (shift 18, reduce 108) on TOK_STORE +29: shift/reduce conflict (shift 19, reduce 108) on '\\' +29: shift/reduce conflict (shift 20, reduce 108) on '^' +state 29 + TermList : Term . TermList (7) + Nothing : . (108) + + TOK_CREATEBYTEFIELD shift 13 + TOK_METHOD shift 14 + TOK_WHILE shift 15 + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '}' reduce 108 + '(' reduce 108 + + UserTerm goto 21 + CreateByteFieldTerm goto 22 + MethodTerm goto 23 + MethodInterface goto 24 + NameString goto 25 + PrefixPath goto 26 + TermList goto 54 + Nothing goto 28 + Term goto 29 + Object goto 30 + Type1Opcode goto 31 + Type2Opcode goto 32 + NamedObject goto 33 + WhileTerm goto 34 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + CreateByteFieldDenotation goto 38 + MethodDenotation goto 39 + WhileDenotation goto 40 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + RootChar goto 44 + + +state 30 + Term : Object . (8) + + . reduce 8 + + +state 31 + Term : Type1Opcode . (9) + + . reduce 9 + + +state 32 + Term : Type2Opcode . (10) + + . reduce 10 + + +state 33 + Object : NamedObject . (13) + + . reduce 13 + + +state 34 + Type1Opcode : WhileTerm . (32) + + . reduce 32 + + +state 35 + Type2Opcode : DecTerm . (33) + + . reduce 33 + + +state 36 + Type2Opcode : RefOfTerm . (34) + + . reduce 34 + + +state 37 + Type2Opcode : StoreTerm . (35) + + . reduce 35 + + +state 38 + CreateByteFieldTerm : CreateByteFieldDenotation . '(' TermArg ',' TermArg ',' NameString ')' (38) + + '(' shift 55 + . error + + +state 39 + MethodInterface : MethodDenotation . '(' NameString MethodNumArgs MethodSerializeRule ')' (42) + + '(' shift 56 + . error + + +state 40 + WhileTerm : WhileDenotation . '(' TermArg ')' '{' $$5 TermList '}' (49) + + '(' shift 57 + . error + + +state 41 + DecTerm : DecrementDenotation . '(' SuperName ')' (51) + + '(' shift 58 + . error + + +state 42 + RefOfTerm : RefOfDenotation . '(' SuperName ')' (57) + + '(' shift 59 + . error + + +state 43 + StoreTerm : StoreDenotation . '(' TermArg ',' SuperName ')' (59) + + '(' shift 60 + . error + + +44: shift/reduce conflict (shift 50, reduce 108) on TOK_NAMESEG +state 44 + NameString : RootChar . NamePath (100) + Nothing : . (108) + + TOK_NAMESEG shift 50 + TOK_CREATEBYTEFIELD reduce 108 + TOK_METHOD reduce 108 + TOK_WHILE reduce 108 + TOK_DECREMENT reduce 108 + TOK_REFOF reduce 108 + TOK_STORE reduce 108 + '}' reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + '\\' reduce 108 + '^' reduce 108 + + NameSeg goto 51 + NamePath goto 61 + Nothing goto 53 + + +state 45 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String . ',' ByteConst ',' String ',' String ',' DWordConst ')' (3) + + ',' shift 62 + . error + + +state 46 + PrefixPath : '^' PrefixPath . (103) + + . reduce 103 + + +state 47 + PrefixPath : Nothing . (102) + + . reduce 102 + + +state 48 + MethodTerm : MethodInterface '{' . $$4 TermList '}' (41) + $$4 : . (40) + + . reduce 40 + + $$4 goto 63 + + +state 49 + UserTerm : NameString '(' . $$3 ArgList ')' (21) + $$3 : . (20) + + . reduce 20 + + $$3 goto 64 + + +state 50 + NameSeg : TOK_NAMESEG . (99) + + . reduce 99 + + +state 51 + NamePath : NameSeg . NamePathTail (105) + Nothing : . (108) + + '.' shift 65 + TOK_CREATEBYTEFIELD reduce 108 + TOK_METHOD reduce 108 + TOK_WHILE reduce 108 + TOK_DECREMENT reduce 108 + TOK_REFOF reduce 108 + TOK_STORE reduce 108 + TOK_NAMESEG reduce 108 + '}' reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + '\\' reduce 108 + '^' reduce 108 + + NamePathTail goto 66 + Nothing goto 67 + + +state 52 + NameString : PrefixPath NamePath . (101) + + . reduce 101 + + +state 53 + NamePath : Nothing . (104) + + . reduce 104 + + +state 54 + TermList : Term TermList . (7) + + . reduce 7 + + +state 55 + CreateByteFieldTerm : CreateByteFieldDenotation '(' . TermArg ',' TermArg ',' NameString ')' (38) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ',' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 47 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 86 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 56 + MethodInterface : MethodDenotation '(' . NameString MethodNumArgs MethodSerializeRule ')' (42) + Nothing : . (108) + + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + ',' reduce 108 + ')' reduce 108 + + NameString goto 91 + PrefixPath goto 26 + Nothing goto 47 + RootChar goto 44 + + +state 57 + WhileTerm : WhileDenotation '(' . TermArg ')' '{' $$5 TermList '}' (49) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ')' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 47 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 92 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 58 + DecTerm : DecrementDenotation '(' . SuperName ')' (51) + Nothing : . (108) + + TOK_INDEX shift 93 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_DEBUGTERM shift 94 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + ')' reduce 108 + + NameString goto 95 + PrefixPath goto 26 + Nothing goto 47 + ArgTerm goto 96 + LocalTerm goto 97 + SuperName goto 98 + IndexTerm goto 99 + IndexDenotation goto 100 + DebugTerm goto 101 + RootChar goto 44 + + +state 59 + RefOfTerm : RefOfDenotation '(' . SuperName ')' (57) + Nothing : . (108) + + TOK_INDEX shift 93 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_DEBUGTERM shift 94 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + ')' reduce 108 + + NameString goto 95 + PrefixPath goto 26 + Nothing goto 47 + ArgTerm goto 96 + LocalTerm goto 97 + SuperName goto 102 + IndexTerm goto 99 + IndexDenotation goto 100 + DebugTerm goto 101 + RootChar goto 44 + + +state 60 + StoreTerm : StoreDenotation '(' . TermArg ',' SuperName ')' (59) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ',' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 47 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 103 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 61 + NameString : RootChar NamePath . (100) + + . reduce 100 + + +state 62 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' . ByteConst ',' String ',' String ',' DWordConst ')' (3) + + TOK_BYTECONST shift 70 + . error + + ByteConst goto 104 + + +63: shift/reduce conflict (shift 13, reduce 108) on TOK_CREATEBYTEFIELD +63: shift/reduce conflict (shift 14, reduce 108) on TOK_METHOD +63: shift/reduce conflict (shift 15, reduce 108) on TOK_WHILE +63: shift/reduce conflict (shift 16, reduce 108) on TOK_DECREMENT +63: shift/reduce conflict (shift 17, reduce 108) on TOK_REFOF +63: shift/reduce conflict (shift 18, reduce 108) on TOK_STORE +63: shift/reduce conflict (shift 19, reduce 108) on '\\' +63: shift/reduce conflict (shift 20, reduce 108) on '^' +state 63 + MethodTerm : MethodInterface '{' $$4 . TermList '}' (41) + Nothing : . (108) + + TOK_CREATEBYTEFIELD shift 13 + TOK_METHOD shift 14 + TOK_WHILE shift 15 + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '}' reduce 108 + '(' reduce 108 + + UserTerm goto 21 + CreateByteFieldTerm goto 22 + MethodTerm goto 23 + MethodInterface goto 24 + NameString goto 25 + PrefixPath goto 26 + TermList goto 105 + Nothing goto 28 + Term goto 29 + Object goto 30 + Type1Opcode goto 31 + Type2Opcode goto 32 + NamedObject goto 33 + WhileTerm goto 34 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + CreateByteFieldDenotation goto 38 + MethodDenotation goto 39 + WhileDenotation goto 40 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + RootChar goto 44 + + +state 64 + UserTerm : NameString '(' $$3 . ArgList ')' (21) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 106 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + ArgList goto 107 + TermArg goto 108 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 65 + NamePathTail : '.' . NameSeg NamePathTail (107) + + TOK_NAMESEG shift 50 + . error + + NameSeg goto 109 + + +state 66 + NamePath : NameSeg NamePathTail . (105) + + . reduce 105 + + +state 67 + NamePathTail : Nothing . (106) + + . reduce 106 + + +state 68 + ArgTerm : TOK_ARGTERM . (67) + + . reduce 67 + + +state 69 + LocalTerm : TOK_LOCALTERM . (68) + + . reduce 68 + + +state 70 + ByteConst : TOK_BYTECONST . (73) + + . reduce 73 + + +state 71 + WordConst : TOK_WORDCONST . (74) + + . reduce 74 + + +state 72 + DWordConst : TOK_DWORDCONST . (75) + + . reduce 75 + + +state 73 + BufferDenotation : TOK_BUFFER . (79) + + . reduce 79 + + +state 74 + PackageDenotation : TOK_PACKAGE . (89) + + . reduce 89 + + +state 75 + TermArg : UserTerm . (29) + + . reduce 29 + + +state 76 + Integer : ByteConst . (70) + + . reduce 70 + + +state 77 + Integer : WordConst . (71) + + . reduce 71 + + +state 78 + Integer : DWordConst . (72) + + . reduce 72 + + +state 79 + LiteralData : String . (19) + + . reduce 19 + + +state 80 + TermArg : Type2Opcode . (27) + + . reduce 27 + + +state 81 + TermArg : DataObject . (28) + + . reduce 28 + + +state 82 + DataObject : BufferTerm . (15) + + . reduce 15 + + +state 83 + DataObject : PackageTerm . (16) + + . reduce 16 + + +state 84 + DataObject : LiteralData . (17) + + . reduce 17 + + +state 85 + LiteralData : Integer . (18) + + . reduce 18 + + +state 86 + CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg . ',' TermArg ',' NameString ')' (38) + + ',' shift 110 + . error + + +state 87 + TermArg : ArgTerm . (30) + + . reduce 30 + + +state 88 + TermArg : LocalTerm . (31) + + . reduce 31 + + +state 89 + BufferTerm : BufferDenotation . '(' BufferSize ')' '{' $$6 BufferBlock '}' (78) + + '(' shift 111 + . error + + +state 90 + PackageTerm : PackageDenotation . '(' PackageNumElements ')' '{' PackageList '}' (88) + + '(' shift 112 + . error + + +91: shift/reduce conflict (shift 113, reduce 108) on ',' +state 91 + MethodInterface : MethodDenotation '(' NameString . MethodNumArgs MethodSerializeRule ')' (42) + Nothing : . (108) + + ',' shift 113 + ')' reduce 108 + + MethodNumArgs goto 114 + Nothing goto 115 + + +state 92 + WhileTerm : WhileDenotation '(' TermArg . ')' '{' $$5 TermList '}' (49) + + ')' shift 116 + . error + + +state 93 + IndexDenotation : TOK_INDEX . (54) + + . reduce 54 + + +state 94 + DebugTerm : TOK_DEBUGTERM . (69) + + . reduce 69 + + +state 95 + SuperName : NameString . (62) + + . reduce 62 + + +state 96 + SuperName : ArgTerm . (63) + + . reduce 63 + + +state 97 + SuperName : LocalTerm . (64) + + . reduce 64 + + +state 98 + DecTerm : DecrementDenotation '(' SuperName . ')' (51) + + ')' shift 117 + . error + + +state 99 + SuperName : IndexTerm . (66) + + . reduce 66 + + +state 100 + IndexTerm : IndexDenotation . '(' TermArg ',' TermArg IndexDestination ')' (53) + + '(' shift 118 + . error + + +state 101 + SuperName : DebugTerm . (65) + + . reduce 65 + + +state 102 + RefOfTerm : RefOfDenotation '(' SuperName . ')' (57) + + ')' shift 119 + . error + + +state 103 + StoreTerm : StoreDenotation '(' TermArg . ',' SuperName ')' (59) + + ',' shift 120 + . error + + +state 104 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst . ',' String ',' String ',' DWordConst ')' (3) + + ',' shift 121 + . error + + +state 105 + MethodTerm : MethodInterface '{' $$4 TermList . '}' (41) + + '}' shift 122 + . error + + +106: reduce/reduce conflict (reduce 23, reduce 102) on ')' +state 106 + ArgList : Nothing . (23) + PrefixPath : Nothing . (102) + + TOK_NAMESEG reduce 102 + '(' reduce 102 + ',' reduce 102 + ')' reduce 23 + + +state 107 + UserTerm : NameString '(' $$3 ArgList . ')' (21) + + ')' shift 123 + . error + + +state 108 + ArgList : TermArg . ArgListTail (24) + Nothing : . (108) + + ',' shift 124 + ')' reduce 108 + + Nothing goto 125 + ArgListTail goto 126 + + +state 109 + NamePathTail : '.' NameSeg . NamePathTail (107) + Nothing : . (108) + + '.' shift 65 + TOK_CREATEBYTEFIELD reduce 108 + TOK_METHOD reduce 108 + TOK_WHILE reduce 108 + TOK_DECREMENT reduce 108 + TOK_REFOF reduce 108 + TOK_STORE reduce 108 + TOK_NAMESEG reduce 108 + '}' reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + '\\' reduce 108 + '^' reduce 108 + + NamePathTail goto 127 + Nothing goto 67 + + +state 110 + CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' . TermArg ',' NameString ')' (38) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ',' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 47 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 128 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 111 + BufferTerm : BufferDenotation '(' . BufferSize ')' '{' $$6 BufferBlock '}' (78) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ')' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 129 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 130 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + BufferSize goto 131 + PackageDenotation goto 90 + RootChar goto 44 + + +state 112 + PackageTerm : PackageDenotation '(' . PackageNumElements ')' '{' PackageList '}' (88) + Nothing : . (108) + + TOK_BYTECONST shift 70 + ')' reduce 108 + + ByteConst goto 132 + Nothing goto 133 + PackageNumElements goto 134 + + +state 113 + MethodNumArgs : ',' . ByteConst (45) + + TOK_BYTECONST shift 70 + . error + + ByteConst goto 135 + + +state 114 + MethodInterface : MethodDenotation '(' NameString MethodNumArgs . MethodSerializeRule ')' (42) + Nothing : . (108) + + ',' shift 136 + ')' reduce 108 + + MethodSerializeRule goto 137 + Nothing goto 138 + + +state 115 + MethodNumArgs : Nothing . (44) + + . reduce 44 + + +state 116 + WhileTerm : WhileDenotation '(' TermArg ')' . '{' $$5 TermList '}' (49) + + '{' shift 139 + . error + + +state 117 + DecTerm : DecrementDenotation '(' SuperName ')' . (51) + + . reduce 51 + + +state 118 + IndexTerm : IndexDenotation '(' . TermArg ',' TermArg IndexDestination ')' (53) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ',' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 47 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 140 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 119 + RefOfTerm : RefOfDenotation '(' SuperName ')' . (57) + + . reduce 57 + + +state 120 + StoreTerm : StoreDenotation '(' TermArg ',' . SuperName ')' (59) + Nothing : . (108) + + TOK_INDEX shift 93 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_DEBUGTERM shift 94 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + ')' reduce 108 + + NameString goto 95 + PrefixPath goto 26 + Nothing goto 47 + ArgTerm goto 96 + LocalTerm goto 97 + SuperName goto 141 + IndexTerm goto 99 + IndexDenotation goto 100 + DebugTerm goto 101 + RootChar goto 44 + + +state 121 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' . String ',' String ',' DWordConst ')' (3) + + TOK_STRING shift 7 + . error + + String goto 142 + + +state 122 + MethodTerm : MethodInterface '{' $$4 TermList '}' . (41) + + . reduce 41 + + +state 123 + UserTerm : NameString '(' $$3 ArgList ')' . (21) + + . reduce 21 + + +state 124 + ArgListTail : ',' . TermArg ArgListTail (26) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 47 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 143 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 125 + ArgListTail : Nothing . (25) + + . reduce 25 + + +state 126 + ArgList : TermArg ArgListTail . (24) + + . reduce 24 + + +state 127 + NamePathTail : '.' NameSeg NamePathTail . (107) + + . reduce 107 + + +state 128 + CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' TermArg . ',' NameString ')' (38) + + ',' shift 144 + . error + + +129: reduce/reduce conflict (reduce 80, reduce 102) on ')' +state 129 + BufferSize : Nothing . (80) + PrefixPath : Nothing . (102) + + TOK_NAMESEG reduce 102 + '(' reduce 102 + ')' reduce 80 + + +state 130 + BufferSize : TermArg . (81) + + . reduce 81 + + +state 131 + BufferTerm : BufferDenotation '(' BufferSize . ')' '{' $$6 BufferBlock '}' (78) + + ')' shift 145 + . error + + +state 132 + PackageNumElements : ByteConst . (91) + + . reduce 91 + + +state 133 + PackageNumElements : Nothing . (90) + + . reduce 90 + + +state 134 + PackageTerm : PackageDenotation '(' PackageNumElements . ')' '{' PackageList '}' (88) + + ')' shift 146 + . error + + +state 135 + MethodNumArgs : ',' ByteConst . (45) + + . reduce 45 + + +state 136 + MethodSerializeRule : ',' . SerializeRuleKeyword (47) + + TOK_SERIALIZERULEKEYWORD shift 147 + . error + + SerializeRuleKeyword goto 148 + + +state 137 + MethodInterface : MethodDenotation '(' NameString MethodNumArgs MethodSerializeRule . ')' (42) + + ')' shift 149 + . error + + +state 138 + MethodSerializeRule : Nothing . (46) + + . reduce 46 + + +state 139 + WhileTerm : WhileDenotation '(' TermArg ')' '{' . $$5 TermList '}' (49) + $$5 : . (48) + + . reduce 48 + + $$5 goto 150 + + +state 140 + IndexTerm : IndexDenotation '(' TermArg . ',' TermArg IndexDestination ')' (53) + + ',' shift 151 + . error + + +state 141 + StoreTerm : StoreDenotation '(' TermArg ',' SuperName . ')' (59) + + ')' shift 152 + . error + + +state 142 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String . ',' String ',' DWordConst ')' (3) + + ',' shift 153 + . error + + +state 143 + ArgListTail : ',' TermArg . ArgListTail (26) + Nothing : . (108) + + ',' shift 124 + ')' reduce 108 + + Nothing goto 125 + ArgListTail goto 154 + + +state 144 + CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' TermArg ',' . NameString ')' (38) + Nothing : . (108) + + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + ')' reduce 108 + + NameString goto 155 + PrefixPath goto 26 + Nothing goto 47 + RootChar goto 44 + + +state 145 + BufferTerm : BufferDenotation '(' BufferSize ')' . '{' $$6 BufferBlock '}' (78) + + '{' shift 156 + . error + + +state 146 + PackageTerm : PackageDenotation '(' PackageNumElements ')' . '{' PackageList '}' (88) + + '{' shift 157 + . error + + +state 147 + SerializeRuleKeyword : TOK_SERIALIZERULEKEYWORD . (61) + + . reduce 61 + + +state 148 + MethodSerializeRule : ',' SerializeRuleKeyword . (47) + + . reduce 47 + + +state 149 + MethodInterface : MethodDenotation '(' NameString MethodNumArgs MethodSerializeRule ')' . (42) + + . reduce 42 + + +150: shift/reduce conflict (shift 13, reduce 108) on TOK_CREATEBYTEFIELD +150: shift/reduce conflict (shift 14, reduce 108) on TOK_METHOD +150: shift/reduce conflict (shift 15, reduce 108) on TOK_WHILE +150: shift/reduce conflict (shift 16, reduce 108) on TOK_DECREMENT +150: shift/reduce conflict (shift 17, reduce 108) on TOK_REFOF +150: shift/reduce conflict (shift 18, reduce 108) on TOK_STORE +150: shift/reduce conflict (shift 19, reduce 108) on '\\' +150: shift/reduce conflict (shift 20, reduce 108) on '^' +state 150 + WhileTerm : WhileDenotation '(' TermArg ')' '{' $$5 . TermList '}' (49) + Nothing : . (108) + + TOK_CREATEBYTEFIELD shift 13 + TOK_METHOD shift 14 + TOK_WHILE shift 15 + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '}' reduce 108 + '(' reduce 108 + + UserTerm goto 21 + CreateByteFieldTerm goto 22 + MethodTerm goto 23 + MethodInterface goto 24 + NameString goto 25 + PrefixPath goto 26 + TermList goto 158 + Nothing goto 28 + Term goto 29 + Object goto 30 + Type1Opcode goto 31 + Type2Opcode goto 32 + NamedObject goto 33 + WhileTerm goto 34 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + CreateByteFieldDenotation goto 38 + MethodDenotation goto 39 + WhileDenotation goto 40 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + RootChar goto 44 + + +state 151 + IndexTerm : IndexDenotation '(' TermArg ',' . TermArg IndexDestination ')' (53) + Nothing : . (108) + + TOK_DECREMENT shift 16 + TOK_REFOF shift 17 + TOK_STORE shift 18 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '(' reduce 108 + ',' reduce 108 + ')' reduce 108 + + UserTerm goto 75 + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 25 + PrefixPath goto 26 + Nothing goto 47 + Type2Opcode goto 80 + DataObject goto 81 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + TermArg goto 159 + ArgTerm goto 87 + LocalTerm goto 88 + DecTerm goto 35 + RefOfTerm goto 36 + StoreTerm goto 37 + DecrementDenotation goto 41 + RefOfDenotation goto 42 + StoreDenotation goto 43 + BufferDenotation goto 89 + PackageDenotation goto 90 + RootChar goto 44 + + +state 152 + StoreTerm : StoreDenotation '(' TermArg ',' SuperName ')' . (59) + + . reduce 59 + + +state 153 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' . String ',' DWordConst ')' (3) + + TOK_STRING shift 7 + . error + + String goto 160 + + +state 154 + ArgListTail : ',' TermArg ArgListTail . (26) + + . reduce 26 + + +state 155 + CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' TermArg ',' NameString . ')' (38) + + ')' shift 161 + . error + + +state 156 + BufferTerm : BufferDenotation '(' BufferSize ')' '{' . $$6 BufferBlock '}' (78) + $$6 : . (77) + + . reduce 77 + + $$6 goto 162 + + +state 157 + PackageTerm : PackageDenotation '(' PackageNumElements ')' '{' . PackageList '}' (88) + Nothing : . (108) + + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '}' reduce 108 + ',' reduce 108 + + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 163 + PrefixPath goto 26 + Nothing goto 164 + DataObject goto 165 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + BufferDenotation goto 89 + PackageDenotation goto 90 + PackageList goto 166 + PackageElement goto 167 + RootChar goto 44 + + +state 158 + WhileTerm : WhileDenotation '(' TermArg ')' '{' $$5 TermList . '}' (49) + + '}' shift 168 + . error + + +state 159 + IndexTerm : IndexDenotation '(' TermArg ',' TermArg . IndexDestination ')' (53) + Nothing : . (108) + + ',' shift 169 + ')' reduce 108 + + Nothing goto 170 + IndexDestination goto 171 + + +state 160 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' String . ',' DWordConst ')' (3) + + ',' shift 172 + . error + + +state 161 + CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' TermArg ',' NameString ')' . (38) + + . reduce 38 + + +state 162 + BufferTerm : BufferDenotation '(' BufferSize ')' '{' $$6 . BufferBlock '}' (78) + Nothing : . (108) + + TOK_BYTECONST shift 70 + TOK_STRING shift 7 + '}' reduce 108 + + ByteConst goto 173 + String goto 174 + Nothing goto 175 + BufferBlock goto 176 + ByteList goto 177 + + +state 163 + PackageElement : NameString . (97) + + . reduce 97 + + +164: reduce/reduce conflict (reduce 92, reduce 102) on '}' +state 164 + PackageList : Nothing . (92) + PrefixPath : Nothing . (102) + + TOK_NAMESEG reduce 102 + '}' reduce 92 + ',' reduce 102 + + +state 165 + PackageElement : DataObject . (96) + + . reduce 96 + + +state 166 + PackageTerm : PackageDenotation '(' PackageNumElements ')' '{' PackageList . '}' (88) + + '}' shift 178 + . error + + +state 167 + PackageList : PackageElement . PackageListTail (93) + Nothing : . (108) + + ',' shift 179 + '}' reduce 108 + + Nothing goto 180 + PackageListTail goto 181 + + +state 168 + WhileTerm : WhileDenotation '(' TermArg ')' '{' $$5 TermList '}' . (49) + + . reduce 49 + + +state 169 + IndexDestination : ',' . SuperName (56) + Nothing : . (108) + + TOK_INDEX shift 93 + TOK_ARGTERM shift 68 + TOK_LOCALTERM shift 69 + TOK_DEBUGTERM shift 94 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + ')' reduce 108 + + NameString goto 95 + PrefixPath goto 26 + Nothing goto 47 + ArgTerm goto 96 + LocalTerm goto 97 + SuperName goto 182 + IndexTerm goto 99 + IndexDenotation goto 100 + DebugTerm goto 101 + RootChar goto 44 + + +state 170 + IndexDestination : Nothing . (55) + + . reduce 55 + + +state 171 + IndexTerm : IndexDenotation '(' TermArg ',' TermArg IndexDestination . ')' (53) + + ')' shift 183 + . error + + +state 172 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' String ',' . DWordConst ')' (3) + + TOK_DWORDCONST shift 72 + . error + + DWordConst goto 184 + + +state 173 + ByteList : ByteConst . ByteListTail (85) + Nothing : . (108) + + ',' shift 185 + '}' reduce 108 + + Nothing goto 186 + ByteListTail goto 187 + + +state 174 + BufferBlock : String . (82) + + . reduce 82 + + +state 175 + ByteList : Nothing . (84) + + . reduce 84 + + +state 176 + BufferTerm : BufferDenotation '(' BufferSize ')' '{' $$6 BufferBlock . '}' (78) + + '}' shift 188 + . error + + +state 177 + BufferBlock : ByteList . (83) + + . reduce 83 + + +state 178 + PackageTerm : PackageDenotation '(' PackageNumElements ')' '{' PackageList '}' . (88) + + . reduce 88 + + +state 179 + PackageListTail : ',' . PackageElement PackageListTail (95) + Nothing : . (108) + + TOK_BYTECONST shift 70 + TOK_WORDCONST shift 71 + TOK_DWORDCONST shift 72 + TOK_STRING shift 7 + TOK_BUFFER shift 73 + TOK_PACKAGE shift 74 + '\\' shift 19 + '^' shift 20 + TOK_NAMESEG reduce 108 + '}' reduce 108 + ',' reduce 108 + + ByteConst goto 76 + WordConst goto 77 + DWordConst goto 78 + String goto 79 + NameString goto 163 + PrefixPath goto 26 + Nothing goto 47 + DataObject goto 165 + BufferTerm goto 82 + PackageTerm goto 83 + LiteralData goto 84 + Integer goto 85 + BufferDenotation goto 89 + PackageDenotation goto 90 + PackageElement goto 189 + RootChar goto 44 + + +state 180 + PackageListTail : Nothing . (94) + + . reduce 94 + + +state 181 + PackageList : PackageElement PackageListTail . (93) + + . reduce 93 + + +state 182 + IndexDestination : ',' SuperName . (56) + + . reduce 56 + + +state 183 + IndexTerm : IndexDenotation '(' TermArg ',' TermArg IndexDestination ')' . (53) + + . reduce 53 + + +state 184 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' String ',' DWordConst . ')' (3) + + ')' shift 190 + . error + + +state 185 + ByteListTail : ',' . ByteConst ByteListTail (87) + + TOK_BYTECONST shift 70 + . error + + ByteConst goto 191 + + +state 186 + ByteListTail : Nothing . (86) + + . reduce 86 + + +state 187 + ByteList : ByteConst ByteListTail . (85) + + . reduce 85 + + +state 188 + BufferTerm : BufferDenotation '(' BufferSize ')' '{' $$6 BufferBlock '}' . (78) + + . reduce 78 + + +state 189 + PackageListTail : ',' PackageElement . PackageListTail (95) + Nothing : . (108) + + ',' shift 179 + '}' reduce 108 + + Nothing goto 180 + PackageListTail goto 192 + + +state 190 + DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' String ',' DWordConst ')' . (3) + + . reduce 3 + + +state 191 + ByteListTail : ',' ByteConst . ByteListTail (87) + Nothing : . (108) + + ',' shift 185 + '}' reduce 108 + + Nothing goto 186 + ByteListTail goto 193 + + +state 192 + PackageListTail : ',' PackageElement PackageListTail . (95) + + . reduce 95 + + +state 193 + ByteListTail : ',' ByteConst ByteListTail . (87) + + . reduce 87 + + +Rules never reduced: + ObjectList : Nothing (11) + ObjectList : Object ObjectList (12) + + +State 10 contains 8 shift/reduce conflicts. +State 20 contains 1 shift/reduce conflict. +State 25 contains 1 shift/reduce conflict. +State 26 contains 1 shift/reduce conflict. +State 28 contains 1 reduce/reduce conflict. +State 29 contains 8 shift/reduce conflicts. +State 44 contains 1 shift/reduce conflict. +State 63 contains 8 shift/reduce conflicts. +State 91 contains 1 shift/reduce conflict. +State 106 contains 1 reduce/reduce conflict. +State 129 contains 1 reduce/reduce conflict. +State 150 contains 8 shift/reduce conflicts. +State 164 contains 1 reduce/reduce conflict. + + +30 terminals, 70 nonterminals +109 grammar rules, 194 states diff -uN ../aslc-20001128/y.tab.c ./y.tab.c --- ../aslc-20001128/y.tab.c Thu Jan 1 09:00:00 1970 +++ ./y.tab.c Wed Nov 29 12:41:37 2000 @@ -0,0 +1,1558 @@ +#ifndef lint +static char const +yyrcsid[] = "$FreeBSD: src/usr.bin/yacc/skeleton.c,v 1.28 2000/01/17 02:04:06 bde Exp $"; +#endif +#include +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYLEX yylex() +#define YYEMPTY -1 +#define yyclearin (yychar=(YYEMPTY)) +#define yyerrok (yyerrflag=0) +#define YYRECOVERING() (yyerrflag!=0) +static int yygrowstack(); +#define YYPREFIX "yy" +#line 2 "aslcparse.y" +/*- + * ACPI Source Language Compiler + * + * Copyright (c) 2000 Mitsuru IWASAKI + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include +#include +#include +#include + +#include "aslc.h" +#include "aslcsymtree.h" + +#ifdef DEBUG +#define YYDEBUG 1 +#define PARSER_DEBUGPRINT(phase, x...) do { \ + if (parser_phase <= phase && parser_debuglevel) { \ + printf(x); \ + } \ +} while (0) + +#else +#define PARSER_DEBUGPRINT(phase, x...) +#endif + +#define PARSER_ENCODING_TERM(code, term...) do { \ + if (parser_phase == 1) { \ + current_state->pkglength++; \ + } \ + snprintf(parser_msgbuf, PARSER_MSGBUFSIZE, term); \ + PARSER_DEBUGPRINT(2, "0x%02x:\t%s:\tat line %d\n", \ + code, parser_msgbuf, parser_lineno); \ +} while (0) + +#define PARSER_ENCODING_PREFIX(val, type) do { \ + int prefix; \ + if (parser_phase == 1) { \ + current_state->pkglength++; \ + } \ + if (type == LITERAL_INTEGER) { \ + if (val < 0xff) { \ + prefix = 0x0a; \ + } else if (val < 0xffff) { \ + prefix = 0x0b; \ + } else { \ + prefix = 0x0c; \ + } \ + } else { \ + prefix = 0x0d; \ + } \ + PARSER_DEBUGPRINT(2, "0x%02x:\tPrefix:\tat line %d\n", \ + prefix, parser_lineno); \ +} while (0) + +#define PARSER_ENCODING_INTEGER(val, bytes, term) do { \ + if (current_state->prefix_expected) { \ + PARSER_ENCODING_PREFIX(val, LITERAL_INTEGER); \ + } \ + switch (bytes) { \ + case 1: \ + PARSER_ENCODING_TERM(val, term); \ + break; \ + case 2: \ + PARSER_ENCODING_TERM((val >> 8) & 0xff, term); \ + PARSER_ENCODING_TERM((val & 0xff), term); \ + break; \ + case 4: \ + PARSER_ENCODING_TERM((val >> 24) & 0xff, term); \ + PARSER_ENCODING_TERM((val >> 16) & 0xff, term); \ + PARSER_ENCODING_TERM((val >> 8) & 0xff, term); \ + PARSER_ENCODING_TERM((val & 0xff), term); \ + break; \ + default: \ + break; \ + } \ +} while (0) + +#define PARSER_BEGINPACKAGE(x...) do { \ + PARSER_DEBUGPRINT(2, "\t<==\t"); \ + PARSER_DEBUGPRINT(2, x); \ + PARSER_DEBUGPRINT(2, "\n"); \ +} while (0) + +#define PARSER_ENDPACKAGE(term) do { \ + u_int8_t code[4]; \ + int len, i; \ + \ + parser_pkglength_fixup(); \ + len = current_state->pkglength; \ + len = parser_pkglength_encoding(len, code); \ + for (i = 0; i < len; i++) { \ + PARSER_DEBUGPRINT(2, "\t===>\t%s:0x%x\n", \ + term, code[i]); \ + } \ + parser_state_pop(); \ +} while (0) + +#define PARSER_PKGLENGTH_FLUSH() do { \ + u_int8_t code[4]; \ + int len, i; \ + \ + len = current_state->pkglength; \ + len = parser_pkglength_encoding(len, code); \ + for (i = 0; i < len; i++) { \ + PARSER_ENCODING_TERM(code[i], "PkgLength"); \ + } \ + if (parser_phase == 1) { \ + current_state->pkglength -= len; \ + } \ +} while (0) + +#define PARSER_SYMTAB_NEW(dest, name, type) do { \ + dest = symtab_find((const char *)name); \ + if (dest != NULL) { \ + snprintf(parser_msgbuf, PARSER_MSGBUFSIZE, \ + "<%s> is already defined", name); \ + yyerror(parser_msgbuf); \ + exit(1); \ + } else { \ + dest = symtab_new((const char *)name, type); \ + } \ +} while (0) + +#define PARSER_SYMTAB_FIND(dest, name, typestr) do { \ + dest = symtab_find((const char *)name); \ + if (dest == NULL) { \ + snprintf(parser_msgbuf, PARSER_MSGBUFSIZE, \ + "%s<%s> is not defined", typestr, name); \ + yyerror(parser_msgbuf); \ + } \ +} while (0) + +#define PARSER_PHASE_FINAL 1 +int parser_phase = 0; +int parser_debuglevel = 0; +int parser_not_initialized = 1; + +#define PARSER_MSGBUFSIZE 256 +static char parser_msgbuf[PARSER_MSGBUFSIZE]; + +static char *aml_filename = NULL; + +struct parser_state { + int method_numargs; + int pkglength; + int pkglength_fixed; + int buffersize; + int buffersize_unknown; + int in_method_interface; + int prefix_expected; +}; + +struct parser_state_list { + TAILQ_ENTRY(parser_state_list) links; + struct parser_state *state; +}; + +TAILQ_HEAD(, parser_state_list)state_list, state_log; +struct parser_state *current_state = NULL; +static void parser_state_push(void); +static void parser_state_pop(void); + +static char *parser_strcat(const char *str1, const char *str2); + +static void parser_scope_enter(const char *name); +static void parser_scope_exit(void); +static char *parser_scope_fullpath(const char *name); + +static int parser_pkglength_encoding(int pkglength, u_int8_t *encoding); +static void parser_pkglength_fixup(void); + +#line 203 "aslcparse.y" +typedef union { + char *str; + u_int32_t num; + union asl_literal lit; + struct asl_symtab *sym; +} YYSTYPE; +#line 224 "y.tab.c" +#define YYERRCODE 256 +#define TOK_DEFINITIONBLOCK 257 +#define TOK_CREATEBYTEFIELD 258 +#define TOK_METHOD 259 +#define TOK_WHILE 260 +#define TOK_DECREMENT 261 +#define TOK_INDEX 262 +#define TOK_REFOF 263 +#define TOK_STORE 264 +#define TOK_SERIALIZERULEKEYWORD 265 +#define TOK_ARGTERM 266 +#define TOK_LOCALTERM 267 +#define TOK_DEBUGTERM 268 +#define TOK_BYTECONST 269 +#define TOK_WORDCONST 270 +#define TOK_DWORDCONST 271 +#define TOK_STRING 272 +#define TOK_BUFFER 273 +#define TOK_PACKAGE 274 +#define TOK_NAMESEG 275 +#define TOK_ERROR 276 +const short yylhs[] = { -1, + 18, 0, 17, 21, 19, 20, 20, 23, 23, 23, + 27, 27, 24, 24, 29, 29, 29, 32, 32, 35, + 1, 1, 34, 34, 37, 37, 36, 36, 36, 36, + 36, 25, 26, 26, 26, 28, 28, 2, 44, 45, + 3, 4, 46, 5, 5, 6, 6, 48, 40, 47, + 41, 49, 51, 52, 53, 53, 42, 54, 43, 55, + 7, 50, 50, 50, 50, 50, 38, 39, 56, 33, + 33, 33, 8, 9, 10, 11, 60, 30, 57, 58, + 58, 59, 59, 61, 61, 62, 62, 31, 63, 64, + 64, 65, 65, 67, 67, 66, 66, 68, 12, 13, + 13, 14, 14, 15, 15, 16, 16, 22, +}; +const short yylen[] = { 2, + 0, 5, 14, 0, 2, 1, 2, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 0, + 5, 1, 1, 2, 1, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 8, 1, 0, + 5, 6, 1, 1, 2, 1, 2, 0, 8, 1, + 4, 1, 7, 1, 1, 2, 4, 1, 6, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 0, 8, 1, 1, + 1, 1, 1, 1, 2, 1, 3, 7, 1, 1, + 1, 1, 2, 1, 3, 1, 1, 1, 1, 2, + 2, 1, 2, 1, 2, 1, 3, 0, +}; +const short yydefred[] = { 1, + 0, 0, 0, 0, 0, 4, 76, 0, 0, 0, + 0, 2, 39, 43, 50, 52, 58, 60, 98, 0, + 14, 36, 37, 0, 0, 0, 5, 0, 0, 8, + 9, 10, 13, 32, 33, 34, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 103, 102, 40, 20, 99, + 0, 101, 104, 7, 0, 0, 0, 0, 0, 0, + 100, 0, 0, 0, 0, 105, 106, 67, 68, 73, + 74, 75, 79, 89, 29, 70, 71, 72, 19, 27, + 28, 15, 16, 17, 18, 0, 30, 31, 0, 0, + 0, 0, 54, 69, 62, 63, 64, 0, 66, 0, + 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 44, 0, 51, 0, 57, 0, + 0, 41, 21, 0, 25, 24, 107, 0, 0, 81, + 0, 91, 90, 0, 45, 0, 0, 46, 48, 0, + 0, 0, 0, 0, 0, 0, 61, 47, 42, 0, + 0, 59, 0, 26, 0, 77, 0, 0, 0, 0, + 38, 0, 97, 0, 96, 0, 0, 49, 0, 55, + 0, 0, 0, 82, 84, 0, 83, 88, 0, 94, + 93, 56, 53, 0, 0, 86, 85, 78, 0, 3, + 0, 95, 87, +}; +const short yydgoto[] = { 1, + 75, 22, 23, 24, 114, 137, 148, 76, 77, 78, + 79, 51, 25, 26, 52, 66, 4, 2, 9, 27, + 10, 47, 29, 30, 31, 80, 0, 33, 81, 82, + 83, 84, 85, 107, 64, 86, 126, 87, 88, 34, + 35, 36, 37, 38, 63, 39, 40, 150, 41, 98, + 99, 100, 171, 42, 43, 101, 89, 131, 176, 162, + 177, 187, 90, 134, 166, 167, 181, 44, +}; +const short yysindex[] = { 0, + 0, -223, 15, -83, -231, 0, 0, 16, -81, 26, + -231, 0, 0, 0, 0, 0, 0, 0, 0, -21, + 0, 0, 0, -57, 29, -208, 0, 0, 26, 0, + 0, 0, 0, 0, 0, 0, 0, 30, 39, 41, + 42, 43, 44, -208, 45, 0, 0, 0, 0, 0, + 51, 0, 0, 0, -65, -29, -65, -14, -14, -65, + 0, -182, 26, -65, -208, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 54, 0, 0, 48, 59, + 58, 63, 0, 0, 0, 0, 0, 65, 0, 67, + 0, 69, 64, 70, -12, 0, 74, 72, 51, -65, + -65, -182, -182, 73, 0, -4, 0, -65, 0, -14, + -231, 0, 0, -65, 0, 0, 0, 80, 0, 0, + 87, 0, 0, 89, 0, -154, 90, 0, 0, 88, + 95, 93, 72, -29, 17, 18, 0, 0, 0, 26, + -65, 0, -231, 0, 97, 0, -59, 14, 99, 100, + 0, -230, 0, 0, 0, 20, 103, 0, -14, 0, + 107, -119, 106, 0, 0, 31, 0, 0, -59, 0, + 0, 0, 0, 112, -182, 0, 0, 0, 103, 0, + 106, 0, 0, +}; +const short yyrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -30, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -33, + 0, 0, 0, 0, 2, 9, 0, -20, -30, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, + -40, 0, 0, 0, -26, -16, -19, -24, -24, -26, + 0, 0, -30, -38, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -28, 0, 113, -40, -26, + -19, 113, 0, 113, 0, 0, 0, -26, 0, -24, + 0, 0, 0, -38, 0, 0, 0, 0, -17, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 113, -24, 0, 0, 0, 0, 0, -30, + -38, 0, 0, 0, 0, 0, -39, 0, 113, 0, + 0, 34, 0, -25, 0, 0, 34, 0, -24, 0, + 0, 0, 34, 0, 0, 0, 0, 0, -39, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 34, 0, + 34, 0, 0, +}; +const short yygindex[] = { 0, + 27, 0, 0, 0, 0, 0, 0, -36, 0, -9, + 4, 102, -11, 135, 116, 55, 0, 0, 0, 1, + 0, 254, 0, 0, 0, 28, 0, 0, -121, 0, + 0, 0, 0, 0, 0, 11, 22, -27, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -8, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -22, 0, 0, 0, -6, -18, 0, +}; +#define YYTABLESIZE 445 +const short yytable[] = { 108, + 108, 108, 108, 108, 108, 108, 108, 108, 8, 108, + 108, 102, 23, 108, 45, 102, 108, 108, 102, 102, + 108, 108, 102, 80, 108, 104, 19, 108, 20, 54, + 96, 96, 19, 3, 20, 165, 21, 32, 70, 6, + 7, 7, 22, 12, 91, 22, 95, 95, 108, 108, + 102, 108, 108, 108, 5, 21, 32, 165, 108, 11, + 97, 97, 19, 105, 20, 48, 50, 92, 49, 55, + 103, 102, 20, 102, 108, 132, 135, 19, 56, 20, + 57, 58, 59, 60, 108, 108, 70, 111, 62, 21, + 32, 108, 96, 22, 108, 22, 65, 110, 112, 92, + 108, 113, 108, 116, 6, 117, 118, 120, 95, 119, + 147, 141, 122, 121, 123, 124, 136, 19, 139, 20, + 128, 130, 97, 144, 142, 173, 22, 145, 140, 146, + 149, 151, 155, 108, 143, 152, 153, 161, 168, 156, + 157, 96, 169, 172, 178, 163, 179, 183, 191, 185, + 158, 72, 190, 108, 46, 188, 160, 95, 108, 61, + 182, 159, 184, 127, 154, 174, 109, 163, 193, 0, + 192, 97, 189, 0, 0, 0, 21, 32, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 16, 0, 17, 18, 0, + 68, 69, 0, 70, 71, 72, 7, 73, 74, 70, + 71, 72, 7, 73, 74, 0, 0, 108, 108, 108, + 108, 0, 108, 108, 108, 108, 108, 108, 0, 108, + 108, 0, 0, 0, 108, 108, 108, 102, 102, 102, + 102, 108, 102, 102, 108, 0, 102, 93, 108, 102, + 108, 68, 69, 94, 102, 108, 0, 102, 108, 22, + 22, 22, 22, 28, 22, 22, 108, 108, 108, 108, + 0, 108, 108, 0, 0, 0, 22, 0, 0, 53, + 0, 0, 28, 13, 14, 15, 16, 0, 17, 18, + 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, + 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 28, 106, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 115, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 125, 67, 0, 129, 133, 0, 138, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 125, 0, 0, 0, + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + 164, 0, 170, 0, 0, 175, 0, 0, 0, 0, + 180, 0, 0, 0, 0, 0, 186, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 180, 0, 186, +}; +const short yycheck[] = { 40, + 41, 40, 41, 44, 44, 44, 40, 41, 5, 40, + 44, 40, 41, 40, 11, 44, 41, 44, 44, 40, + 40, 41, 40, 41, 41, 62, 92, 44, 94, 29, + 58, 59, 92, 257, 94, 157, 10, 10, 269, 123, + 272, 272, 41, 125, 56, 44, 58, 59, 40, 41, + 59, 92, 44, 94, 40, 29, 29, 179, 92, 44, + 58, 59, 92, 63, 94, 123, 275, 57, 40, 40, + 60, 92, 94, 94, 64, 112, 113, 92, 40, 94, + 40, 40, 40, 40, 125, 125, 269, 40, 44, 63, + 63, 125, 120, 92, 125, 94, 46, 44, 40, 125, + 92, 44, 94, 41, 125, 41, 40, 44, 120, 41, + 265, 120, 125, 44, 41, 44, 44, 92, 123, 94, + 110, 111, 120, 44, 121, 162, 125, 41, 118, 41, + 41, 44, 144, 125, 124, 41, 44, 41, 125, 123, + 123, 169, 44, 44, 125, 157, 44, 41, 185, 44, + 150, 271, 41, 41, 20, 125, 153, 169, 125, 44, + 169, 151, 172, 109, 143, 162, 65, 179, 191, -1, + 189, 169, 179, -1, -1, -1, 150, 150, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 261, -1, 263, 264, -1, + 266, 267, -1, 269, 270, 271, 272, 273, 274, 269, + 270, 271, 272, 273, 274, -1, -1, 258, 259, 260, + 261, -1, 263, 264, 258, 259, 260, 261, -1, 263, + 264, -1, -1, -1, 275, 275, 275, 258, 259, 260, + 261, 275, 263, 264, 275, -1, 275, 262, 275, 275, + 275, 266, 267, 268, 275, 275, -1, 275, 275, 258, + 259, 260, 261, 10, 263, 264, 258, 259, 260, 261, + -1, 263, 264, -1, -1, -1, 275, -1, -1, 26, + -1, -1, 29, 258, 259, 260, 261, -1, 263, 264, + -1, -1, -1, -1, -1, -1, -1, 44, -1, -1, + -1, -1, -1, -1, 51, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 63, 64, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 91, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 108, 109, -1, 111, 112, -1, 114, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 143, -1, -1, -1, + -1, -1, -1, 150, -1, -1, -1, -1, -1, -1, + 157, -1, 159, -1, -1, 162, -1, -1, -1, -1, + 167, -1, -1, -1, -1, -1, 173, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 189, -1, 191, +}; +#define YYFINAL 1 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 276 +#if YYDEBUG +const char * const yyname[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,"'('","')'",0,0,"','",0,"'.'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'\\\\'",0,"'^'",0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,"TOK_DEFINITIONBLOCK","TOK_CREATEBYTEFIELD","TOK_METHOD","TOK_WHILE", +"TOK_DECREMENT","TOK_INDEX","TOK_REFOF","TOK_STORE","TOK_SERIALIZERULEKEYWORD", +"TOK_ARGTERM","TOK_LOCALTERM","TOK_DEBUGTERM","TOK_BYTECONST","TOK_WORDCONST", +"TOK_DWORDCONST","TOK_STRING","TOK_BUFFER","TOK_PACKAGE","TOK_NAMESEG", +"TOK_ERROR", +}; +const char * const yyrule[] = { +"$accept : ASLCode", +"$$1 :", +"ASLCode : $$1 DefinitionBlockTerm '{' ASLTermList '}'", +"DefinitionBlockTerm : TOK_DEFINITIONBLOCK '(' String ',' String ',' ByteConst ',' String ',' String ',' DWordConst ')'", +"$$2 :", +"ASLTermList : $$2 TermList", +"TermList : Nothing", +"TermList : Term TermList", +"Term : Object", +"Term : Type1Opcode", +"Term : Type2Opcode", +"ObjectList : Nothing", +"ObjectList : Object ObjectList", +"Object : NamedObject", +"Object : UserTerm", +"DataObject : BufferTerm", +"DataObject : PackageTerm", +"DataObject : LiteralData", +"LiteralData : Integer", +"LiteralData : String", +"$$3 :", +"UserTerm : NameString '(' $$3 ArgList ')'", +"UserTerm : NameString", +"ArgList : Nothing", +"ArgList : TermArg ArgListTail", +"ArgListTail : Nothing", +"ArgListTail : ',' TermArg ArgListTail", +"TermArg : Type2Opcode", +"TermArg : DataObject", +"TermArg : UserTerm", +"TermArg : ArgTerm", +"TermArg : LocalTerm", +"Type1Opcode : WhileTerm", +"Type2Opcode : DecTerm", +"Type2Opcode : RefOfTerm", +"Type2Opcode : StoreTerm", +"NamedObject : CreateByteFieldTerm", +"NamedObject : MethodTerm", +"CreateByteFieldTerm : CreateByteFieldDenotation '(' TermArg ',' TermArg ',' NameString ')'", +"CreateByteFieldDenotation : TOK_CREATEBYTEFIELD", +"$$4 :", +"MethodTerm : MethodInterface '{' $$4 TermList '}'", +"MethodInterface : MethodDenotation '(' NameString MethodNumArgs MethodSerializeRule ')'", +"MethodDenotation : TOK_METHOD", +"MethodNumArgs : Nothing", +"MethodNumArgs : ',' ByteConst", +"MethodSerializeRule : Nothing", +"MethodSerializeRule : ',' SerializeRuleKeyword", +"$$5 :", +"WhileTerm : WhileDenotation '(' TermArg ')' '{' $$5 TermList '}'", +"WhileDenotation : TOK_WHILE", +"DecTerm : DecrementDenotation '(' SuperName ')'", +"DecrementDenotation : TOK_DECREMENT", +"IndexTerm : IndexDenotation '(' TermArg ',' TermArg IndexDestination ')'", +"IndexDenotation : TOK_INDEX", +"IndexDestination : Nothing", +"IndexDestination : ',' SuperName", +"RefOfTerm : RefOfDenotation '(' SuperName ')'", +"RefOfDenotation : TOK_REFOF", +"StoreTerm : StoreDenotation '(' TermArg ',' SuperName ')'", +"StoreDenotation : TOK_STORE", +"SerializeRuleKeyword : TOK_SERIALIZERULEKEYWORD", +"SuperName : NameString", +"SuperName : ArgTerm", +"SuperName : LocalTerm", +"SuperName : DebugTerm", +"SuperName : IndexTerm", +"ArgTerm : TOK_ARGTERM", +"LocalTerm : TOK_LOCALTERM", +"DebugTerm : TOK_DEBUGTERM", +"Integer : ByteConst", +"Integer : WordConst", +"Integer : DWordConst", +"ByteConst : TOK_BYTECONST", +"WordConst : TOK_WORDCONST", +"DWordConst : TOK_DWORDCONST", +"String : TOK_STRING", +"$$6 :", +"BufferTerm : BufferDenotation '(' BufferSize ')' '{' $$6 BufferBlock '}'", +"BufferDenotation : TOK_BUFFER", +"BufferSize : Nothing", +"BufferSize : TermArg", +"BufferBlock : String", +"BufferBlock : ByteList", +"ByteList : Nothing", +"ByteList : ByteConst ByteListTail", +"ByteListTail : Nothing", +"ByteListTail : ',' ByteConst ByteListTail", +"PackageTerm : PackageDenotation '(' PackageNumElements ')' '{' PackageList '}'", +"PackageDenotation : TOK_PACKAGE", +"PackageNumElements : Nothing", +"PackageNumElements : ByteConst", +"PackageList : Nothing", +"PackageList : PackageElement PackageListTail", +"PackageListTail : Nothing", +"PackageListTail : ',' PackageElement PackageListTail", +"PackageElement : DataObject", +"PackageElement : NameString", +"RootChar : '\\\\'", +"NameSeg : TOK_NAMESEG", +"NameString : RootChar NamePath", +"NameString : PrefixPath NamePath", +"PrefixPath : Nothing", +"PrefixPath : '^' PrefixPath", +"NamePath : Nothing", +"NamePath : NameSeg NamePathTail", +"NamePathTail : Nothing", +"NamePathTail : '.' NameSeg NamePathTail", +"Nothing :", +}; +#endif +#if YYDEBUG +#include +#endif +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 10000 +#define YYMAXDEPTH 10000 +#endif +#endif +#define YYINITSTACKSIZE 200 +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; +short *yyss; +short *yysslim; +YYSTYPE *yyvs; +int yystacksize; +#line 834 "aslcparse.y" + +static char * +parser_strcat(const char *str1, const char *str2) +{ + char *str; + size_t len; + + len = ((str1 == NULL) ? 0 : strlen(str1)) + + ((str2 == NULL) ? 0 : strlen(str2)) + 1; + + if ((str = (char *)malloc(len)) == NULL) { + parser_fatal("No more room for strcat"); + } + + bzero(str, len); + if (str1 != NULL) { + strncpy(str, str1, strlen(str1)); + } + if (str2 != NULL) { + strcat(str, str2); + } + + return(str); +} + +static int +parser_pkglength_encoding(int pkglength, u_int8_t *encoding) +{ + int len; + u_int8_t code[4]; + + len = 0; + bzero(code, sizeof(code)); + if (pkglength <= 0x0000003f) { /* 6bit */ + len = 1; + code[0] = pkglength; + goto out; + } + if (pkglength <= 0x00000fff) { /* 12bit */ + len = 2; + code[0] = (1 << 6) + (pkglength & 0xf); + code[1] = (pkglength >> 4) & 0xff; + goto out; + } + if (pkglength <= 0x000fffff) { /* 20bit */ + len = 3; + code[0] = (2 << 6) + (pkglength & 0xf); + code[1] = (pkglength >> 4) & 0xff; + code[2] = (pkglength >> 12) & 0xff; + goto out; + } + if (pkglength <= 0x0fffffff) { /* 28bit */ + len = 4; + code[0] = (3 << 6) + (pkglength & 0xf); + code[1] = (pkglength >> 4) & 0xff; + code[2] = (pkglength >> 12) & 0xff; + code[3] = (pkglength >> 20) & 0xff; + goto out; + } +out: + if (encoding != NULL) { + bcopy(code, encoding, sizeof(code)); + } + return(len); +} + +static void +parser_pkglength_fixup(void) +{ + int pkglength; + + if (current_state->pkglength_fixed == 0) { + pkglength = current_state->pkglength; + pkglength += parser_pkglength_encoding(pkglength, NULL); + current_state->pkglength = pkglength; + current_state->pkglength_fixed = 1; + } +} + +static __inline void +parser_state_init() +{ + static int first = 1; + + if (first) { + TAILQ_INIT(&state_list); + TAILQ_INIT(&state_log); + first = 0; + } +} + +static void +parser_state_push(void) +{ + struct parser_state *new_state; + struct parser_state_list *state_entry, *entry_log; + + parser_state_init(); + switch (parser_phase) { + case 1: + new_state = (struct parser_state *)malloc(sizeof(struct parser_state)); + if (new_state == NULL) { + parser_fatal("No room for parser_state."); + } + bzero(new_state, sizeof(struct parser_state)); + state_entry = (struct parser_state_list *)malloc(sizeof(struct parser_state_list)); + if (state_entry == NULL) { + parser_fatal("No room for parser_state_list."); + } + entry_log = (struct parser_state_list *)malloc(sizeof(struct parser_state_list)); + if (entry_log == NULL) { + parser_fatal("No room for parser_state_list."); + } + + state_entry->state = entry_log->state = new_state; + + TAILQ_INSERT_TAIL(&state_log, entry_log, links); + break; + default: + state_entry = TAILQ_FIRST(&state_log); + TAILQ_REMOVE(&state_log, state_entry, links); + TAILQ_INSERT_TAIL(&state_log, state_entry, links); + break; + } + TAILQ_INSERT_HEAD(&state_list, state_entry, links); + current_state = state_entry->state; +} + +static void +parser_state_pop(void) +{ + int pkglength; + struct parser_state_list *state_entry; + + parser_state_init(); + pkglength = current_state->pkglength; + state_entry = TAILQ_FIRST(&state_list); + TAILQ_REMOVE(&state_list, state_entry, links); + if (parser_phase == 1) { + free(state_entry); + } + + state_entry = TAILQ_FIRST(&state_list); + current_state = state_entry->state; + if (parser_phase == 1) { + current_state->pkglength += pkglength; + } +} + +struct parser_scope { + TAILQ_ENTRY(parser_scope) links; + char *name; +}; +TAILQ_HEAD(, parser_scope) scope_list; + +static __inline void +parser_scope_init() +{ + static int first = 1; + + if (first) { + TAILQ_INIT(&scope_list); + first = 0; + } +} + +static void +parser_scope_enter(const char *name) +{ + struct parser_scope *new_entry; + + parser_scope_init(); + + if ((new_entry = malloc(sizeof(struct parser_scope))) == NULL) { + parser_fatal("No more room for parser_scope."); + } + + bzero(new_entry, sizeof(struct parser_scope)); + new_entry->name = strdup(name); + TAILQ_INSERT_HEAD(&scope_list, new_entry, links); +} + +static void +parser_scope_exit(void) +{ + struct parser_scope *entry; + + parser_scope_init(); + entry = TAILQ_FIRST(&scope_list); + TAILQ_REMOVE(&scope_list, entry, links); + free(entry->name); + free(entry); +} + +static char * +parser_scope_fullpath(const char *name) +{ + struct parser_scope *entry; + static char fullpath[PARSER_MSGBUFSIZE]; + + parser_scope_init(); + bzero(fullpath, sizeof(fullpath)); + TAILQ_FOREACH(entry, &scope_list, links) { + snprintf(fullpath, sizeof(fullpath), "%s%s.", fullpath, entry->name); + } + snprintf(fullpath, sizeof(fullpath), "%s%s", fullpath, name); + return(fullpath); +} + +void +yyerror(const char *msg) +{ + + fprintf(stderr, "line %d: %s\n", parser_lineno, msg); +} + +#define PARSER_WARN(msg) do { \ + va_list ap; \ + va_start(ap, msg); \ + vsnprintf(parser_msgbuf, PARSER_MSGBUFSIZE, msg, ap); \ + va_end(ap); \ + yyerror(parser_msgbuf); \ +} while (0) + +void +parser_warn(const char *msg, ...) +{ + PARSER_WARN(msg); +} + +void +parser_error(const char *msg, ...) +{ + PARSER_WARN(msg); + exit(1); +} + +void +parser_fatal(const char *msg, ...) +{ + PARSER_WARN(msg); + abort(); +} + +extern FILE *yyin; + +void +parser_main(const char *asl_filename) +{ + + if ((yyin = fopen(asl_filename, "r")) == NULL) { + (void) err(1, "cannot open ASL file"); + } + + for (parser_phase = 1; parser_phase <= PARSER_PHASE_FINAL; parser_phase++) { + parser_lineno = 1; + if (parser_debuglevel) { + printf("==== PARSER PHASE %d ====\n", parser_phase); + } + + if (yyparse() != 0) { + fprintf(stderr, "ASL parser errors in phase %d\n", parser_phase); + exit(1); + } + + switch (parser_phase) { + case 1: + symtab_dump(); + symtree_dump(symtree_getroot(), 0); + break; + default: + break; + } + + rewind(yyin); + } + + fclose(yyin); + symtab_destroy(); +} +#line 891 "y.tab.c" +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack() +{ + int newsize, i; + short *newss; + YYSTYPE *newvs; + + if ((newsize = yystacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return -1; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + i = yyssp - yyss; + newss = yyss ? (short *)realloc(yyss, newsize * sizeof *newss) : + (short *)malloc(newsize * sizeof *newss); + if (newss == NULL) + return -1; + yyss = newss; + yyssp = newss + i; + newvs = yyvs ? (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs) : + (YYSTYPE *)malloc(newsize * sizeof *newvs); + if (newvs == NULL) + return -1; + yyvs = newvs; + yyvsp = newvs + i; + yystacksize = newsize; + yysslim = yyss + newsize - 1; + return 0; +} + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab + +#ifndef YYPARSE_PARAM +#if defined(__cplusplus) || __STDC__ +#define YYPARSE_PARAM_ARG void +#define YYPARSE_PARAM_DECL +#else /* ! ANSI-C/C++ */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* ANSI-C/C++ */ +#else /* YYPARSE_PARAM */ +#ifndef YYPARSE_PARAM_TYPE +#define YYPARSE_PARAM_TYPE void * +#endif +#if defined(__cplusplus) || __STDC__ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM_TYPE YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* ! ANSI-C/C++ */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL YYPARSE_PARAM_TYPE YYPARSE_PARAM; +#endif /* ANSI-C/C++ */ +#endif /* ! YYPARSE_PARAM */ + +int +yyparse (YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yym, yyn, yystate; +#if YYDEBUG + register const char *yys; + + if ((yys = getenv("YYDEBUG"))) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = (-1); + + if (yyss == NULL && yygrowstack()) goto yyoverflow; + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if ((yyn = yydefred[yystate])) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = (-1); + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; +#if defined(lint) || defined(__GNUC__) + goto yynewerror; +#endif +yynewerror: + yyerror("syntax error"); +#if defined(lint) || defined(__GNUC__) + goto yyerrlab; +#endif +yyerrlab: + ++yynerrs; +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = (-1); + goto yyloop; + } +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + yyval = yyvsp[1-yym]; + switch (yyn) + { +case 1: +#line 271 "aslcparse.y" +{ + parser_state_push(); + + symtree_moveptr(symtree_new(0, "DefinitionBlockTerm")); + } +break; +case 2: +#line 277 "aslcparse.y" +{ + PARSER_ENDPACKAGE("ASLTermList"); + + symtree_upptr(); + } +break; +case 3: +#line 286 "aslcparse.y" +{ + PARSER_DEBUGPRINT(1, "DefinitionBlock ("); + PARSER_DEBUGPRINT(1, "\"%s\", \"%s\", 0x%x, \"%s\", \"%s\", 0x%x)\n", + yyvsp[-11].lit.str.ptr, yyvsp[-9].lit.str.ptr, + yyvsp[-7].lit.num.val, yyvsp[-5].lit.str.ptr, + yyvsp[-3].lit.str.ptr, yyvsp[-1].lit.num.val); + + switch (parser_phase) { + case 1: + aml_filename = strdup(yyvsp[-11].lit.str.ptr); + break; + default: + break; + } + + free(yyvsp[-11].lit.str.ptr); + free(yyvsp[-9].lit.str.ptr); + free(yyvsp[-5].lit.str.ptr); + free(yyvsp[-3].lit.str.ptr); + + symtree_upptr(); + } +break; +case 4: +#line 311 "aslcparse.y" +{ + parser_state_push(); + PARSER_BEGINPACKAGE("ASLTermList"); + + symtree_moveptr(symtree_new(0, "ASLTermList")); + } +break; +case 20: +#line 346 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "UserTermMethod")); } +break; +case 21: +#line 348 "aslcparse.y" +{ + int numargs; + if (parser_phase == 2) { + PARSER_SYMTAB_FIND(yyval.sym, yyvsp[-4].str, "Method"); + if (yyval.sym == NULL) { + goto userterm_out; + } + numargs = symtab_method_getnumargs(yyval.sym); + if (numargs != current_state->method_numargs) { + parser_error("number of args is wrong for %s\n", yyvsp[-4].str); + } + } + userterm_out: + current_state->method_numargs = 0; + free(yyvsp[-4].str); + + symtree_upptr(); + } +break; +case 22: +#line 367 "aslcparse.y" +{ + if (parser_phase == 2) { + PARSER_SYMTAB_FIND(yyval.sym, + parser_scope_fullpath(yyvsp[0].str), "Object"); + } + free(yyvsp[0].str); + } +break; +case 24: +#line 378 "aslcparse.y" +{ current_state->method_numargs++; } +break; +case 26: +#line 383 "aslcparse.y" +{ current_state->method_numargs++; } +break; +case 38: +#line 408 "aslcparse.y" +{ + if (parser_phase == 1) { + PARSER_SYMTAB_NEW(yyval.sym, parser_scope_fullpath(yyvsp[-1].str), SYM_FIELD); + } + free(yyvsp[-1].str); + + symtree_upptr(); + } +break; +case 39: +#line 420 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x8c, "CreateByteField"); + + symtree_moveptr(symtree_new(0, "CreateByteField")); + } +break; +case 40: +#line 429 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "MethodTermList")); } +break; +case 41: +#line 431 "aslcparse.y" +{ + yyval.sym = yyvsp[-4].sym; + PARSER_ENDPACKAGE("Method"); + parser_scope_exit(); + + symtree_upptr(); + symtree_upptr(); + } +break; +case 42: +#line 443 "aslcparse.y" +{ + current_state->in_method_interface = 0; + PARSER_ENCODING_TERM((yyvsp[-2].num | yyvsp[-1].num << 3), "MethodFlags"); + if (parser_phase == 1) { + PARSER_SYMTAB_NEW(yyval.sym, parser_scope_fullpath(yyvsp[-3].str), SYM_METHOD); + symtab_method_setflags(yyval.sym, (int)(yyvsp[-2].num | yyvsp[-1].num << 3)); + } + parser_scope_enter(yyvsp[-3].str); + free(yyvsp[-3].str); + } +break; +case 43: +#line 457 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x14, "Method"); + PARSER_BEGINPACKAGE("Method"); + parser_state_push(); + PARSER_PKGLENGTH_FLUSH(); + current_state->in_method_interface = 1; + + symtree_moveptr(symtree_new(0, "Method")); + + } +break; +case 44: +#line 470 "aslcparse.y" +{ yyval.num = 0; } +break; +case 45: +#line 471 "aslcparse.y" +{ yyval.num = yyvsp[0].lit.num.val; } +break; +case 46: +#line 475 "aslcparse.y" +{ yyval.num = 0; } +break; +case 47: +#line 476 "aslcparse.y" +{ yyval.num = yyvsp[0].num; } +break; +case 48: +#line 485 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "WhileTermList")); } +break; +case 49: +#line 487 "aslcparse.y" +{ + PARSER_ENDPACKAGE("While"); + + symtree_upptr(); + symtree_upptr(); + } +break; +case 50: +#line 497 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0xa2, "While"); + PARSER_BEGINPACKAGE("While"); + parser_state_push(); + PARSER_PKGLENGTH_FLUSH(); + + symtree_moveptr(symtree_new(0, "While")); + } +break; +case 51: +#line 513 "aslcparse.y" +{ + symtree_upptr(); + } +break; +case 52: +#line 520 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x76, "Decrement"); + + symtree_moveptr(symtree_new(0, "Decrement")); + } +break; +case 54: +#line 533 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x88, "Index"); + } +break; +case 58: +#line 549 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x71, "RefOf"); + } +break; +case 59: +#line 556 "aslcparse.y" +{ + current_state->prefix_expected = 0; + + symtree_upptr(); + } +break; +case 60: +#line 565 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x70, "Store"); + current_state->prefix_expected = 1; + + symtree_moveptr(symtree_new(0, "Store")); + } +break; +case 61: +#line 578 "aslcparse.y" +{ yyval.num = yyvsp[0].num; } +break; +case 67: +#line 591 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x68 + yyvsp[0].num, "Arg%d", yyvsp[0].num); + + symtree_new(0, "ArgX"); + } +break; +case 68: +#line 600 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x60 + yyvsp[0].num, "Local%d", yyvsp[0].num); + + symtree_new(0, "LocalX"); + } +break; +case 73: +#line 621 "aslcparse.y" +{ + yyval.lit = yyvsp[0].lit; + if (current_state->in_method_interface == 0) { + PARSER_ENCODING_INTEGER(yyval.lit.num.val, + 1, "ByteConst"); + } + + symtree_new(0, "ByteConst"); + } +break; +case 74: +#line 634 "aslcparse.y" +{ + yyval.lit = yyvsp[0].lit; + PARSER_ENCODING_INTEGER(yyval.lit.num.val, 2, "WordConst"); + + symtree_new(0, "WordConst"); + } +break; +case 75: +#line 644 "aslcparse.y" +{ + yyval.lit = yyvsp[0].lit; + PARSER_ENCODING_INTEGER(yyval.lit.num.val, 4, "DWordConst"); + + symtree_new(0, "DWordConst"); + } +break; +case 76: +#line 658 "aslcparse.y" +{ + char *ptr; + yyval.lit = yyvsp[0].lit; + PARSER_DEBUGPRINT(2, "\tString<%s>:\tat line %d\n", + yyval.lit.str.ptr, parser_lineno); + if (current_state->prefix_expected) { + PARSER_ENCODING_PREFIX(0, LITERAL_STRING); + } + ptr = yyval.lit.str.ptr; + while (*ptr) { + PARSER_ENCODING_TERM(*ptr, "String"); + ptr++; + } + PARSER_ENCODING_TERM(0x00, "StringTermination"); + + symtree_new(0, yyval.lit.str.ptr); + } +break; +case 77: +#line 683 "aslcparse.y" +{ symtree_moveptr(symtree_new(0, "BufferBlock")); } +break; +case 78: +#line 685 "aslcparse.y" +{ + if (parser_phase == 1 && current_state->buffersize_unknown) { + current_state->buffersize = current_state->pkglength; + /* to adjust pkglength of the Buffer */ + current_state->prefix_expected = 1; + PARSER_ENCODING_INTEGER(current_state->buffersize, + 1, "BufferSize"); /* XXX */ + current_state->prefix_expected = 0; + } + + PARSER_ENDPACKAGE("Buffer"); + + symtree_upptr(); + symtree_upptr(); + } +break; +case 79: +#line 704 "aslcparse.y" +{ + PARSER_ENCODING_TERM(0x11, "Buffer"); + PARSER_BEGINPACKAGE("Buffer"); + parser_state_push(); + PARSER_PKGLENGTH_FLUSH(); + if (current_state->buffersize) { + current_state->prefix_expected = 1; + PARSER_ENCODING_INTEGER(current_state->buffersize, + 1, "BufferSize"); /* XXX */ + current_state->prefix_expected = 0; + } else { + current_state->prefix_expected = 1; + } + + symtree_moveptr(symtree_new(0, "Buffer")); + } +break; +case 80: +#line 724 "aslcparse.y" +{ + current_state->buffersize_unknown = 1; + current_state->prefix_expected = 0; + } +break; +case 81: +#line 728 "aslcparse.y" +{ current_state->prefix_expected = 0; } +break; +case 99: +#line 776 "aslcparse.y" +{ yyval.str = yyvsp[0].str; } +break; +case 100: +#line 781 "aslcparse.y" +{ + yyval.str = parser_strcat("\\", yyvsp[0].str); + free(yyvsp[0].str); + goto namestring_out; + } +break; +case 101: +#line 787 "aslcparse.y" +{ + char *ptr; + yyval.str = parser_strcat(yyvsp[-1].str, yyvsp[0].str); + free(yyvsp[-1].str); + free(yyvsp[0].str); + namestring_out: + PARSER_DEBUGPRINT(2, "\tNameString<%s>:\tat line %d\n", + yyval.str, parser_lineno); + ptr = yyval.str; + while (*ptr) { + PARSER_ENCODING_TERM(*ptr, "NameString"); + ptr++; + } + + symtree_new(0, yyval.str); + } +break; +case 102: +#line 806 "aslcparse.y" +{ yyval.str = NULL; } +break; +case 103: +#line 807 "aslcparse.y" +{ yyval.str = parser_strcat("^", yyvsp[0].str); free(yyvsp[0].str); } +break; +case 104: +#line 811 "aslcparse.y" +{ yyval.str = NULL; } +break; +case 105: +#line 812 "aslcparse.y" +{ yyval.str = parser_strcat(yyvsp[-1].str, yyvsp[0].str); free(yyvsp[-1].str); free(yyvsp[0].str); } +break; +case 106: +#line 816 "aslcparse.y" +{ yyval.str = NULL; } +break; +case 107: +#line 818 "aslcparse.y" +{ + yyval.str = parser_strcat(".", parser_strcat(yyvsp[-1].str, yyvsp[0].str)); + free(yyvsp[-1].str); + free(yyvsp[0].str); + } +break; +#line 1503 "y.tab.c" + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; +yyoverflow: + yyerror("yacc stack overflow"); +yyabort: + return (1); +yyaccept: + return (0); +} diff -uN ../aslc-20001128/y.tab.h ./y.tab.h --- ../aslc-20001128/y.tab.h Thu Jan 1 09:00:00 1970 +++ ./y.tab.h Wed Nov 29 12:41:37 2000 @@ -0,0 +1,31 @@ +#ifndef YYERRCODE +#define YYERRCODE 256 +#endif + +#define TOK_DEFINITIONBLOCK 257 +#define TOK_CREATEBYTEFIELD 258 +#define TOK_METHOD 259 +#define TOK_WHILE 260 +#define TOK_DECREMENT 261 +#define TOK_INDEX 262 +#define TOK_REFOF 263 +#define TOK_STORE 264 +#define TOK_SERIALIZERULEKEYWORD 265 +#define TOK_ARGTERM 266 +#define TOK_LOCALTERM 267 +#define TOK_DEBUGTERM 268 +#define TOK_BYTECONST 269 +#define TOK_WORDCONST 270 +#define TOK_DWORDCONST 271 +#define TOK_STRING 272 +#define TOK_BUFFER 273 +#define TOK_PACKAGE 274 +#define TOK_NAMESEG 275 +#define TOK_ERROR 276 +typedef union { + char *str; + u_int32_t num; + union asl_literal lit; + struct asl_symtab *sym; +} YYSTYPE; +extern YYSTYPE yylval;