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

📄 soapcpp2.y

📁 linux下开发的soap协议。建议大家学习学习!
💻 Y
📖 第 1 页 / 共 3 页
字号:
			  $$.sto = Snone;			  sp->node = $$;	/* set global `tmp1' for inheritance */			}	| store spec	{ $$.typ = $2.typ;			  $$.sto = $1 | $2.sto;			  sp->node = $$;	/* set global `tmp1' for inheritance */			  if ($1 & Sextern)			    transient--;			}	| type spec	{ if ($1->type == Tint)				switch ($2.typ->type)				{ case Tchar:	$$.typ = $2.typ; break;				  case Tshort:	$$.typ = $2.typ; break;				  case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = $2.typ; break;				  case Tllong:	$$.typ = $2.typ; break;				  default:	semwarn("illegal use of `signed'");						$$.typ = $2.typ;				}			  else if ($1->type == Tuint)				switch ($2.typ->type)				{ case Tchar:	$$.typ = mkuchar(); break;				  case Tshort:	$$.typ = mkushort(); break;				  case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = mkulong(); break;				  case Tllong:	$$.typ = mkullong(); break;				  default:	semwarn("illegal use of `unsigned'");						$$.typ = $2.typ;				}			  else if ($1->type == Tlong)				switch ($2.typ->type)				{ case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = mkllong(); break;				  case Tuint:	$$.typ = mkulong(); break;				  case Tulong:	$$.typ = mkullong(); break;				  default:	semwarn("illegal use of `long'");						$$.typ = $2.typ;				}			  else if ($1->type == Tulong)				switch ($2.typ->type)				{ case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = mkullong(); break;				  case Tuint:	$$.typ = $1; break;				  case Tulong:	$$.typ = mkullong(); break;				  default:	semwarn("illegal use of `long'");						$$.typ = $2.typ;				}			  else				$$.typ = $1;			  $$.sto = $2.sto;			  sp->node = $$;	/* set global `tmp1' for inheritance */			}	;tspec	: store		{ $$.typ = mkint();			  $$.sto = $1;			  sp->node = $$;	/* set global `tmp1' for inheritance */			  if ($1 & Sextern)			    transient--;			}	| type		{ $$.typ = $1;			  $$.sto = Snone;			  sp->node = $$;	/* set global `tmp1' for inheritance */			}	| store tspec	{ $$.typ = $2.typ;			  $$.sto = $1 | $2.sto;			  sp->node = $$;	/* set global `tmp1' for inheritance */			  if ($1 & Sextern)			    transient--;			}	| type tspec	{ if ($1->type == Tint)				switch ($2.typ->type)				{ case Tchar:	$$.typ = $2.typ; break;				  case Tshort:	$$.typ = $2.typ; break;				  case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = $2.typ; break;				  case Tllong:	$$.typ = $2.typ; break;				  default:	semwarn("illegal use of `signed'");						$$.typ = $2.typ;				}			  else if ($1->type == Tuint)				switch ($2.typ->type)				{ case Tchar:	$$.typ = mkuchar(); break;				  case Tshort:	$$.typ = mkushort(); break;				  case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = mkulong(); break;				  case Tllong:	$$.typ = mkullong(); break;				  default:	semwarn("illegal use of `unsigned'");						$$.typ = $2.typ;				}			  else if ($1->type == Tlong)				switch ($2.typ->type)				{ case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = mkllong(); break;				  case Tuint:	$$.typ = mkulong(); break;				  case Tulong:	$$.typ = mkullong(); break;				  default:	semwarn("illegal use of `long'");						$$.typ = $2.typ;				}			  else if ($1->type == Tulong)				switch ($2.typ->type)				{ case Tint:	$$.typ = $1; break;				  case Tlong:	$$.typ = mkullong(); break;				  case Tuint:	$$.typ = $1; break;				  case Tulong:	$$.typ = mkullong(); break;				  default:	semwarn("illegal use of `long'");						$$.typ = $2.typ;				}			  else				$$.typ = $1;			  $$.sto = $2.sto;			  sp->node = $$;	/* set global `tmp1' for inheritance */			}	;type	: VOID		{ $$ = mkvoid(); }	| BOOL		{ $$ = mkbool(); }	| CHAR		{ $$ = mkchar(); }	| WCHAR		{ $$ = mkwchart(); }	| SHORT		{ $$ = mkshort(); }	| INT		{ $$ = mkint(); }	| LONG		{ $$ = mklong(); }	| LLONG		{ $$ = mkllong(); }	| ULLONG	{ $$ = mkullong(); }	| SIZE		{ $$ = mkuint(); }	| FLOAT		{ $$ = mkfloat(); }	| DOUBLE	{ $$ = mkdouble(); }	| SIGNED	{ $$ = mkint(); }	| UNSIGNED	{ $$ = mkuint(); }	| TIME		{ $$ = mktimet(); }	| CLASS '{' s2 decls '}'			{ sym = gensym("Struct");			  sprintf(errbuf, "Nameless class will be named %s", sym->name);			  semwarn(errbuf);			  if ((p = entry(classtable, sym)) != (Entry*) 0)			  {	if ((Table*) p->info.typ->ref != (Table*) 0)				{	sprintf(errbuf, "struct/class `%s' already defined", sym->name);					semerror(errbuf);				}			  }			  else			  {	p = enter(classtable, sym);				p->info.typ = mkclass((Table*)0, 0);			  }			  sym->token = TYPE;			  sp->table->sym = sym;			  p->info.typ->ref = sp->table;			  p->info.typ->width = sp->offset;			  p->info.typ->id = sym;			  $$ = p->info.typ;			  exitscope();			}	| class '{' s2 decls '}'			{ sp->table->sym = $1->sym;			  $1->info.typ->ref = sp->table;			  $1->info.typ->width = sp->offset;			  $1->info.typ->id = $1->sym;			  $$ = $1->info.typ;			  exitscope();			}	| class ':' super '{' s2 decls '}'			{ sp->table->sym = $1->sym;			  sp->table->prev = (Table*)$3->info.typ->ref;			  $1->info.typ->ref = sp->table;			  $1->info.typ->width = sp->offset;			  $1->info.typ->id = $1->sym;			  $$ = $1->info.typ;			  exitscope();			}	| class		{ $1->info.typ->id = $1->sym;			  $$ = $1->info.typ;			}	| STRUCT '{' s2 decls '}'			{ sym = gensym("Struct");			  sprintf(errbuf, "Nameless struct will be named %s", sym->name);			  semwarn(errbuf);			  if ((p = entry(classtable, sym)) != (Entry*) 0)				if ((Table*) p->info.typ->ref != (Table*) 0) {					sprintf(errbuf, "struct/class `%s' already defined", sym->name);					semerror(errbuf);				} else {					p->info.typ->ref = sp->table;					p->info.typ->width = sp->offset;				}			  else {			  	p = enter(classtable, sym);				p->info.typ = mkstruct(sp->table, sp->offset);			  }			  p->info.typ->id = sym;			  $$ = p->info.typ;			  exitscope();			}	| STRUCT ID '{' s2 decls '}'			{ if ((p = entry(classtable, $2)) != (Entry*)0)				if ((Table*)p->info.typ->ref != (Table*)0) {					sprintf(errbuf, "struct/class `%s' already defined (referenced from line %d)", $2->name, p->lineno);					semerror(errbuf);				} else {					p->info.typ->ref = sp->table;					p->info.typ->width = sp->offset;				}			  else {			  	p = enter(classtable, $2);				p->info.typ = mkstruct(sp->table, sp->offset);			  	p->info.typ->id = $2;			  }			  $$ = p->info.typ;			  exitscope();			}	| STRUCT ID	{ if ((p = entry(classtable, $2)) != (Entry*)0) {			  	$$ = p->info.typ;			  } else {			  	p = enter(classtable, $2);			  	$$ = p->info.typ = mkstruct((Table*)0, 0);				p->info.typ->id = $2;			  }			}	| UNION '{' s3 decls '}'			{ $$ = mkunion(sp->table, sp->offset);			  semwarn("Unions cannot be (de)serialized");			  exitscope();			}	| UNION ID '{' s3 decls '}'			{ semwarn("Unions cannot be (de)serialized");			  if ((p = entry(uniontable, $2)) != (Entry*) 0)				if ((Table*) p->info.typ->ref != (Table*) 0) {					sprintf(errbuf, "union `%s' already defined", $2->name);					semerror(errbuf);				} else {					p->info.typ->ref = sp->table;					p->info.typ->width = sp->offset;				}			  else {			  	p = enter(uniontable, $2);				p->info.typ = mkunion(sp->table, sp->offset);			  }			  p->info.typ->id = $2;			  $$ = p->info.typ;			  exitscope();			}	| UNION ID	{ semwarn("Unions cannot be (de)serialized");			  if ((p = entry(uniontable, $2)) != (Entry*) 0)			  	$$ = p->info.typ;			  else {			  	p = enter(uniontable, $2);			  	$$ = p->info.typ = mkunion((Table*) 0, 0);				p->info.typ->id = $2;			  }			}	| ENUM '{' s2 dclrs '}'			{ sym = gensym("Enum");			  sprintf(errbuf, "Nameless enum will be named %s", sym->name);			  semwarn(errbuf);			  if ((p = entry(enumtable, sym)) != (Entry*) 0)				if ((Table*) p->info.typ->ref != (Table*) 0) {					sprintf(errbuf, "enum `%s' already defined", sym->name);					semerror(errbuf);				} else {					p->info.typ->ref = sp->table;					p->info.typ->width = sp->offset;				}			  else {			  	p = enter(enumtable, sym);				p->info.typ = mkenum(sp->table);			  }			  p->info.typ->id = sym;			  $$ = p->info.typ;			  exitscope();			}	| ENUM ID '{' s2 dclrs '}'			{ if ((p = entry(enumtable, $2)) != (Entry*) 0)				if ((Table*) p->info.typ->ref != (Table*) 0) {					sprintf(errbuf, "enum `%s' already defined (referenced from line %d)", $2->name, p->lineno);					semerror(errbuf);				} else {					p->info.typ->ref = sp->table;					p->info.typ->width = sp->offset;				}			  else {			  	p = enter(enumtable, $2);				p->info.typ = mkenum(sp->table);			  }			  p->info.typ->id = $2;			  $$ = p->info.typ;			  exitscope();			}	| ENUM '*' ID '{' s4 dclrs '}'			{ if ((p = entry(enumtable, $3)) != (Entry*) 0)				if ((Table*) p->info.typ->ref != (Table*) 0) {					sprintf(errbuf, "enum `%s' already defined (referenced from line %d)", $3->name, p->lineno);					semerror(errbuf);				} else {					p->info.typ->ref = sp->table;					p->info.typ->width = sp->offset;				}			  else {			  	p = enter(enumtable, $3);				p->info.typ = mkmask(sp->table);			  }			  p->info.typ->id = $3;			  $$ = p->info.typ;			  exitscope();			}	| ENUM ID	{ if ((p = entry(enumtable, $2)) != (Entry*) 0)			  	$$ = p->info.typ;			  else {			  	p = enter(enumtable, $2);			  	$$ = p->info.typ = mkenum((Table*)0);				p->info.typ->id = $2;			  }			}	| TYPE		{ if ((p = entry(typetable, $1)) != (Entry*) 0)				$$ = p->info.typ;			  else if ((p = entry(classtable, $1)) != (Entry*) 0)			  	$$ = p->info.typ;			  else {			  	sprintf(errbuf, "unknown type `%s'", $1->name);				semerror(errbuf);				$$ = mkint();			  }			}	;class	: CLASS ID	{ if ((p = entry(classtable, $2)) != (Entry*) 0)			  {	if ((Table*) p->info.typ->ref != (Table*) 0)				{	sprintf(errbuf, "struct/class `%s' already defined", $2->name);					semerror(errbuf);				}			  }			  else			  {	p = enter(classtable, $2);				p->info.typ = mkclass((Table*)0, 0);			  }			  $2->token = TYPE;			  $$ = p;			}	| CLASS TYPE	{ if ((p = entry(classtable, $2)) != (Entry*) 0)			  {	if ((Table*) p->info.typ->ref != (Table*) 0)				{	sprintf(errbuf, "struct/class `%s' already defined", $2->name);					semerror(errbuf);				}			  }			  else			  {	sprintf(errbuf, "illegal class name `%s'", $2->name);				semerror(errbuf);			  }			  $$ = p;			}	;super	: PROTECTED TYPE{ $$ = entry(classtable, $2); }	| PRIVATE TYPE	{ $$ = entry(classtable, $2); }	| PUBLIC TYPE	{ $$ = entry(classtable, $2); }	| TYPE		{ $$ = entry(classtable, $1); }	;s2	: /* empty */	{ enterscope(mktable((Table*) 0), 0);			  sp->entry = (Entry*)0;			}	;s3	: /* empty */	{ enterscope(mktable((Table*) 0), 0);			  sp->entry = (Entry*)0;			  sp->grow = False;			}	;s4	: /* empty */	{ enterscope(mktable((Table*) 0), 0);			  sp->entry = (Entry*)0;			  sp->mask = True;			  sp->val = 1;			}	;store	: AUTO		{ $$ = Sauto; }	| REGISTER	{ $$ = Sregister; }	| STATIC	{ $$ = Sstatic; }	| EXTERN	{ $$ = Sextern; transient++; }	| TYPEDEF	{ $$ = Stypedef; }	| VIRTUAL	{ $$ = Svirtual; }	| CONST		{ $$ = Sconst; }	| INLINE	{ $$ = Sinline; }	| MUSTUNDERSTAND{ $$ = SmustUnderstand; }	;constobj: /* empty */	{ $$ = Snone; }	| CONST		{ $$ = Sconstobj; }	;abstract: /* empty */	{ $$ = Snone; }	| '=' LNG	{ $$ = Sabstract; }	;virtual : /* empty */	{ $$ = Snone; }	| VIRTUAL	{ $$ = Svirtual; }	;ptrs	: /* empty */	{ $$ = tmp = sp->node; }	| ptrs '*'	{ tmp.typ = mkpointer(tmp.typ); $$ = tmp; }	| ptrs '&'	{ tmp.typ = mkreference(tmp.typ); $$ = tmp; }	;array	: /* empty */ 	{ $$ = tmp; }	/* tmp2 is inherited */	| '[' cexp ']' array			{ if ($4.typ->type == Tchar)			  {	sprintf(errbuf, "char [%d] will be (de)marshalled as an array of %d bytes: use char* for strings", $2.val.i, $2.val.i);			  	semwarn(errbuf);			  }			  if ($2.hasval && $2.typ->type == Tint && $2.val.i > 0 && $4.typ->width > 0)				$$.typ = mkarray($4.typ, (int) $2.val.i * $4.typ->width);			  else			  	semerror("illegal array size");			  $$.sto = $4.sto;			}	| '[' ']' array	{ $$.typ = mkpointer($3.typ); /* zero size array = pointer */			  $$.sto = $3.sto;			}	;init	: /* empty */   { $$.hasval = False; }	| '=' cexp      { if ($2.hasval)			  {	$$.typ = $2.typ;				$$.hasval = True;				$$.val = $2.val;			  }			  else			  {	$$.hasval = False;				semerror("initialization expression not constant");			  }			}        ;occurs	: /* empty */	{ $$.minOccurs = 1;			  $$.maxOccurs = 1;			}	| LNG		{ $$.minOccurs = $1;			  $$.maxOccurs = 1;			}	| LNG ':' LNG	{ $$.minOccurs = $1;			  $$.maxOccurs = $3;			}	;/******************************************************************************\	Expressions\******************************************************************************/expr	: expr ',' expr	{ $$ = $3; }	| cexp	;/* cexp : conditional expression */cexp	: obex '?' qexp ':' cexp			{ $$.typ = $3.typ;			  $$.sto = Snone;			  $$.hasval = False;			}	| oexp	;/* qexp : true-branch of ? : conditional expression */qexp	: expr		{ $$ = $1; }	;/* oexp : or-expression */oexp	: obex OR aexp			{ $$.hasval = False;			  $$.typ = mkint();

⌨️ 快捷键说明

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