# line 2 "../libfru/nameSyntaxYacc.y" /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END * * Copyright (c) 2000-2001 by Sun Microsystems, Inc. * All rights reserved. */ #pragma ident "%Z%%M% %I% %E% SMI" /* This is the yacc grammar for the libfru NamingSyntax */ #include #include #include "Parser.h" //#define YYDEBUG 1 // Parser Globals. extern fru_errno_t gParserErrno; extern char *gParserString; extern Ancestor *gParserAnts; extern PathDef *gParserHead; extern int *gParserAbs; extern void fruerror (const char *msg); extern int frulex (void); # line 49 "../libfru/nameSyntaxYacc.y" typedef union #ifdef __cplusplus YYSTYPE #endif { int num; char *name; PathDef *pathDef; } YYSTYPE; # define SEPIDENT 257 # define ITERBEGIN 258 # define ITEREND 259 # define LAST 260 # define ADD 261 # define NUMBER 262 # define NAME 263 #include #ifdef __STDC__ #include #include #define YYCONST const #else #include #include #define YYCONST #endif #include #if defined(__cplusplus) || defined(__STDC__) #if defined(__cplusplus) && defined(__EXTERN_C__) extern "C" { #endif #ifndef fruerror #if defined(__cplusplus) void fruerror(YYCONST char *); #endif #endif #ifndef frulex int frulex(void); #endif int fruparse(void); #if defined(__cplusplus) && defined(__EXTERN_C__) } #endif #endif #define yyclearin fruchar = -1 #define yyerrok fruerrflag = 0 extern int fruchar; extern int fruerrflag; YYSTYPE frulval; YYSTYPE fruval; typedef int yytabelem; #ifndef YYMAXDEPTH #define YYMAXDEPTH 150 #endif #if YYMAXDEPTH > 0 int yy_frus[YYMAXDEPTH], *frus = yy_frus; YYSTYPE yy_fruv[YYMAXDEPTH], *fruv = yy_fruv; #else /* user does initial allocation */ int *frus; YYSTYPE *fruv; #endif static int yymaxdepth = YYMAXDEPTH; # define YYERRCODE 256 # line 174 "../libfru/nameSyntaxYacc.y" void fruerror (const char *msg) { gParserErrno = FRU_INVALPATH; } // just to override what the library should have done. int fruwrap (void) { return 1; } static YYCONST yytabelem fruexca[] ={ -1, 1, 0, -1, -2, 0, }; # define YYNPROD 10 # define YYLAST 15 static YYCONST yytabelem fruact[]={ 12, 13, 11, 4, 14, 8, 6, 2, 1, 5, 10, 3, 7, 0, 9 }; static YYCONST yytabelem frupact[]={ -254,-10000000,-10000000, -251, -254, -253, -254,-10000000, -260,-10000000, -255,-10000000,-10000000,-10000000,-10000000 }; static YYCONST yytabelem frupgo[]={ 0, 7, 11, 10, 8 }; static YYCONST yytabelem frur1[]={ 0, 4, 1, 1, 1, 2, 2, 3, 3, 3 }; static YYCONST yytabelem frur2[]={ 0, 3, 3, 7, 5, 3, 9, 3, 3, 3 }; static YYCONST yytabelem fruchk[]={ -10000000, -4, -1, -2, 257, 263, 257, -1, 258, -1, -3, 262, 260, 261, 259 }; static YYCONST yytabelem frudef[]={ 0, -2, 1, 2, 0, 5, 0, 4, 0, 3, 0, 7, 8, 9, 6 }; typedef struct #ifdef __cplusplus yytoktype #endif { #ifdef __cplusplus const #endif char *t_name; int t_val; } yytoktype; #ifndef YYDEBUG # define YYDEBUG 0 /* don't allow debugging */ #endif #if YYDEBUG yytoktype frutoks[] = { "SEPIDENT", 257, "ITERBEGIN", 258, "ITEREND", 259, "LAST", 260, "ADD", 261, "NUMBER", 262, "NAME", 263, "-unknown-", -1 /* ends search */ }; #ifdef __cplusplus const #endif char * frureds[] = { "-no such reduction-", "fullpath : recordpath", "recordpath : element", "recordpath : element SEPIDENT recordpath", "recordpath : SEPIDENT recordpath", "element : NAME", "element : NAME ITERBEGIN itercount ITEREND", "itercount : NUMBER", "itercount : LAST", "itercount : ADD", }; #endif /* YYDEBUG */ # line 1 "/usr/share/lib/ccs/yaccpar" /* * CDDL HEADER START * * The contents of this file are subject to the terms of the * Common Development and Distribution License, Version 1.0 only * (the "License"). You may not use this file except in compliance * with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE * or http://www.opensolaris.org/os/licensing. * See the License for the specific language governing permissions * and limitations under the License. * * When distributing Covered Code, include this CDDL HEADER in each * file and include the License file at usr/src/OPENSOLARIS.LICENSE. * If applicable, add the following below this CDDL HEADER, with the * fields enclosed by brackets "[]" replaced with your own identifying * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* * Copyright 1993 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ #pragma ident "%Z%%M% %I% %E% SMI" /* ** Skeleton parser driver for yacc output */ /* ** yacc user known macros and defines */ #define YYERROR goto yyerrlab #define YYACCEPT return(0) #define YYABORT return(1) #define YYBACKUP( newtoken, newvalue )\ {\ if ( fruchar >= 0 || ( frur2[ frutmp ] >> 1 ) != 1 )\ {\ fruerror( "syntax error - cannot backup" );\ goto yyerrlab;\ }\ fruchar = newtoken;\ frustate = *frups;\ frulval = newvalue;\ goto yynewstate;\ } #define YYRECOVERING() (!!fruerrflag) #define YYNEW(type) malloc(sizeof(type) * yynewmax) #define YYCOPY(to, from, type) \ (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type)) #define YYENLARGE( from, type) \ (type *) realloc((char *) from, yynewmax * sizeof(type)) #ifndef YYDEBUG # define YYDEBUG 1 /* make debugging available */ #endif /* ** user known globals */ int frudebug; /* set to 1 to get debugging */ /* ** driver internal defines */ #define YYFLAG (-10000000) /* ** global variables used by the parser */ YYSTYPE *frupv; /* top of value stack */ int *frups; /* top of state stack */ int frustate; /* current state */ int frutmp; /* extra var (lasts between blocks) */ int frunerrs; /* number of errors */ int fruerrflag; /* error recovery flag */ int fruchar; /* current input token number */ #ifdef YYNMBCHARS #define YYLEX() yycvtok(frulex()) /* ** yycvtok - return a token if i is a wchar_t value that exceeds 255. ** If i<255, i itself is the token. If i>255 but the neither ** of the 30th or 31st bit is on, i is already a token. */ #if defined(__STDC__) || defined(__cplusplus) int yycvtok(int i) #else int yycvtok(i) int i; #endif { int first = 0; int last = YYNMBCHARS - 1; int mid; wchar_t j; if(i&0x60000000){/*Must convert to a token. */ if( yymbchars[last].character < i ){ return i;/*Giving up*/ } while ((last>=first)&&(first>=0)) {/*Binary search loop*/ mid = (first+last)/2; j = yymbchars[mid].character; if( j==i ){/*Found*/ return yymbchars[mid].tvalue; }else if( j= 0; yy_i++ ) { if ( frutoks[yy_i].t_val == fruchar ) break; } printf( "%s\n", frutoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ++yy_ps >= &frus[ yymaxdepth ] ) /* room on stack? */ { /* ** reallocate and recover. Note that pointers ** have to be reset, or bad things will happen */ long frups_index = (yy_ps - frus); long frupv_index = (yy_pv - fruv); long frupvt_index = (frupvt - fruv); int yynewmax; #ifdef YYEXPAND yynewmax = YYEXPAND(yymaxdepth); #else yynewmax = 2 * yymaxdepth; /* double table size */ if (yymaxdepth == YYMAXDEPTH) /* first time growth */ { char *newfrus = (char *)YYNEW(int); char *newfruv = (char *)YYNEW(YYSTYPE); if (newfrus != 0 && newfruv != 0) { frus = YYCOPY(newfrus, frus, int); fruv = YYCOPY(newfruv, fruv, YYSTYPE); } else yynewmax = 0; /* failed */ } else /* not first time */ { frus = YYENLARGE(frus, int); fruv = YYENLARGE(fruv, YYSTYPE); if (frus == 0 || fruv == 0) yynewmax = 0; /* failed */ } #endif if (yynewmax <= yymaxdepth) /* tables not expanded */ { fruerror( "yacc stack overflow" ); YYABORT; } yymaxdepth = yynewmax; yy_ps = frus + frups_index; yy_pv = fruv + frupv_index; frupvt = fruv + frupvt_index; } *yy_ps = yy_state; *++yy_pv = fruval; /* ** we have a new state - find out what to do */ yy_newstate: if ( ( yy_n = frupact[ yy_state ] ) <= YYFLAG ) goto frudefault; /* simple state */ #if YYDEBUG /* ** if debugging, need to mark whether new token grabbed */ frutmp = fruchar < 0; #endif if ( ( fruchar < 0 ) && ( ( fruchar = YYLEX() ) < 0 ) ) fruchar = 0; /* reached EOF */ #if YYDEBUG if ( frudebug && frutmp ) { register int yy_i; printf( "Received token " ); if ( fruchar == 0 ) printf( "end-of-file\n" ); else if ( fruchar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; frutoks[yy_i].t_val >= 0; yy_i++ ) { if ( frutoks[yy_i].t_val == fruchar ) break; } printf( "%s\n", frutoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( ( ( yy_n += fruchar ) < 0 ) || ( yy_n >= YYLAST ) ) goto frudefault; if ( fruchk[ yy_n = fruact[ yy_n ] ] == fruchar ) /*valid shift*/ { fruchar = -1; fruval = frulval; yy_state = yy_n; if ( fruerrflag > 0 ) fruerrflag--; goto yy_stack; } frudefault: if ( ( yy_n = frudef[ yy_state ] ) == -2 ) { #if YYDEBUG frutmp = fruchar < 0; #endif if ( ( fruchar < 0 ) && ( ( fruchar = YYLEX() ) < 0 ) ) fruchar = 0; /* reached EOF */ #if YYDEBUG if ( frudebug && frutmp ) { register int yy_i; printf( "Received token " ); if ( fruchar == 0 ) printf( "end-of-file\n" ); else if ( fruchar < 0 ) printf( "-none-\n" ); else { for ( yy_i = 0; frutoks[yy_i].t_val >= 0; yy_i++ ) { if ( frutoks[yy_i].t_val == fruchar ) { break; } } printf( "%s\n", frutoks[yy_i].t_name ); } } #endif /* YYDEBUG */ /* ** look through exception table */ { register YYCONST int *yyxi = fruexca; while ( ( *yyxi != -1 ) || ( yyxi[1] != yy_state ) ) { yyxi += 2; } while ( ( *(yyxi += 2) >= 0 ) && ( *yyxi != fruchar ) ) ; if ( ( yy_n = yyxi[1] ) < 0 ) YYACCEPT; } } /* ** check for syntax error */ if ( yy_n == 0 ) /* have an error */ { /* no worry about speed here! */ switch ( fruerrflag ) { case 0: /* new error */ fruerror( "syntax error" ); goto skip_init; yyerrlab: /* ** get globals into registers. ** we have a user generated syntax type error */ yy_pv = frupv; yy_ps = frups; yy_state = frustate; skip_init: frunerrs++; /* FALLTHRU */ case 1: case 2: /* incompletely recovered error */ /* try again... */ fruerrflag = 3; /* ** find state where "error" is a legal ** shift action */ while ( yy_ps >= frus ) { yy_n = frupact[ *yy_ps ] + YYERRCODE; if ( yy_n >= 0 && yy_n < YYLAST && fruchk[fruact[yy_n]] == YYERRCODE) { /* ** simulate shift of "error" */ yy_state = fruact[ yy_n ]; goto yy_stack; } /* ** current state has no shift on ** "error", pop stack */ #if YYDEBUG # define _POP_ "Error recovery pops state %d, uncovers state %d\n" if ( frudebug ) printf( _POP_, *yy_ps, yy_ps[-1] ); # undef _POP_ #endif yy_ps--; yy_pv--; } /* ** there is no state on stack with "error" as ** a valid shift. give up. */ YYABORT; case 3: /* no shift yet; eat a token */ #if YYDEBUG /* ** if debugging, look up token in list of ** pairs. 0 and negative shouldn't occur, ** but since timing doesn't matter when ** debugging, it doesn't hurt to leave the ** tests here. */ if ( frudebug ) { register int yy_i; printf( "Error recovery discards " ); if ( fruchar == 0 ) printf( "token end-of-file\n" ); else if ( fruchar < 0 ) printf( "token -none-\n" ); else { for ( yy_i = 0; frutoks[yy_i].t_val >= 0; yy_i++ ) { if ( frutoks[yy_i].t_val == fruchar ) { break; } } printf( "token %s\n", frutoks[yy_i].t_name ); } } #endif /* YYDEBUG */ if ( fruchar == 0 ) /* reached EOF. quit */ YYABORT; fruchar = -1; goto yy_newstate; } }/* end if ( yy_n == 0 ) */ /* ** reduction by production yy_n ** put stack tops, etc. so things right after switch */ #if YYDEBUG /* ** if debugging, print the string that is the user's ** specification of the reduction which is just about ** to be done. */ if ( frudebug ) printf( "Reduce by (%d) \"%s\"\n", yy_n, frureds[ yy_n ] ); #endif frutmp = yy_n; /* value to switch over */ frupvt = yy_pv; /* $vars top of value stack */ /* ** Look in goto table for next state ** Sorry about using yy_state here as temporary ** register variable, but why not, if it works... ** If frur2[ yy_n ] doesn't have the low order bit ** set, then there is no action to be done for ** this reduction. So, no saving & unsaving of ** registers done. The only difference between the ** code just after the if and the body of the if is ** the goto yy_stack in the body. This way the test ** can be made before the choice of what to do is needed. */ { /* length of production doubled with extra bit */ register int yy_len = frur2[ yy_n ]; if ( !( yy_len & 01 ) ) { yy_len >>= 1; fruval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = frupgo[ yy_n = frur1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || fruchk[ yy_state = fruact[ yy_state ] ] != -yy_n ) { yy_state = fruact[ frupgo[ yy_n ] ]; } goto yy_stack; } yy_len >>= 1; fruval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */ yy_state = frupgo[ yy_n = frur1[ yy_n ] ] + *( yy_ps -= yy_len ) + 1; if ( yy_state >= YYLAST || fruchk[ yy_state = fruact[ yy_state ] ] != -yy_n ) { yy_state = fruact[ frupgo[ yy_n ] ]; } } /* save until reenter driver code */ frustate = yy_state; frups = yy_ps; frupv = yy_pv; } /* ** code supplied by user is placed in this switch */ switch( frutmp ) { case 1: # line 67 "../libfru/nameSyntaxYacc.y" { gParserHead = frupvt[-0].pathDef; gParserAnts = Ancestor::listTaggedAncestors((char *)frupvt[-0].pathDef->def->name); } break; case 2: # line 75 "../libfru/nameSyntaxYacc.y" { fruval.pathDef = frupvt[-0].pathDef; } break; case 3: # line 79 "../libfru/nameSyntaxYacc.y" { if (frupvt[-2].pathDef->def->dataType != FDTYPE_Record) { fruerror (NULL); YYABORT; } int found = 0; for ( int i=0;idef->enumCount;i++) { if ( strcmp (frupvt[-0].pathDef->def->name, frupvt[-2].pathDef->def->enumTable[i].text) == 0 ) found = 1; } if ( !found ) { fruerror (NULL); YYABORT; } // insert it in the list. frupvt[-2].pathDef->next = frupvt[-0].pathDef; // return the head of the list. fruval.pathDef = frupvt[-2].pathDef; } break; case 4: # line 102 "../libfru/nameSyntaxYacc.y" { // absolute path definitions MUST start with tagged elements. if ( frupvt[-0].pathDef->def->tagType == FRU_X ) { fruerror ("First Element of absolute path MUST be tagged"); YYABORT; } *gParserAbs = 1; fruval.pathDef = frupvt[-0].pathDef; } break; case 5: # line 115 "../libfru/nameSyntaxYacc.y" { const fru_regdef_t *def = fru_reg_lookup_def_by_name(frupvt[-0].name); if ( def == NULL ) { fruerror (NULL); gParserErrno = FRU_NOREGDEF; free (frupvt[-0].name); // the lexer allocates this memory. YYABORT; } PathDef *pathDef = new PathDef; pathDef->def = (fru_regdef_t *)def; pathDef->iterIndex = 0; pathDef->next = NULL; free (frupvt[-0].name); // the lexer allocates this memory. fruval.pathDef = pathDef; } break; case 6: # line 132 "../libfru/nameSyntaxYacc.y" { const fru_regdef_t *def = fru_reg_lookup_def_by_name(frupvt[-3].name); if ( def == NULL ) { fruerror (NULL); gParserErrno = FRU_NOREGDEF; free (frupvt[-3].name); // the lexer allocates this memory. YYABORT; } if ( def->iterationType == FRU_NOT_ITERATED ) { fruerror (NULL); free (frupvt[-3].name); // the lexer allocates this memory. YYABORT; } if ( (frupvt[-1].num != PathDef::lastIteration) && (frupvt[-1].num != PathDef::addIteration) ) { if ( (frupvt[-1].num >= def->iterationCount) || (frupvt[-1].num < 0) ) { fruerror (NULL); free (frupvt[-3].name); // the lexer allocates this memory. YYABORT; } } PathDef *pathDef = new PathDef; pathDef->def = (fru_regdef_t *)def; pathDef->iterIndex = frupvt[-1].num; pathDef->next = NULL; free (frupvt[-3].name); // the lexer allocates this memory. fruval.pathDef = pathDef; } break; case 7: # line 167 "../libfru/nameSyntaxYacc.y" { fruval.num = frupvt[-0].num; } break; case 8: # line 169 "../libfru/nameSyntaxYacc.y" { fruval.num = PathDef::lastIteration; } break; case 9: # line 171 "../libfru/nameSyntaxYacc.y" { fruval.num = PathDef::addIteration; } break; # line 556 "/usr/share/lib/ccs/yaccpar" } goto frustack; /* reset registers in driver code */ }