Current Path : /sys/amd64/compile/hs32/modules/usr/src/sys/modules/mvs/@/amd64/compile/hs32/modules/usr/src/sys/modules/aic7xxx/aicasm/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //sys/amd64/compile/hs32/modules/usr/src/sys/modules/mvs/@/amd64/compile/hs32/modules/usr/src/sys/modules/aic7xxx/aicasm/aicasm_macro_gram.c |
#include <stdlib.h> #include <string.h> #ifndef lint #ifdef __unused __unused #endif static char const yyrcsid[] = "$FreeBSD: release/9.1.0/usr.bin/yacc/skeleton.c 216370 2010-12-11 08:32:16Z joel $"; #endif #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) #if defined(__cplusplus) || __STDC__ static int yygrowstack(void); #else static int yygrowstack(); #endif #define yyparse mmparse #define yylex mmlex #define yyerror mmerror #define yychar mmchar #define yyval mmval #define yylval mmlval #define yydebug mmdebug #define yynerrs mmnerrs #define yyerrflag mmerrflag #define yyss mmss #define yyssp mmssp #define yyvs mmvs #define yyvsp mmvsp #define yylhs mmlhs #define yylen mmlen #define yydefred mmdefred #define yydgoto mmdgoto #define yysindex mmsindex #define yyrindex mmrindex #define yygindex mmgindex #define yytable mmtable #define yycheck mmcheck #define yyname mmname #define yyrule mmrule #define yysslim mmsslim #define yystacksize mmstacksize #define YYPREFIX "mm" #line 2 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" /*- * Sub-parser for macro invocation in the Aic7xxx SCSI * Host adapter sequencer assembler. * * Copyright (c) 2001 Adaptec Inc. * 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, * without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer * substantially similar to the "NO WARRANTY" disclaimer below * ("Disclaimer") and any redistribution must be conditioned upon * including a substantially similar Disclaimer requirement for further * binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR 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 DAMAGES. * * $Id: //depot/aic7xxx/aic7xxx/aicasm/aicasm_macro_gram.y#5 $ * * $FreeBSD: release/9.1.0/sys/dev/aic7xxx/aicasm/aicasm_macro_gram.y 224046 2011-07-15 00:36:47Z emaste $ */ #include <sys/types.h> #include <inttypes.h> #include <regex.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sysexits.h> #include <sys/queue.h> #include "aicasm.h" #include "aicasm_symbol.h" #include "aicasm_insformat.h" static symbol_t *macro_symbol; static void add_macro_arg(const char *argtext, int position); extern int mmlex(void); extern int mmparse(void); #line 69 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" typedef union { int value; char *str; symbol_t *sym; } YYSTYPE; #line 123 "aicasm_macro_gram.c" #define YYERRCODE 256 #define T_ARG 257 #define T_SYMBOL 258 const short mmlhs[] = { -1, 2, 0, 1, 1, 1, }; const short mmlen[] = { 2, 0, 5, 0, 1, 3, }; const short mmdefred[] = { 0, 0, 0, 1, 0, 4, 0, 2, 0, 5, }; const short mmdgoto[] = { 2, 6, 4, }; const short mmsindex[] = { -256, -35, 0, 0, -251, 0, -41, 0, -250, 0, }; const short mmrindex[] = { 0, 0, 0, 0, -40, 0, 0, 0, 0, 0, }; const short mmgindex[] = { 0, 0, 0, }; #define YYTABLESIZE 7 const short mmtable[] = { 7, 3, 1, 8, 3, 3, 5, 9, }; const short mmcheck[] = { 41, 41, 258, 44, 44, 40, 257, 257, }; #define YYFINAL 2 #ifndef YYDEBUG #define YYDEBUG 0 #endif #define YYMAXTOKEN 258 #if YYDEBUG const char * const mmname[] = { "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,0,0,0,0,0,"T_ARG","T_SYMBOL", }; const char * const mmrule[] = { "$accept : macrocall", "$$1 :", "macrocall : T_SYMBOL '(' $$1 macro_arglist ')'", "macro_arglist :", "macro_arglist : T_ARG", "macro_arglist : macro_arglist ',' T_ARG", }; #endif #if YYDEBUG #include <stdio.h> #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 125 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" static void add_macro_arg(const char *argtext, int argnum) { struct macro_arg *marg; int i; if (macro_symbol == NULL || macro_symbol->type != MACRO) { stop("Invalid current symbol for adding macro arg", EX_SOFTWARE); /* NOTREACHED */ } /* * Macro Invocation. Find the appropriate argument and fill * in the replace ment text for this call. */ i = 0; STAILQ_FOREACH(marg, ¯o_symbol->info.macroinfo->args, links) { i++; if (i == argnum) break; } if (marg == NULL) { stop("Too many arguments for macro invocation", EX_DATAERR); /* NOTREACHED */ } marg->replacement_text = strdup(argtext); if (marg->replacement_text == NULL) { stop("Unable to replicate replacement text", EX_SOFTWARE); /* NOTREACHED */ } } static void mmerror(const char *string) { stop(string, EX_DATAERR); } #line 245 "aicasm_macro_gram.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ #if defined(__cplusplus) || __STDC__ static int yygrowstack(void) #else static int yygrowstack() #endif { 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 { int yym, yyn, yystate; #if YYDEBUG 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]; if (yym) yyval = yyvsp[1-yym]; else memset(&yyval, 0, sizeof yyval); switch (yyn) { case 1: #line 86 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" { macro_symbol = yyvsp[-1].sym; } break; case 2: #line 90 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" { if (macro_symbol->info.macroinfo->narg != yyvsp[-1].value) { printf("Narg == %d", macro_symbol->info.macroinfo->narg); stop("Too few arguments for macro invocation", EX_DATAERR); /* NOTREACHED */ } macro_symbol = NULL; YYACCEPT; } break; case 3: #line 103 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" { /* Macros can take 0 arguments */ yyval.value = 0; } break; case 4: #line 108 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" { yyval.value = 1; add_macro_arg(yyvsp[0].str, 1); } break; case 5: #line 113 "/usr/src/sys/modules/aic7xxx/aicasm/../../../dev/aic7xxx/aicasm/aicasm_macro_gram.y" { if (yyvsp[-2].value == 0) { stop("Comma without preceding argument in arg list", EX_DATAERR); /* NOTREACHED */ } yyval.value = yyvsp[-2].value + 1; add_macro_arg(yyvsp[0].str, yyval.value); } break; #line 492 "aicasm_macro_gram.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); }