⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lab3.tab.c

📁 c—语言的句法分析器。读入一个C--语言程序
💻 C
📖 第 1 页 / 共 4 页
字号:

/*  A Bison parser, made from lab3.y
    by GNU Bison version 1.28  */

#define YYBISON 1  /* Identify Bison output.  */

#define	IF	257
#define	ELSE	258
#define	WHILE	259
#define	RETURN	260
#define	VOID	261
#define	INT	262
#define	CHAR	263
#define	ID	264
#define	NUM	265
#define	NE	266
#define	LT	267
#define	LE	268
#define	EQ	269
#define	GT	270
#define	GE	271
#define	ADDOP	272
#define	CHAR_LITERAL	273
#define	STRING_LITERAL	274
#define	CDECL	275
#define	STDCALL	276
#define	ELLIPSIS	277
#define	IFX	278

#line 1 "lab3.y"

#include "lab3.h"

#define YYERROR_VERBOSE 1

tablelen = 0;
level = 0;
right = 1;
typecount = 0;
typecheck = 0;

#line 13 "lab3.y"
typedef union {
    char *id;             /* identifier */
    int  value;           /* value */
    char op[3];           /* operator */
    symbol *sign;         /* symbol */
    expr expn;            /* expression */
} YYSTYPE;
#include <stdio.h>

#ifndef __cplusplus
#ifndef __STDC__
#define const
#endif
#endif



#define	YYFINAL		129
#define	YYFLAG		-32768
#define	YYNTBASE	39

#define YYTRANSLATE(x) ((unsigned)(x) <= 278 ? yytranslate[x] : 72)

static const char yytranslate[] = {     0,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,    36,     2,     2,    31,
    32,    26,    37,    33,    38,     2,    27,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,    28,     2,
    25,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
    29,     2,    30,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,    34,     2,    35,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
     7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
    17,    18,    19,    20,    21,    22,    23,    24
};

#if YYDEBUG != 0
static const short yyprhs[] = {     0,
     0,     1,     4,     7,     9,    11,    13,    17,    24,    29,
    37,    39,    41,    43,    46,    49,    56,    62,    64,    66,
    70,    72,    75,    79,    84,    86,    91,    94,    95,    98,
    99,   101,   103,   105,   107,   109,   112,   114,   120,   128,
   134,   137,   141,   145,   147,   149,   154,   158,   160,   162,
   164,   166,   168,   170,   172,   176,   178,   182,   184,   186,
   188,   190,   193,   195,   197,   199,   203,   205,   207,   209,
   211,   213,   218,   220,   221,   225,   227,   229
};

static const short yyrhs[] = {    -1,
    40,    41,     0,    41,    42,     0,    42,     0,    43,     0,
    45,     0,    44,    10,    28,     0,    44,    10,    29,    11,
    30,    28,     0,    44,    26,    10,    28,     0,    44,    26,
    10,    29,    11,    30,    28,     0,     8,     0,     7,     0,
     9,     0,    46,    50,     0,    46,    28,     0,    44,    71,
    10,    31,    47,    32,     0,    44,    10,    31,    47,    32,
     0,    48,     0,     7,     0,    48,    33,    49,     0,    49,
     0,    44,    10,     0,    44,    26,    10,     0,    44,    10,
    29,    30,     0,    23,     0,    34,    51,    52,    35,     0,
    51,    43,     0,     0,    52,    53,     0,     0,    54,     0,
    50,     0,    55,     0,    56,     0,    57,     0,    58,    28,
     0,    28,     0,     3,    31,    58,    32,    53,     0,     3,
    31,    58,    32,    53,     4,    53,     0,     5,    31,    58,
    32,    53,     0,     6,    28,     0,     6,    58,    28,     0,
    59,    25,    58,     0,    60,     0,    10,     0,    10,    29,
    58,    30,     0,    62,    61,    62,     0,    62,     0,    14,
     0,    13,     0,    16,     0,    17,     0,    15,     0,    12,
     0,    62,    18,    63,     0,    63,     0,    63,    64,    65,
     0,    65,     0,    26,     0,    27,     0,    36,     0,    66,
    65,     0,    67,     0,    37,     0,    38,     0,    31,    58,
    32,     0,    59,     0,    68,     0,    11,     0,    19,     0,
    20,     0,    10,    31,    69,    32,     0,    70,     0,     0,
    70,    33,    58,     0,    58,     0,    21,     0,    22,     0
};

#endif

#if YYDEBUG != 0
static const short yyrline[] = { 0,
    50,    69,    76,    82,    90,    96,   104,   118,   132,   146,
   162,   169,   176,   185,   193,   203,   222,   243,   249,   266,
   272,   280,   307,   334,   361,   378,   386,   392,   395,   401,
   404,   410,   416,   422,   428,   436,   442,   450,   456,   464,
   472,   478,   486,   499,   508,   519,   532,   586,   595,   601,
   607,   613,   619,   625,   633,   655,   664,   688,   697,   704,
   711,   720,   738,   747,   754,   763,   770,   780,   787,   795,
   803,   813,   833,   839,   842,   857,   874,   880
};
#endif


#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)

static const char * const yytname[] = {   "$","error","$undefined.","IF","ELSE",
"WHILE","RETURN","VOID","INT","CHAR","ID","NUM","NE","LT","LE","EQ","GT","GE",
"ADDOP","CHAR_LITERAL","STRING_LITERAL","CDECL","STDCALL","ELLIPSIS","IFX","'='",
"'*'","'/'","';'","'['","']'","'('","')'","','","'{'","'}'","'%'","'+'","'-'",
"program","@1","declaration_list","declaration","var_declaration","type_specifer",
"fun_declaration","fun_tag","params","param_list","param","compound_stmt","local_declarations",
"statement_list","statement","expression_stmt","if_stmt","while_stmt","return_stmt",
"expression","var","simple_expression","relop","additive_expression","term",
"mulop","unary_expression","unaryop","factor","call","args","arg_list","calling_convention", NULL
};
#endif

static const short yyr1[] = {     0,
    40,    39,    41,    41,    42,    42,    43,    43,    43,    43,
    44,    44,    44,    45,    45,    46,    46,    47,    47,    48,
    48,    49,    49,    49,    49,    50,    51,    51,    52,    52,
    53,    53,    53,    53,    53,    54,    54,    55,    55,    56,
    57,    57,    58,    58,    59,    59,    60,    60,    61,    61,
    61,    61,    61,    61,    62,    62,    63,    63,    64,    64,
    64,    65,    65,    66,    66,    67,    67,    67,    67,    67,
    67,    68,    69,    69,    70,    70,    71,    71
};

static const short yyr2[] = {     0,
     0,     2,     2,     1,     1,     1,     3,     6,     4,     7,
     1,     1,     1,     2,     2,     6,     5,     1,     1,     3,
     1,     2,     3,     4,     1,     4,     2,     0,     2,     0,
     1,     1,     1,     1,     1,     2,     1,     5,     7,     5,
     2,     3,     3,     1,     1,     4,     3,     1,     1,     1,
     1,     1,     1,     1,     3,     1,     3,     1,     1,     1,
     1,     2,     1,     1,     1,     3,     1,     1,     1,     1,
     1,     4,     1,     0,     3,     1,     1,     1
};

static const short yydefact[] = {     1,
     0,    12,    11,    13,     2,     4,     5,     0,     6,     0,
     3,     0,    77,    78,     0,     0,    15,    28,    14,     7,
     0,     0,     0,     0,    30,     0,    12,    25,     0,     0,
    18,    21,     9,     0,     0,    27,     0,     0,     0,    22,
     0,    17,     0,     0,     0,     0,     0,     0,     0,    45,
    69,    70,    71,    37,     0,    26,    64,    65,    32,    29,
    31,    33,    34,    35,     0,    67,    44,    48,    56,    58,
     0,    63,    68,     8,     0,    23,    20,     0,    16,     0,
     0,    41,     0,     0,    74,     0,    36,     0,    54,    50,
    49,    53,    51,    52,     0,     0,    59,    60,    61,     0,
    67,    62,    24,    10,     0,     0,    42,     0,    76,     0,
    73,    66,    43,    55,    47,    57,     0,     0,    46,    72,
     0,    38,    40,    75,     0,    39,     0,     0,     0
};

static const short yydefgoto[] = {   127,
     1,     5,     6,     7,    29,     9,    10,    30,    31,    32,
    59,    25,    38,    60,    61,    62,    63,    64,    65,    66,
    67,    96,    68,    69,   100,    70,    71,    72,    73,   110,
   111,    16
};

static const short yypact[] = {-32768,
    89,-32768,-32768,-32768,    89,-32768,-32768,    -8,-32768,    61,
-32768,    62,-32768,-32768,     5,    36,-32768,-32768,-32768,-32768,
    38,    15,    -9,    34,    89,    37,    56,-32768,    -5,    60,
    41,-32768,-32768,    58,    15,-32768,    32,     6,    81,    82,
   100,-32768,    76,    83,    80,    79,    84,    85,    40,   -21,
-32768,-32768,-32768,-32768,    44,-32768,-32768,-32768,-32768,-32768,
-32768,-32768,-32768,-32768,    86,    92,-32768,    88,    30,-32768,
    44,-32768,-32768,-32768,    90,-32768,-32768,    91,-32768,    44,
    44,-32768,    93,    44,    44,    94,-32768,    44,-32768,-32768,
-32768,-32768,-32768,-32768,    44,    44,-32768,-32768,-32768,    44,
-32768,-32768,-32768,-32768,    95,    96,-32768,    99,-32768,    98,
   101,-32768,-32768,    30,   104,-32768,    42,    42,-32768,-32768,
    44,   114,-32768,-32768,    42,-32768,   123,   124,-32768
};

static const short yypgoto[] = {-32768,
-32768,-32768,   120,   106,     2,-32768,-32768,    97,-32768,   102,
   125,-32768,-32768,   -31,-32768,-32768,-32768,-32768,   -49,   -67,
-32768,-32768,    43,    45,-32768,   -70,-32768,-32768,-32768,-32768,
-32768,-32768
};


#define	YYLAST		145


static const short yytable[] = {    83,
   102,    12,     8,   101,    40,    86,     8,    84,    47,    85,
    48,    49,    13,    14,    23,    50,    51,    15,    33,    34,
    41,    27,     3,     4,    52,    53,    37,   101,   101,   116,
   105,   106,   101,    54,   108,   109,    55,    28,   113,    18,
    56,    46,    57,    58,    47,    24,    48,    49,    26,    50,
    51,    50,    51,    50,    51,    97,    98,    15,    52,    53,
    52,    53,    52,    53,    35,    99,    39,    82,    44,    54,
    55,   124,    55,    43,    55,    18,    57,    58,    57,    58,
    57,    58,     2,     3,     4,   122,   123,   -19,    17,    20,
    21,    42,    22,   126,    18,     2,     3,     4,    28,    89,
    90,    91,    92,    93,    94,    95,    20,    21,    74,    76,
    75,    79,    78,    87,    80,    81,    88,   125,   104,   103,
   107,    95,   128,   129,    11,   112,   117,   118,   119,   120,
    36,    45,     0,   121,    19,     0,     0,     0,   115,   114,
     0,     0,     0,     0,    77
};

static const short yycheck[] = {    49,
    71,    10,     1,    71,    10,    55,     5,    29,     3,    31,
     5,     6,    21,    22,    10,    10,    11,    26,    28,    29,
    26,     7,     8,     9,    19,    20,    25,    95,    96,   100,
    80,    81,   100,    28,    84,    85,    31,    23,    88,    34,
    35,    10,    37,    38,     3,    10,     5,     6,    11,    10,
    11,    10,    11,    10,    11,    26,    27,    26,    19,    20,
    19,    20,    19,    20,    31,    36,    30,    28,    11,    28,
    31,   121,    31,    33,    31,    34,    37,    38,    37,    38,
    37,    38,     7,     8,     9,   117,   118,    32,    28,    28,
    29,    32,    31,   125,    34,     7,     8,     9,    23,    12,
    13,    14,    15,    16,    17,    18,    28,    29,    28,    10,
    29,    32,    30,    28,    31,    31,    25,     4,    28,    30,
    28,    18,     0,     0,     5,    32,    32,    32,    30,    32,
    25,    35,    -1,    33,    10,    -1,    -1,    -1,    96,    95,
    -1,    -1,    -1,    -1,    43
};
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
#line 3 "/usr/local/share/bison.simple"
/* This file comes from bison-1.28.  */

/* Skeleton output parser for bison,
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

/* This is the parser code that is written into each bison parser
  when the %semantic_parser declaration is not specified in the grammar.
  It was written by Richard Stallman by simplifying the hairy parser
  used when %semantic_parser is specified.  */

#ifndef YYSTACK_USE_ALLOCA
#ifdef alloca
#define YYSTACK_USE_ALLOCA
#else /* alloca not defined */
#ifdef __GNUC__
#define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#else /* not GNU C.  */
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
#define YYSTACK_USE_ALLOCA
#include <alloca.h>
#else /* not sparc */
/* We think this test detects Watcom and Microsoft C.  */
/* This used to test MSDOS, but that is a bad idea
   since that symbol is in the user namespace.  */
#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
#if 0 /* No need for malloc.h, which pollutes the namespace;
	 instead, just don't use alloca.  */
#include <malloc.h>
#endif
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
/* I don't know what this was needed for, but it pollutes the namespace.
   So I turned it off.   rms, 2 May 1997.  */
/* #include <malloc.h>  */
 #pragma alloca
#define YYSTACK_USE_ALLOCA
#else /* not MSDOS, or __TURBOC__, or _AIX */
#if 0
#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
		 and on HPUX 10.  Eventually we can turn this on.  */
#define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#endif /* __hpux */
#endif
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
#endif /* not sparc */
#endif /* not GNU C */
#endif /* alloca not defined */
#endif /* YYSTACK_USE_ALLOCA not defined */

#ifdef YYSTACK_USE_ALLOCA
#define YYSTACK_ALLOC alloca
#else
#define YYSTACK_ALLOC malloc
#endif

/* Note: there must be only one dollar sign in this file.
   It is replaced by the list of actions, each action
   as one case of the switch.  */

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		-2
#define YYEOF		0
#define YYACCEPT	goto yyacceptlab
#define YYABORT 	goto yyabortlab
#define YYERROR		goto yyerrlab1
/* Like YYERROR except do call yyerror.
   This remains here temporarily to ease the
   transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */
#define YYFAIL		goto yyerrlab
#define YYRECOVERING()  (!!yyerrstatus)
#define YYBACKUP(token, value) \
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    { yychar = (token), yylval = (value);			\
      yychar1 = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

#ifndef YYPURE
#define YYLEX		yylex()
#endif

#ifdef YYPURE
#ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX		yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX		yylex(&yylval)
#endif
#endif /* not YYLSP_NEEDED */
#endif

/* If nonreentrant, generate the variables here */

#ifndef YYPURE

int	yychar;			/*  the lookahead symbol		*/
YYSTYPE	yylval;			/*  the semantic value of the		*/
				/*  lookahead symbol			*/

#ifdef YYLSP_NEEDED
YYLTYPE yylloc;			/*  location data for the lookahead	*/
				/*  symbol				*/
#endif

int yynerrs;			/*  number of parse errors so far       */
#endif  /* not YYPURE */

#if YYDEBUG != 0
int yydebug;			/*  nonzero means print parse trace	*/
/* Since this is uninitialized, it does not stop multiple parsers
   from coexisting.  */
#endif

/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/

#ifndef	YYINITDEPTH
#define YYINITDEPTH 200
#endif

/*  YYMAXDEPTH is the maximum size the stacks can grow to
    (effective only if the built-in stack extension method is used).  */

#if YYMAXDEPTH == 0
#undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif

/* Define __yy_memcpy.  Note that the size argument
   should be passed with type unsigned int, because that is what the non-GCC
   definitions require.  With GCC, __builtin_memcpy takes an arg
   of type size_t, but it can handle unsigned int.  */

#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
#define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
#else				/* not GNU C or C++ */
#ifndef __cplusplus

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (to, from, count)
     char *to;
     char *from;
     unsigned int count;
{
  register char *f = from;
  register char *t = to;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#else /* __cplusplus */

/* This is the most reliable way to avoid incompatibilities
   in available built-in functions on various systems.  */
static void
__yy_memcpy (char *to, char *from, unsigned int count)
{
  register char *t = to;
  register char *f = from;
  register int i = count;

  while (i-- > 0)
    *t++ = *f++;
}

#endif
#endif

#line 217 "/usr/local/share/bison.simple"

/* The user can define YYPARSE_PARAM as the name of an argument to be passed
   into yyparse.  The argument should have type void *.
   It should actually point to an object.
   Grammar actions can access the variable by casting it
   to the proper pointer type.  */

#ifdef YYPARSE_PARAM
#ifdef __cplusplus
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
#define YYPARSE_PARAM_DECL
#else /* not __cplusplus */
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
#endif /* not __cplusplus */
#else /* not YYPARSE_PARAM */
#define YYPARSE_PARAM_ARG
#define YYPARSE_PARAM_DECL

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -