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

📄 vcg.c

📁 bison 2.0 主要可以用来做语法分析用的
💻 C
📖 第 1 页 / 共 2 页
字号:
/* VCG description handler for Bison.   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.   This file is part of Bison, the GNU Compiler Compiler.   Bison 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.   Bison 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 Bison; see the file COPYING.  If not, write to   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,   Boston, MA 02111-1307, USA.  */#include "system.h"#include <quotearg.h>#include "vcg.h"#include "vcg_defaults.h"/* Return an unambiguous printable representated, for NAME, suitable   for C strings.  Use slot 2 since the user may use slots 0 and 1.   */static char const *quote (char const *name){  return quotearg_n_style (2, c_quoting_style, name);}/* Initialize a graph with the default values. */voidnew_graph (graph *g){  g->title = G_TITLE;  g->label = G_LABEL;  g->infos[0] = G_INFOS1;  g->infos[1] = G_INFOS2;  g->infos[2] = G_INFOS3;  g->color = G_COLOR;  g->textcolor = G_TEXTCOLOR;  g->bordercolor = G_BORDERCOLOR;  g->width = G_WIDTH;  g->height = G_HEIGHT;  g->borderwidth = G_BORDERWIDTH;  g->x = G_X;  g->y = G_Y;  g->folding = G_FOLDING;  g->shrink = G_SHRINK;  g->stretch = G_STRETCH;  g->textmode = G_TEXTMODE;  g->shape = G_SHAPE;  g->vertical_order = G_VERTICAL_ORDER;  g->horizontal_order = G_HORIZONTAL_ORDER;  g->xmax = G_XMAX; /* Not output. */  g->ymax = G_YMAX; /* Not output. */  g->xbase = G_XBASE;  g->ybase = G_YBASE;  g->xspace = G_XSPACE;  g->yspace = G_YSPACE;  g->xlspace = G_XLSPACE; /* Not output. */  g->xraster = G_XRASTER;  g->yraster = G_YRASTER;  g->xlraster = G_XLRASTER;  g->hidden = G_HIDDEN; /* No default value. */  g->classname = G_CLASSNAME; /* No class name association. */  g->layout_downfactor = G_LAYOUT_DOWNFACTOR;  g->layout_upfactor = G_LAYOUT_UPFACTOR;  g->layout_nearfactor = G_LAYOUT_NEARFACTOR;  g->layout_splinefactor = G_LAYOUT_SPLINEFACTOR;  g->late_edge_labels = G_LATE_EDGE_LABELS;  g->display_edge_labels = G_DISPLAY_EDGE_LABELS;  g->dirty_edge_labels = G_DIRTY_EDGE_LABELS;  g->finetuning = G_FINETUNING;  g->ignore_singles = G_IGNORE_SINGLES;  g->priority_phase = G_PRIORITY_PHASE;  g->manhattan_edges = G_MANHATTAN_EDGES;  g->smanhattan_edges = G_SMANHATTAN_EDGES;  g->near_edges = G_NEAR_EDGES;  g->orientation = G_ORIENTATION;  g->node_alignment = G_NODE_ALIGNMENT;  g->port_sharing = G_PORT_SHARING;  g->arrow_mode = G_ARROW_MODE;  g->treefactor = G_TREEFACTOR;  g->spreadlevel = G_SPREADLEVEL;  g->crossing_weight = G_CROSSING_WEIGHT;  g->crossing_phase2 = G_CROSSING_PHASE2;  g->crossing_optimization = G_CROSSING_OPTIMIZATION;  g->view = G_VIEW;  g->edges = G_EDGES;  g->nodes = G_NODES;  g->splines = G_SPLINES;  g->bmax = G_BMAX;  g->cmin = G_CMIN;  g->cmax = G_CMAX;  g->pmin = G_PMIN;  g->pmax = G_PMAX;  g->rmin = G_RMIN;  g->rmax = G_RMAX;  g->smax = G_SMAX;  g->node_list = G_NODE_LIST;  g->edge_list = G_EDGE_LIST;  new_edge (&g->edge);  new_node (&g->node);}/* Initialize a node with the default values. */voidnew_node (node *n){  n->title = N_TITLE;  n->label = N_LABEL;  n->locx = N_LOCX; /* Default unspcified. */  n->locy = N_LOCY; /* Default unspcified. */  n->vertical_order = N_VERTICAL_ORDER;	/* Default unspcified. */  n->horizontal_order = N_HORIZONTAL_ORDER;	/* Default unspcified. */  n->width = N_WIDTH; /* We assume that we can't define it now. */  n->height = N_HEIGHT; /* Also. */  n->shrink = N_SHRINK;  n->stretch = N_STRETCH;  n->folding = N_FOLDING; /* No explicit default value. */  n->shape = N_SHAPE;  n->textmode = N_TEXTMODE;  n->borderwidth = N_BORDERWIDTH;  n->color = N_COLOR;  n->textcolor = N_TEXTCOLOR;  n->bordercolor = N_BORDERCOLOR;  n->infos[0] = N_INFOS1;  n->infos[1] = N_INFOS2;  n->infos[2] = N_INFOS3;  n->next = N_NEXT;}/* Initialize an edge with the default values. */voidnew_edge (edge *e){  e->type = E_EDGE_TYPE;  e->sourcename = E_SOURCENAME;  e->targetname = E_TARGETNAME;  e->label = E_LABEL;  e->linestyle = E_LINESTYLE;  e->thickness = E_THICKNESS;  e->class = E_CLASS;  e->color = E_COLOR;  e->textcolor = E_TEXTCOLOR;  e->arrowcolor = E_ARROWCOLOR;  e->backarrowcolor = E_BACKARROWCOLOR;  e->arrowsize = E_ARROWSIZE;  e->backarrowsize = E_BACKARROWSIZE;  e->arrowstyle = E_ARROWSTYLE;  e->backarrowstyle = E_BACKARROWSTYLE;  e->priority = E_PRIORITY;  e->anchor = E_ANCHOR;  e->horizontal_order = E_HORIZONTAL_ORDER;  e->next = E_NEXT;}/*----------------------------------------------.| Get functions.       	                        || Return string corresponding to an enum value. |`----------------------------------------------*/static const char *get_color_str (enum color color){  switch (color)    {    case white:		return "white";    case blue:		return "blue";    case red:		return "red";    case green:		return "green";    case yellow:	return "yellow";    case magenta:	return "magenta";    case cyan:		return "cyan";    case darkgrey:	return "darkgrey";    case darkblue:	return "darkblue";    case darkred:	return "darkred";    case darkgreen:	return "darkgreen";    case darkyellow:	return "darkyellow";    case darkmagenta:	return "darkmagenta";    case darkcyan:	return "darkcyan";    case gold:		return "gold";    case lightgrey:	return "lightgrey";    case lightblue:	return "lightblue";    case lightred:	return "lightred";    case lightgreen:	return "lightgreen";    case lightyellow:	return "lightyellow";    case lightmagenta:	return "lightmagenta";    case lightcyan:	return "lightcyan";    case lilac:		return "lilac";    case turquoise:	return "turquoise";    case aquamarine:	return "aquamarine";    case khaki:		return "khaki";    case purple:	return "purple";    case yellowgreen:	return "yellowgreen";    case pink:		return "pink";    case orange:	return "orange";    case orchid:	return "orchid";    case black:		return "black";    default:		abort (); return NULL;    }}static const char *get_textmode_str (enum textmode textmode){  switch (textmode)    {    case centered:	return "center";    case left_justify:	return "left_justify";    case right_justify:	return "right_justify";    default:		abort (); return NULL;    }}static const char *get_shape_str (enum shape shape){  switch (shape)    {    case box:		return "box";    case rhomb:		return "rhomb";    case ellipse:	return "ellipse";    case triangle:	return "triangle";    default:		abort (); return NULL;    }}static const char *get_decision_str (enum decision decision){  switch (decision)    {    case no:	return "no";    case yes:	return "yes";    default:	abort (); return NULL;    }}static const char *get_orientation_str (enum orientation orientation){  switch (orientation)    {    case top_to_bottom:	return "top_to_bottom";    case bottom_to_top: return "bottom_to_top";    case left_to_right: return "left_to_right";    case right_to_left: return "right_to_left";    default:		abort (); return NULL;    }}static const char *get_node_alignment_str (enum alignment alignment){  switch (alignment)    {    case center:	return "center";    case top:		return "top";    case bottom:	return "bottom";    default:		abort (); return NULL;    }}static const char *get_arrow_mode_str (enum arrow_mode arrow_mode){  switch (arrow_mode)    {    case fixed:		return "fixed";    case free_a:	return "free";    default:		abort (); return NULL;    }}static const char *get_crossing_type_str (enum crossing_type crossing_type){  switch (crossing_type)    {    case bary:		return "bary";    case median:	return "median";    case barymedian:	return "barymedian";    case medianbary:	return "medianbary";    default:		abort (); return NULL;    }}static const char *get_view_str (enum view view){  switch (view)    {    case normal_view:	return "normal_view";    case cfish:		return "cfish";    case pfish:		return "pfish";    case fcfish:	return "fcfish";    case fpfish:	return "fpfish";    default:		abort (); return NULL;    }}static const char *get_linestyle_str (enum linestyle linestyle){  switch (linestyle)    {    case continuous:	return "continuous";    case dashed:	return "dashed";    case dotted:	return "dotted";    case invisible:	return "invisible";    default:		abort (); return NULL;    }}static const char *get_arrowstyle_str (enum arrowstyle arrowstyle){  switch (arrowstyle)    {    case solid:	return "solid";    case line:	return "line";    case none:	return "none";    default:	abort (); return NULL;    }}/*------------------------------.| Add functions.       	        || Edge and nodes into a graph.  |`------------------------------*/voidadd_node (graph *g, node *n){  n->next = g->node_list;  g->node_list = n;}voidadd_edge (graph *g, edge *e){  e->next = g->edge_list;  g->edge_list = e;}voidadd_classname (graph *g, int val, const char *name){  struct classname *classname = xmalloc (sizeof *classname);  classname->no = val;  classname->name = name;  classname->next = g->classname;  g->classname = classname;}voidadd_infoname (graph *g, int integer, const char *str){  struct infoname *infoname = xmalloc (sizeof *infoname);  infoname->integer = integer;  infoname->chars = str;  infoname->next = g->infoname;  g->infoname = infoname;}/* Build a colorentry struct and add it to the list.  */voidadd_colorentry (graph *g, int color_idx, int red_cp,		int green_cp, int blue_cp){  struct colorentry *ce = xmalloc (sizeof *ce);  ce->color_index = color_idx;

⌨️ 快捷键说明

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