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

📄 snapparse.c

📁 一个学习SNMP项目:tmoerlan.
💻 C
📖 第 1 页 / 共 4 页
字号:
/* A Bison parser, made from snapparse.y   by GNU bison 1.35.  */#define YYBISON 1  /* Identify Bison output.  */# define	T_INTV	257# define	T_ADDRV	258# define	T_STRV	259# define	T_EXCV	260# define	T_FLOATV	261# define	T_MAIN	262# define	T_EXIT	263# define	T_PUSH	264# define	T_POP	265# define	T_POPI	266# define	T_PULL	267# define	T_EQ	268# define	T_EQI	269# define	T_PAJ	270# define	T_TPAJ	271# define	T_BEZ	272# define	T_BNE	273# define	T_STORE	274# define	T_JI	275# define	T_NEQ	276# define	T_NEQI	277# define	T_ADD	278# define	T_ADDI	279# define	T_SUB	280# define	T_SUBI	281# define	T_MULT	282# define	T_MULTI	283# define	T_DIV	284# define	T_DIVI	285# define	T_MOD	286# define	T_MODI	287# define	T_NEG	288# define	T_NOT	289# define	T_LNOT	290# define	T_AND	291# define	T_ANDI	292# define	T_OR	293# define	T_ORI	294# define	T_LSHL	295# define	T_LSHLI	296# define	T_RSHL	297# define	T_RSHLI	298# define	T_RSHA	299# define	T_RSHAI	300# define	T_SNET	301# define	T_SNETI	302# define	T_BCAST	303# define	T_BCASTI	304# define	T_ISX	305# define	T_GETRB	306# define	T_GETSRC	307# define	T_GETDST	308# define	T_GETSPT	309# define	T_HERE	310# define	T_ISHERE	311# define	T_ROUTE	312# define	T_RTDEV	313# define	T_SEND	314# define	T_HOP	315# define	T_FORW	316# define	T_FORWTO	317# define	T_DEMUX	318# define	T_DEMUXI	319# define	T_PRINT	320# define	T_GETLD	321# define	T_SETXH	322# define	T_RAISEX	323# define	T_PLUS	324# define	T_MINUS	325# define	T_LABEL	326# define	T_LABELV	327# define	T_PC	328# define	T_MKTUP	329# define	T_LEN	330# define	T_NTH	331# define	T_ISTUP	332# define	T_LPAREN	333# define	T_RPAREN	334# define	T_COMMA	335# define	T_SVCV	336# define	T_CALLS	337# define	T_GT	338# define	T_GEQ	339# define	T_LT	340# define	T_LEQ	341# define	T_GTI	342# define	T_GEQI	343# define	T_LTI	344# define	T_LEQI	345# define	T_DATA	346# define	T_DFORW	347# define	T_DFORWTO	348# define	T_DSEND	349# define	T_STACKEMPTY	350# define	T_STACKCOUNT	351# define	T_PULLSTACK	352#line 1 "snapparse.y"/* snap-1.0. Copyright (C) 2000 by Jonathan T. Moore and Michael Hicks. * * snapparse.y : yacc parser for SNAP assembly language * * $Id: snapparse.c,v 1.2 2003/09/17 11:26:10 tmoerlan Exp $ */#include "../lib/config.h"#include <errno.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <assert.h>#include <netinet/in.h>#include "../lib/bytecode.h"#include "../lib/dyncheck.h"#include "../lib/packet.h"#include "../lib/io.h"#include "../lib/memalloc.h"#include "labels.h"#include "../lib/d_printf.h"#include "../lib/list.h"extern packet_t *p;#define CHECK_CODE_OVERFLOW(p)				\if ((p)->pc >= (p)->code_max) {			\  fprintf(stderr,"%s:%d: code overflow\n",	\	  __FILE__,__LINE__);			\  fflush(stderr);				\  exit(1);					\}int newho(buffer_t *b,char *file,int line);int newtup(list_t *vlist, char *file, int line);#ifdef SMALL_INSTRSOPCODE_T refine_op(OPCODE_T op, TAG_T vtag);#endifvoid yyerror(char *s);/* literal values from the lexer */extern int value_int;extern uint32 value_addr;extern buffer_t value_str;extern int value_exc;extern float32 value_float;extern int noop;static char *label = NULL;#line 56 "snapparse.y"#ifndef YYSTYPEtypedef union {  void *ptr;  int integer;} yystype;# define YYSTYPE yystype# define YYSTYPE_IS_TRIVIAL 1#endif#ifndef YYDEBUG# define YYDEBUG 0#endif#define	YYFINAL		117#define	YYFLAG		-32768#define	YYNTBASE	99/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */#define YYTRANSLATE(x) ((unsigned)(x) <= 352 ? yytranslate[x] : 109)/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */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,     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,     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,    25,      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,      36,    37,    38,    39,    40,    41,    42,    43,    44,    45,      46,    47,    48,    49,    50,    51,    52,    53,    54,    55,      56,    57,    58,    59,    60,    61,    62,    63,    64,    65,      66,    67,    68,    69,    70,    71,    72,    73,    74,    75,      76,    77,    78,    79,    80,    81,    82,    83,    84,    85,      86,    87,    88,    89,    90,    91,    92,    93,    94,    95,      96,    97,    98};#if YYDEBUGstatic const short yyprhs[] ={       0,     0,     3,     4,     6,     9,    12,    15,    18,    20,      22,    25,    27,    29,    31,    33,    35,    37,    39,    41,      43,    45,    47,    49,    51,    53,    55,    57,    59,    61,      63,    65,    67,    69,    71,    73,    75,    77,    79,    81,      83,    85,    87,    89,    91,    93,    95,    97,    99,   101,     103,   105,   107,   109,   111,   113,   115,   117,   119,   121,     123,   125,   127,   129,   131,   133,   135,   137,   139,   141,     143,   145,   147,   149,   151,   153,   155,   157,   159,   161,     163,   165,   167,   169,   171,   173,   175,   177,   179,   181,     183,   185,   187,   189,   191,   193,   195,   197,   201,   205,     207,   211,   215,   217,   219};static const short yyrhs[] ={     100,    99,     0,     0,   101,     0,   102,   108,     0,   103,       4,     0,   104,     5,     0,   105,   106,     0,     8,     0,      72,     0,    92,   106,     0,     9,     0,    11,     0,    14,       0,    22,     0,    24,     0,    26,     0,    28,     0,    30,       0,    32,     0,    34,     0,    35,     0,    36,     0,    37,       0,    39,     0,    41,     0,    43,     0,    45,     0,    51,       0,    52,     0,    53,     0,    54,     0,    55,     0,    67,       0,    68,     0,    69,     0,    56,     0,    57,     0,    58,       0,    59,     0,    60,     0,    61,     0,    62,     0,    63,       0,    64,     0,    66,     0,    76,     0,    78,     0,    47,       0,    49,     0,    84,     0,    85,     0,    86,     0,    87,       0,    95,     0,    93,     0,    94,     0,    96,     0,    97,       0,    98,     0,    13,     0,    20,     0,    16,     0,    17,       0,    18,     0,    19,     0,    12,     0,    33,     0,    38,       0,    40,     0,    42,     0,    44,     0,    46,     0,    21,       0,    75,     0,    77,     0,    50,     0,    65,     0,    48,       0,    82,     0,    83,     0,    10,     0,    15,     0,    23,       0,    25,     0,    27,     0,    29,     0,    31,     0,    88,       0,    89,     0,    90,     0,    91,     0,   108,     0,     4,       0,     7,     0,     5,     0,     6,     0,    79,   107,    80,       0,   106,    81,   107,     0,   106,     0,   108,    70,   108,       0,   108,    71,   108,     0,    74,     0,     3,     0,    73,       0};#endif#if YYDEBUG/* YYRLINE[YYN] -- source line where rule number YYN was defined. */static const short yyrline[] ={       0,    87,    88,    91,    96,   112,   127,   134,   152,   153,     154,   170,   171,   172,   173,   174,   175,   176,   177,   178,     179,   180,   181,   182,   183,   184,   185,   186,   187,   188,     189,   190,   191,   192,   193,   194,   195,   196,   197,   198,     199,   200,   201,   202,   203,   204,   205,   206,   207,   208,     209,   210,   211,   212,   213,   214,   215,   216,   217,   218,     221,   222,   223,   224,   225,   226,   227,   228,   229,   230,     231,   232,   233,   234,   235,   236,   239,   240,   241,   244,     245,   248,   249,   250,   251,   252,   253,   254,   255,   256,     257,   258,   261,   273,   288,   303,   311,   324,   335,   337,     340,   341,   342,   343,   344};#endif#if (YYDEBUG) || defined YYERROR_VERBOSE/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */static const char *const yytname[] ={  "$", "error", "$undefined.", "T_INTV", "T_ADDRV", "T_STRV", "T_EXCV",   "T_FLOATV", "T_MAIN", "T_EXIT", "T_PUSH", "T_POP", "T_POPI", "T_PULL",   "T_EQ", "T_EQI", "T_PAJ", "T_TPAJ", "T_BEZ", "T_BNE", "T_STORE", "T_JI",   "T_NEQ", "T_NEQI", "T_ADD", "T_ADDI", "T_SUB", "T_SUBI", "T_MULT",   "T_MULTI", "T_DIV", "T_DIVI", "T_MOD", "T_MODI", "T_NEG", "T_NOT",   "T_LNOT", "T_AND", "T_ANDI", "T_OR", "T_ORI", "T_LSHL", "T_LSHLI",   "T_RSHL", "T_RSHLI", "T_RSHA", "T_RSHAI", "T_SNET", "T_SNETI",   "T_BCAST", "T_BCASTI", "T_ISX", "T_GETRB", "T_GETSRC", "T_GETDST",   "T_GETSPT", "T_HERE", "T_ISHERE", "T_ROUTE", "T_RTDEV", "T_SEND",   "T_HOP", "T_FORW", "T_FORWTO", "T_DEMUX", "T_DEMUXI", "T_PRINT",   "T_GETLD", "T_SETXH", "T_RAISEX", "T_PLUS", "T_MINUS", "T_LABEL",   "T_LABELV", "T_PC", "T_MKTUP", "T_LEN", "T_NTH", "T_ISTUP", "T_LPAREN",   "T_RPAREN", "T_COMMA", "T_SVCV", "T_CALLS", "T_GT", "T_GEQ", "T_LT",   "T_LEQ", "T_GTI", "T_GEQI", "T_LTI", "T_LEQI", "T_DATA", "T_DFORW",   "T_DFORWTO", "T_DSEND", "T_STACKEMPTY", "T_STACKCOUNT", "T_PULLSTACK",   "instrs", "instr", "op0", "opint", "opaddr", "opstr", "op1", "value",   "value_list", "int_expr", 0};#endif/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */static const short yyr1[] ={       0,    99,    99,   100,   100,   100,   100,   100,   100,   100,     100,   101,   101,   101,   101,   101,   101,   101,   101,   101,     101,   101,   101,   101,   101,   101,   101,   101,   101,   101,     101,   101,   101,   101,   101,   101,   101,   101,   101,   101,     101,   101,   101,   101,   101,   101,   101,   101,   101,   101,     101,   101,   101,   101,   101,   101,   101,   101,   101,   101,     102,   102,   102,   102,   102,   102,   102,   102,   102,   102,     102,   102,   102,   102,   102,   102,   103,   103,   103,   104,     104,   105,   105,   105,   105,   105,   105,   105,   105,   105,     105,   105,   106,   106,   106,   106,   106,   106,   107,   107,     108,   108,   108,   108,   108};/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */static const short yyr2[] ={       0,     2,     0,     1,     2,     2,     2,     2,     1,     1,       2,     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,     3,     3,     1,       3,     3,     1,     1,     1};/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE   doesn't specify something else to do.  Zero means the default is an   error. */static const short yydefact[] ={       2,     8,    11,    81,    12,    66,    60,    13,    82,    62,      63,    64,    65,    61,    73,    14,    83,    15,    84,    16,      85,    17,    86,    18,    87,    19,    67,    20,    21,    22,      23,    68,    24,    69,    25,    70,    26,    71,    27,    72,      48,    78,    49,    76,    28,    29,    30,    31,    32,    36,      37,    38,    39,    40,    41,    42,    43,    44,    77,    45,      33,    34,    35,     9,    74,    46,    75,    47,    79,    80,      50,    51,    52,    53,    88,    89,    90,    91,     0,    55,      56,    54,    57,    58,    59,     2,     3,     0,     0,     0,       0,   103,    93,    95,    96,    94,   104,   102,     0,    10,      92,     1,     4,     5,     6,     7,    99,     0,     0,     0,       0,    97,   100,   101,    98,     0,     0,     0};static const short yydefgoto[] ={     101,    85,    86,    87,    88,    89,    90,   106,   107,   100};static const short yypact[] ={      -8,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,  -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    88,-32768,  -32768,-32768,-32768,-32768,-32768,    -8,-32768,    59,    67,    58,      88,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    88,-32768,      -5,-32768,    -5,-32768,-32768,-32768,    -9,    -7,    59,    59,      88,-32768,-32768,-32768,-32768,    98,    99,-32768};static const short yypgoto[] ={     100,-32768,-32768,-32768,-32768,-32768,-32768,    19,    -6,     9};#define	YYLAST		167static const short yytable[] ={       1,     2,     3,     4,     5,     6,     7,     8,     9,    10,      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,      41,    42,    43,    44,    45,    46,    47,    48,    49,    50,      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,      61,    62,    91,   104,    63,   108,   109,    64,    65,    66,      67,   103,   110,   111,    68,    69,    70,    71,    72,    73,      74,    75,    76,    77,    78,    79,    80,    81,    82,    83,      84,    91,    92,    93,    94,    95,   102,    99,   116,   117,     115,     0,     0,     0,   114,     0,     0,     0,     0,   105,       0,     0,     0,     0,     0,     0,     0,   112,   113,     0,       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,       0,     0,    96,    97,     0,     0,     0,     0,     0,     0,       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,       0,    96,    97,     0,     0,     0,     0,    98};static const short yycheck[] ={       8,     9,    10,    11,    12,    13,    14,    15,    16,    17,      18,    19,    20,    21,    22,    23,    24,    25,    26,    27,      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,      38,    39,    40,    41,    42,    43,    44,    45,    46,    47,      48,    49,    50,    51,    52,    53,    54,    55,    56,    57,      58,    59,    60,    61,    62,    63,    64,    65,    66,    67,      68,    69,     3,     5,    72,    70,    71,    75,    76,    77,      78,     4,    81,    80,    82,    83,    84,    85,    86,    87,      88,    89,    90,    91,    92,    93,    94,    95,    96,    97,      98,     3,     4,     5,     6,     7,    87,    78,     0,     0,       0,    -1,    -1,    -1,   110,    -1,    -1,    -1,    -1,    90,      -1,    -1,    -1,    -1,    -1,    -1,    -1,   108,   109,    -1,      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,      -1,    -1,    73,    74,    -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,    73,    74,    -1,    -1,    -1,    -1,    79};/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */#line 3 "/usr/share/bison/bison.simple"/* Skeleton output parser for bison,   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 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.  *//* All symbols defined below should begin with yy or YY, to avoid   infringing on user name space.  This should be done even for local   variables, as they might otherwise be expanded by user macros.   There are some unavoidable exceptions within include files to   define necessary library symbols; they are noted "INFRINGES ON   USER NAME SPACE" below.  */#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)/* The parser invokes alloca or malloc; define the necessary symbols.  */# if YYSTACK_USE_ALLOCA#  define YYSTACK_ALLOC alloca# else#  ifndef YYSTACK_USE_ALLOCA#   if defined (alloca) || defined (_ALLOCA_H)#    define YYSTACK_ALLOC alloca#   else#    ifdef __GNUC__#     define YYSTACK_ALLOC __builtin_alloca#    endif#   endif#  endif# endif# ifdef YYSTACK_ALLOC   /* Pacify GCC's `empty if-body' warning. */#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)# else#  if defined (__STDC__) || defined (__cplusplus)#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */#   define YYSIZE_T size_t#  endif#  define YYSTACK_ALLOC malloc#  define YYSTACK_FREE free# endif#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */#if (! defined (yyoverflow) \     && (! defined (__cplusplus) \	 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))/* A type that is properly aligned for any stack member.  */union yyalloc{  short yyss;  YYSTYPE yyvs;# if YYLSP_NEEDED  YYLTYPE yyls;# endif};/* The size of the maximum gap between one aligned stack and the next.  */# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)/* The size of an array large to enough to hold all stacks, each with   N elements.  */# if YYLSP_NEEDED#  define YYSTACK_BYTES(N) \     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))	\      + 2 * YYSTACK_GAP_MAX)# else#  define YYSTACK_BYTES(N) \     ((N) * (sizeof (short) + sizeof (YYSTYPE))				\      + YYSTACK_GAP_MAX)# endif/* Copy COUNT objects from FROM to TO.  The source and destination do   not overlap.  */# ifndef YYCOPY#  if 1 < __GNUC__#   define YYCOPY(To, From, Count) \      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))#  else#   define YYCOPY(To, From, Count)		\      do					\	{					\	  register YYSIZE_T yyi;		\	  for (yyi = 0; yyi < (Count); yyi++)	\	    (To)[yyi] = (From)[yyi];		\

⌨️ 快捷键说明

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