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

📄 asn1p_y.c

📁 ASN.1解析解码工具,可以解析各种ASN.1格式的文件,并对相应的BER文件解码
💻 C
📖 第 1 页 / 共 5 页
字号:
/* A Bison parser, made from e:\wangbin\study\mytest\test01\asn1parser\src\asn1p_y.y
   by GNU bison 1.35.  */

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

# define	TOK_PPEQ	257
# define	TOK_whitespace	258
# define	TOK_opaque	259
# define	TOK_bstring	260
# define	TOK_cstring	261
# define	TOK_hstring	262
# define	TOK_identifier	263
# define	TOK_number	264
# define	TOK_number_negative	265
# define	TOK_realnumber	266
# define	TOK_tuple	267
# define	TOK_quadruple	268
# define	TOK_typereference	269
# define	TOK_capitalreference	270
# define	TOK_typefieldreference	271
# define	TOK_valuefieldreference	272
# define	TOK_Literal	273
# define	TOK_ABSENT	274
# define	TOK_ABSTRACT_SYNTAX	275
# define	TOK_ALL	276
# define	TOK_ANY	277
# define	TOK_APPLICATION	278
# define	TOK_AUTOMATIC	279
# define	TOK_BEGIN	280
# define	TOK_BIT	281
# define	TOK_BMPString	282
# define	TOK_BOOLEAN	283
# define	TOK_BY	284
# define	TOK_CHARACTER	285
# define	TOK_CHOICE	286
# define	TOK_CLASS	287
# define	TOK_COMPONENT	288
# define	TOK_COMPONENTS	289
# define	TOK_CONSTRAINED	290
# define	TOK_CONTAINING	291
# define	TOK_DEFAULT	292
# define	TOK_DEFINITIONS	293
# define	TOK_DEFINED	294
# define	TOK_EMBEDDED	295
# define	TOK_ENCODED	296
# define	TOK_ENCODING_CONTROL	297
# define	TOK_END	298
# define	TOK_ENUMERATED	299
# define	TOK_EXPLICIT	300
# define	TOK_EXPORTS	301
# define	TOK_EXTENSIBILITY	302
# define	TOK_EXTERNAL	303
# define	TOK_FALSE	304
# define	TOK_FROM	305
# define	TOK_GeneralizedTime	306
# define	TOK_GeneralString	307
# define	TOK_GraphicString	308
# define	TOK_IA5String	309
# define	TOK_IDENTIFIER	310
# define	TOK_IMPLICIT	311
# define	TOK_IMPLIED	312
# define	TOK_IMPORTS	313
# define	TOK_INCLUDES	314
# define	TOK_INSTANCE	315
# define	TOK_INSTRUCTIONS	316
# define	TOK_INTEGER	317
# define	TOK_ISO646String	318
# define	TOK_MAX	319
# define	TOK_MIN	320
# define	TOK_MINUS_INFINITY	321
# define	TOK_NULL	322
# define	TOK_NumericString	323
# define	TOK_OBJECT	324
# define	TOK_ObjectDescriptor	325
# define	TOK_OCTET	326
# define	TOK_OF	327
# define	TOK_OPTIONAL	328
# define	TOK_PATTERN	329
# define	TOK_PDV	330
# define	TOK_PLUS_INFINITY	331
# define	TOK_PRESENT	332
# define	TOK_PrintableString	333
# define	TOK_PRIVATE	334
# define	TOK_REAL	335
# define	TOK_RELATIVE_OID	336
# define	TOK_SEQUENCE	337
# define	TOK_SET	338
# define	TOK_SIZE	339
# define	TOK_STRING	340
# define	TOK_SYNTAX	341
# define	TOK_T61String	342
# define	TOK_TAGS	343
# define	TOK_TeletexString	344
# define	TOK_TRUE	345
# define	TOK_TYPE_IDENTIFIER	346
# define	TOK_UNIQUE	347
# define	TOK_UNIVERSAL	348
# define	TOK_UniversalString	349
# define	TOK_UTCTime	350
# define	TOK_UTF8String	351
# define	TOK_VideotexString	352
# define	TOK_VisibleString	353
# define	TOK_WITH	354
# define	TOK_EXCEPT	355
# define	TOK_INTERSECTION	356
# define	TOK_UNION	357
# define	TOK_TwoDots	358
# define	TOK_ThreeDots	359

#line 1 "e:\\wangbin\\study\\mytest\\test01\\asn1parser\\src\\asn1p_y.y"


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h>

#include "asn1parser/asn1parser.h"

#define yyparse asn1p_parse
#define yylex   asn1p_lex
#define yyerror asn1p_error
#define yylval  asn1p_lval
#define yychar  asn1p_char
#define yydebug asn1p_debug
#define yynerrs asn1p_nerrs

int asn1p_debug;

#define YYPARSE_PARAM	param
#define YYPARSE_PARAM_TYPE	void **
#define YYERROR_VERBOSE

int yylex(void);
int yyerror(const char *msg);
#ifdef	YYBYACC
int yyparse(void **param);	/* byacc does not produce a prototype */
#endif
void asn1p_lexer_hack_push_opaque_state(void);
void asn1p_lexer_hack_enable_with_syntax(void);
void asn1p_lexer_hack_push_encoding_control(void);
#define	yylineno	asn1p_lineno
extern int asn1p_lineno;

/*
 * Process directives as <ASN1C:RepresentAsPointer>
 */
extern int asn1p_as_pointer;

/*
 * This temporary variable is used to solve the shortcomings of 1-lookahead
 * parser.
 */
static struct AssignedIdentifier *saved_aid;

static asn1p_value_t *_convert_bitstring2binary(char *str, int base);
static void _fixup_anonymous_identifier(asn1p_expr_t *expr);

static asn1p_module_t *currentModule;
#define	NEW_EXPR()	(asn1p_expr_new(yylineno, currentModule))

#define	checkmem(ptr)	do {						\
		if(!(ptr))						\
		return yyerror("Memory failure");			\
	} while(0)

#define	CONSTRAINT_INSERT(root, constr_type, arg1, arg2) do {		\
		if(arg1->type != constr_type) {				\
			int __ret;					\
			root = asn1p_constraint_new(yylineno);		\
			checkmem(root);					\
			root->type = constr_type;			\
			__ret = asn1p_constraint_insert(root,		\
				arg1);					\
			checkmem(__ret == 0);				\
		} else {						\
			root = arg1;					\
		}							\
		if(arg2) {						\
			int __ret					\
			= asn1p_constraint_insert(root, arg2);		\
			checkmem(__ret == 0);				\
		}							\
	} while(0)

#ifdef	AL_IMPORT
#error	AL_IMPORT DEFINED ELSEWHERE!
#endif
#define	AL_IMPORT(to,where,from,field,_type)	do {				\
		if(!(from)) break;					\
		while(TQ_FIRST(&((from)->where))) {			\
			TQ_ADD_TYPE(_type,&((to)->where),				\
				TQ_REMOVE_TYPE(_type,&((from)->where), field),	\
				field);					\
		}							\
		assert(TQ_FIRST(&((from)->where)) == 0);		\
	} while(0)


#line 98 "e:\\wangbin\\study\\mytest\\test01\\asn1parser\\src\\asn1p_y.y"
#ifndef YYSTYPE
typedef union {
	asn1p_t			*a_grammar;
	asn1p_module_flags_e	 a_module_flags;
	asn1p_module_t		*a_module;
	asn1p_expr_type_e	 a_type;	/* ASN.1 Type */
	asn1p_expr_t		*a_expr;	/* Constructed collection */
	asn1p_constraint_t	*a_constr;	/* Constraint */
	enum asn1p_constraint_type_e	a_ctype;/* Constraint type */
	asn1p_xports_t		*a_xports;	/* IMports/EXports */
	struct AssignedIdentifier a_aid;	/* Assigned Identifier */
	asn1p_oid_t		*a_oid;		/* Object Identifier */
	asn1p_oid_arc_t		 a_oid_arc;	/* Single OID's arc */
	struct asn1p_type_tag_s	 a_tag;		/* A tag */
	asn1p_ref_t		*a_ref;		/* Reference to custom type */
	asn1p_wsyntx_t		*a_wsynt;	/* WITH SYNTAX contents */
	asn1p_wsyntx_chunk_t	*a_wchunk;	/* WITH SYNTAX chunk */
	struct asn1p_ref_component_s a_refcomp;	/* Component of a reference */
	asn1p_value_t		*a_value;	/* Number, DefinedValue, etc */
	struct asn1p_param_s	 a_parg;	/* A parameter argument */
	asn1p_paramlist_t	*a_plist;	/* A pargs list */
	struct asn1p_expr_marker_s a_marker;	/* OPTIONAL/DEFAULT */
	enum asn1p_constr_pres_e a_pres;	/* PRESENT/ABSENT/OPTIONAL */
	asn1c_integer_t		 a_int;
	double			 a_dbl;
	char	*tv_str;
	struct {
		char *buf;
		int len;
	}	tv_opaque;
	struct {
		char *name;
		struct asn1p_type_tag_s tag;
	} tv_nametag;
} yystype;
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifndef YYDEBUG
# define YYDEBUG 0
#endif



#define	YYFINAL		462
#define	YYFLAG		-32768
#define	YYNTBASE	121

/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
#define YYTRANSLATE(x) ((unsigned)(x) <= 359 ? yytranslate[x] : 237)

/* 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,   117,     2,     2,     2,     2,     2,     2,
     110,   111,     2,     2,   113,     2,   118,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,   114,   112,
     119,     2,     2,     2,   120,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,   115,     2,   116,   102,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,   108,   104,   109,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     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,

⌨️ 快捷键说明

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