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

📄 existing.at

📁 GNU的词法/语法分析器bison源码
💻 AT
📖 第 1 页 / 共 5 页
字号:
	  DELIMITED		{ delim_flag = 0; }	  until		{		  if (yychar < 0)		    do_lookahead();		  copy_rest_thru($4, $6);		  a_delete $4;		  a_delete $6;		}	| FOR VARIABLE '=' expr TO expr optional_by DO		{ delim_flag = 1; }	  DELIMITED		{		  delim_flag = 0;		  if (yychar < 0)		    do_lookahead();		  do_for($2, $4, $6, $7.is_multiplicative, $7.val, $10);		}	| simple_if		{		  if (yychar < 0)		    do_lookahead();		  if ($1.x != 0.0)		    push_body($1.body);		  a_delete $1.body;		}	| simple_if ELSE		{ delim_flag = 1; }	  DELIMITED		{		  delim_flag = 0;		  if (yychar < 0)		    do_lookahead();		  if ($1.x != 0.0)		    push_body($1.body);		  else		    push_body($4);		  a_delete $1.body;		  a_delete $4;		}	| reset_variables	| RESET		{ define_variable("scale", 1.0); }	;reset_variables:	RESET VARIABLE		{		  reset($2);		  a_delete $2;		}	| reset_variables VARIABLE		{		  reset($2);		  a_delete $2;		}	| reset_variables ',' VARIABLE		{		  reset($3);		  a_delete $3;		}	;print_args:	print_arg		{ $$ = $1; }	| print_args print_arg		{		  $$.str = new char[strlen($1.str) + strlen($2.str) + 1];		  strcpy($$.str, $1.str);		  strcat($$.str, $2.str);		  a_delete $1.str;		  a_delete $2.str;		  if ($1.filename) {		    $$.filename = $1.filename;		    $$.lineno = $1.lineno;		  }		  else if ($2.filename) {		    $$.filename = $2.filename;		    $$.lineno = $2.lineno;		  }		}	;print_arg:	expr							%prec ','		{		  $$.str = new char[GDIGITS + 1];		  sprintf($$.str, "%g", $1);		  $$.filename = 0;		  $$.lineno = 0;		}	| text		{ $$ = $1; }	| position						%prec ','		{		  $$.str = new char[GDIGITS + 2 + GDIGITS + 1];		  sprintf($$.str, "%g, %g", $1.x, $1.y);		  $$.filename = 0;		  $$.lineno = 0;		}	;simple_if:	IF any_expr THEN		{ delim_flag = 1; }	DELIMITED		{		  delim_flag = 0;		  $$.x = $2;		  $$.body = $5;		}	;until:	/* empty */		{ $$ = 0; }	| UNTIL TEXT		{ $$ = $2.str; }	;any_expr:	expr		{ $$ = $1; }	| text_expr		{ $$ = $1; }	;text_expr:	text EQUALEQUAL text		{		  $$ = strcmp($1.str, $3.str) == 0;		  a_delete $1.str;		  a_delete $3.str;		}	| text NOTEQUAL text		{		  $$ = strcmp($1.str, $3.str) != 0;		  a_delete $1.str;		  a_delete $3.str;		}	| text_expr ANDAND text_expr		{ $$ = ($1 != 0.0 && $3 != 0.0); }	| text_expr ANDAND expr		{ $$ = ($1 != 0.0 && $3 != 0.0); }	| expr ANDAND text_expr		{ $$ = ($1 != 0.0 && $3 != 0.0); }	| text_expr OROR text_expr		{ $$ = ($1 != 0.0 || $3 != 0.0); }	| text_expr OROR expr		{ $$ = ($1 != 0.0 || $3 != 0.0); }	| expr OROR text_expr		{ $$ = ($1 != 0.0 || $3 != 0.0); }	| '!' text_expr		{ $$ = ($2 == 0.0); }	;optional_by:	/* empty */		{		  $$.val = 1.0;		  $$.is_multiplicative = 0;		}	| BY expr		{		  $$.val = $2;		  $$.is_multiplicative = 0;		}	| BY '*' expr		{		  $$.val = $3;		  $$.is_multiplicative = 1;		}	;element:	object_spec		{		  $$.obj = $1->make_object(&current_position,					   &current_direction);		  if ($$.obj == 0)		    YYABORT;		  delete $1;		  if ($$.obj)		    olist.append($$.obj);		  else {		    $$.x = current_position.x;		    $$.y = current_position.y;		  }		}	| LABEL ':' optional_separator element		{		  $$ = $4;		  define_label($1, & $$);		  a_delete $1;		}	| LABEL ':' optional_separator position_not_place		{		  $$.obj = 0;		  $$.x = $4.x;		  $$.y = $4.y;		  define_label($1, & $$);		  a_delete $1;		}	| LABEL ':' optional_separator place		{		  $$ = $4;		  define_label($1, & $$);		  a_delete $1;		}	| '{'		{		  $<state>$.x = current_position.x;		  $<state>$.y = current_position.y;		  $<state>$.dir = current_direction;		}	  element_list '}'		{		  current_position.x = $<state>2.x;		  current_position.y = $<state>2.y;		  current_direction = $<state>2.dir;		}	  optional_element		{		  $$ = $3;		}	| placeless_element		{		  $$.obj = 0;		  $$.x = current_position.x;		  $$.y = current_position.y;		}	;optional_element:	/* empty */		{}	| element		{}	;object_spec:	BOX		{ $$ = new object_spec(BOX_OBJECT); }	| CIRCLE		{ $$ = new object_spec(CIRCLE_OBJECT); }	| ELLIPSE		{ $$ = new object_spec(ELLIPSE_OBJECT); }	| ARC		{		  $$ = new object_spec(ARC_OBJECT);		  $$->dir = current_direction;		}	| LINE		{		  $$ = new object_spec(LINE_OBJECT);		  lookup_variable("lineht", & $$->segment_height);		  lookup_variable("linewid", & $$->segment_width);		  $$->dir = current_direction;		}	| ARROW		{		  $$ = new object_spec(ARROW_OBJECT);		  lookup_variable("lineht", & $$->segment_height);		  lookup_variable("linewid", & $$->segment_width);		  $$->dir = current_direction;		}	| MOVE		{		  $$ = new object_spec(MOVE_OBJECT);		  lookup_variable("moveht", & $$->segment_height);		  lookup_variable("movewid", & $$->segment_width);		  $$->dir = current_direction;		}	| SPLINE		{		  $$ = new object_spec(SPLINE_OBJECT);		  lookup_variable("lineht", & $$->segment_height);		  lookup_variable("linewid", & $$->segment_width);		  $$->dir = current_direction;		}	| text							%prec TEXT		{		  $$ = new object_spec(TEXT_OBJECT);		  $$->text = new text_item($1.str, $1.filename, $1.lineno);		}	| PLOT expr		{		  $$ = new object_spec(TEXT_OBJECT);		  $$->text = new text_item(format_number(0, $2), 0, -1);		}	| PLOT expr text		{		  $$ = new object_spec(TEXT_OBJECT);		  $$->text = new text_item(format_number($3.str, $2),					   $3.filename, $3.lineno);		  a_delete $3.str;		}	| '['		{		  saved_state *p = new saved_state;		  $<pstate>$ = p;		  p->x = current_position.x;		  p->y = current_position.y;		  p->dir = current_direction;		  p->tbl = current_table;		  p->prev = current_saved_state;		  current_position.x = 0.0;		  current_position.y = 0.0;		  current_table = new PTABLE(place);		  current_saved_state = p;		  olist.append(make_mark_object());		}	  element_list ']'		{		  current_position.x = $<pstate>2->x;		  current_position.y = $<pstate>2->y;		  current_direction = $<pstate>2->dir;		  $$ = new object_spec(BLOCK_OBJECT);		  olist.wrap_up_block(& $$->oblist);		  $$->tbl = current_table;		  current_table = $<pstate>2->tbl;		  current_saved_state = $<pstate>2->prev;		  delete $<pstate>2;		}	| object_spec HEIGHT expr		{		  $$ = $1;		  $$->height = $3;		  $$->flags |= HAS_HEIGHT;		}	| object_spec RADIUS expr		{		  $$ = $1;		  $$->radius = $3;		  $$->flags |= HAS_RADIUS;		}	| object_spec WIDTH expr		{		  $$ = $1;		  $$->width = $3;		  $$->flags |= HAS_WIDTH;		}	| object_spec DIAMETER expr		{		  $$ = $1;		  $$->radius = $3/2.0;		  $$->flags |= HAS_RADIUS;		}	| object_spec expr					%prec HEIGHT		{		  $$ = $1;		  $$->flags |= HAS_SEGMENT;		  switch ($$->dir) {		  case UP_DIRECTION:		    $$->segment_pos.y += $2;		    break;		  case DOWN_DIRECTION:		    $$->segment_pos.y -= $2;		    break;		  case RIGHT_DIRECTION:		    $$->segment_pos.x += $2;		    break;		  case LEFT_DIRECTION:		    $$->segment_pos.x -= $2;		    break;		  }		}	| object_spec UP		{		  $$ = $1;		  $$->dir = UP_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.y += $$->segment_height;		}	| object_spec UP expr		{		  $$ = $1;		  $$->dir = UP_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.y += $3;		}	| object_spec DOWN		{		  $$ = $1;		  $$->dir = DOWN_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.y -= $$->segment_height;		}	| object_spec DOWN expr		{		  $$ = $1;		  $$->dir = DOWN_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.y -= $3;		}	| object_spec RIGHT		{		  $$ = $1;		  $$->dir = RIGHT_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.x += $$->segment_width;		}	| object_spec RIGHT expr		{		  $$ = $1;		  $$->dir = RIGHT_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.x += $3;		}	| object_spec LEFT		{		  $$ = $1;		  $$->dir = LEFT_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.x -= $$->segment_width;		}	| object_spec LEFT expr		{		  $$ = $1;		  $$->dir = LEFT_DIRECTION;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.x -= $3;		}	| object_spec FROM position		{		  $$ = $1;		  $$->flags |= HAS_FROM;		  $$->from.x = $3.x;		  $$->from.y = $3.y;		}	| object_spec TO position		{		  $$ = $1;		  if ($$->flags & HAS_SEGMENT)		    $$->segment_list = new segment($$->segment_pos,						   $$->segment_is_absolute,						   $$->segment_list);		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.x = $3.x;		  $$->segment_pos.y = $3.y;		  $$->segment_is_absolute = 1;		  $$->flags |= HAS_TO;		  $$->to.x = $3.x;		  $$->to.y = $3.y;		}	| object_spec AT position		{		  $$ = $1;		  $$->flags |= HAS_AT;		  $$->at.x = $3.x;		  $$->at.y = $3.y;		  if ($$->type != ARC_OBJECT) {		    $$->flags |= HAS_FROM;		    $$->from.x = $3.x;		    $$->from.y = $3.y;		  }		}	| object_spec WITH path		{		  $$ = $1;		  $$->flags |= HAS_WITH;		  $$->with = $3;		}	| object_spec WITH position				%prec ','		{		  $$ = $1;		  $$->flags |= HAS_WITH;		  position pos;		  pos.x = $3.x;		  pos.y = $3.y;		  $$->with = new path(pos);		}	| object_spec BY expr_pair		{		  $$ = $1;		  $$->flags |= HAS_SEGMENT;		  $$->segment_pos.x += $3.x;		  $$->segment_pos.y += $3.y;		}	| object_spec THEN		{		  $$ = $1;		  if ($$->flags & HAS_SEGMENT) {		    $$->segment_list = new segment($$->segment_pos,						   $$->segment_is_absolute,						   $$->segment_list);		    $$->flags &= ~HAS_SEGMENT;		    $$->segment_pos.x = $$->segment_pos.y = 0.0;		    $$->segment_is_absolute = 0;		  }		}	| object_spec SOLID		{		  $$ = $1;	// nothing		}	| object_spec DOTTED		{		  $$ = $1;		  $$->flags |= IS_DOTTED;		  lookup_variable("dashwid", & $$->dash_width);		}	| object_spec DOTTED expr		{		  $$ = $1;		  $$->flags |= IS_DOTTED;		  $$->dash_width = $3;		}	| object_spec DASHED

⌨️ 快捷键说明

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