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

📄 macedon.y

📁 这是一个著名的应用层组播中间件的源码
💻 Y
📖 第 1 页 / 共 2 页
字号:
//Copyright (c) 2004, Charles Killian, Adolfo Rodriguez, Dejan Kostic, Sooraj Bhat, and Amin Vahdat//All rights reserved.////Redistribution and use in source and binary forms, with or without//modification, are permitted provided that the following conditions are met:////   * Redistributions of source code must retain the above copyright//     notice, this list of conditions and the following disclaimer.//   * Redistributions in binary form must reproduce the above copyright//     notice, this list of conditions and the following disclaimer in//     the documentation and/or other materials provided with the//     distribution.//   * Neither the names of Duke University nor The University of//     California, San Diego, nor the names of its contributors//     may be used to endorse or promote products derived from//     this software without specific prior written permission.////THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE//IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE//FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL//DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE//USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.%{#include <stdio.h>#include <string.h>#include <stdlib.h>#include "macedon-conv-utils.h"    int protocol_done = 1; /* 1 if done, 0 otherwise */char *message_str; char *transition_stimulus_str; #define MAX_ARGS 50char *mymessage_args[MAX_ARGS];int num_message_args;char *cur_state;char *temp_str;char *temp_str2;int init_func = 0;char include_buf[2048];char *include_ptr = include_buf;char *progname = "macedon";char *protocol_name;char *base_name;char *mac_name;char *agent_name; // not used (yet) ...SoorajFILE *hfile, *hfile2, *cfile, *cfilefuncs, *cfile2,      *hfilemacros;int lineno = 1;int API_specified[API_num_types];int trans_API=0;int trans_API_index=0;int trans_locking=LOCK_UNSPECIFIED;int data_in_specified=0;int addressing;int tracing=0;const int PARSE_INIT = 0;const int PARSE_TRANSITIONS = 10;const int PARSE_PERIPHERALS = 20; const int PARSE_ROUTINES = 30;int parse_stage = 0; char the_param_list[128];char *usage = "usage: %s [infile] [outfile]\n";%}%union {    char    *string;     /* string buffer */    int cmd;    int    intval;          /* command value */}%token <string> ID IDCOMP STATE_EXPR TRANS_NAME%token <cmd> PROTOCOL USES CONSTANTS NODE_TYPES STATES PERIPHERALS MESSAGES TRANSPORTS%token <cmd> INT DOUBLE CHAR EXPORTED TRANSITIONS TIMER%token <cmd> OBRACE CBRACE STRING RECV SEMI EQ TRACE_OFF TRACE_LOW%token <cmd> TRACE_MED TRACE_HIGH CLASS OBRACKET CBRACKET%token <cmd> OPAREN CPAREN API FORWARD ADDRESSING IP HASH NODUMP%token <cmd> NEIGHBOR_TYPES TCP UDP SWP TFRC BASE_RELIAB BASE_UNRELIAB STAR%token <cmd> ROUTINES PARAM_LIST LOCKING%token <intval> NUM GRAFT_HEAD GRAFT_BODY FAIL_DETECT%type <string> id%type <string> idcomp%type <string> transition_type%type <string> transition_name%type <intval> num%type <string> state_expr%start protocol%%protocol:   protocol_name protocol_body { end_agent(); }	    ;protocol_name: PROTOCOL id { 	       start_protocol($2, 0); 	       }	       | PROTOCOL id USES id {	       start_protocol($2, $4);	       }	       | PROTOCOL   { start_protocol(strdup("default")); }	       ;protocol_body:  addressing trace constants node_types states neighbor_types complete_messages peripherals transitions routines		;  addressing:  ADDRESSING IP { addressing = AD_IP; }	     | ADDRESSING HASH { addressing = AD_HASH; }	     ;          trace:  TRACE_HIGH { tracing=3; }	  | TRACE_MED { tracing=2; }	  | TRACE_LOW { tracing=1; }	  | TRACE_OFF { tracing=0; }	  |	  ;constants: constants1 constants2 {}	   ;constants1: CONSTANTS { begin_constants(); }	    ;constants2: OBRACE constants_recur CBRACE  	   { done_constants(); fprintf(hfile, "\n");}             | CONSTANTS OBRACE CBRACE  	   { done_constants(); fprintf(hfile, "\n");}  	       ;constants_recur:  constant SEMI	 		  | constants_recur constant SEMI		  ;constant:   INT id EQ idcomp { add_constant($2, $4, "int"); }	    | DOUBLE id EQ idcomp { add_constant($2, $4, "double"); }	    | INT id EQ id { add_constant($2, $4, "int"); }	    | DOUBLE id EQ id { add_constant($2, $4, "double"); }	    | INT id EQ num { 		      temp_str = (char *)malloc(40);	      sprintf(temp_str, "%d",$4);	      add_constant($2, temp_str, "int"); 	      }	    | DOUBLE id EQ num { 		      temp_str = (char *)malloc(40);	      sprintf(temp_str, "%d",$4);	      add_constant($2, temp_str, "double"); 	      }	      ;node_types:	NODE_TYPES OBRACE node_types_recur CBRACE  {		done_node_types(); }		|	;node_types_recur:	node_type SEMI	| node_types_recur node_type SEMI	;node_type:	id { add_type($1); }	;states:	STATES OBRACE states_recur CBRACE {	add_state("init", "unready");  done_states();	}  |  { add_state("init", "unready"); done_states(); }	;states_recur:	state SEMI	| states_recur state SEMI	;state:	 id { add_state($1,NULL); }  | id id { add_state($1,$2); }	;neighbor_types:  NEIGHBOR_TYPES OBRACE neighbor_types_recur CBRACE {		 done_neighbor_types(); }		 ;neighbor_types_recur:	neighbor_type			| neighbor_types_recur neighbor_type			;neighbor_type:		neighbor_type1 SEMI			| neighbor_type1 OBRACE neighbor_type_fields_recur CBRACE			;neighbor_type1:		id num {			  temp_str = (char *)malloc(40);			  sprintf(temp_str, "%d", $2);			  add_neighbor_type($1, temp_str)	;			}			| id id {			  add_neighbor_type($1, $2);			}			;neighbor_type_fields_recur: neighbor_type_field			    | neighbor_type_fields_recur neighbor_type_field			    ;neighbor_type_field:	    id id SEMI {			      add_neighbor_type_field($1, $2);			    }			    | INT id SEMI {			      add_neighbor_type_field("int", $2);			   }			    | DOUBLE id SEMI {			      add_neighbor_type_field("double", $2);			   }			    ;peripherals:	peripherals1 peripherals2 { parse_stage = PARSE_INIT; }		;peripherals1:	PERIPHERALS OBRACE { parse_stage = PARSE_PERIPHERALS; }		;peripherals2:	peripherals_recur CBRACE { start_agent(); }		| peripherals2a peripherals2b {}		;peripherals2a:	peripherals_recur GRAFT_HEAD { start_agent(); }		;peripherals2b:	GRAFT_BODY CBRACE {}		;peripherals_recur:	peripheral	| peripherals_recur peripheral	;peripheral: generic_peripheral	    | neighbor_peripheral	    ;neighbor_peripheral:	nbr_periph SEMI			| nbr_periph nbr_class SEMI			;nbr_periph:	FAIL_DETECT nbr_periph_base { add_failure(); }		|  nbr_periph_base 		;nbr_periph_base:			id id { add_periph(0, $2, $1, 0); }		| id id id  { add_periph_array(0,$2, $1, $3); }		| id id id id  { add_periph_array_2d(0,$2, $1, $3, $4); }		| id id id id id  { add_periph_array_3d(0,$2, $1, $3, $4, $5); }		;nbr_class:	CLASS id { assoc_nbr_class ($2); }		;generic_peripheral:			INT id SEMI { add_periph(0,$2, "int", 0); }		| INT id NODUMP SEMI { add_periph(1, $2, "int", 0); }		| INT id id SEMI { add_periph_array(0, $2, "int", $3); }		| EXPORTED INT id SEMI { add_periph(0, $3, "int", 1);}		| DOUBLE id SEMI { add_periph(0, $2, "double", 0); }		| DOUBLE id id SEMI { add_periph_array(0,$2, "double", $3); }		| EXPORTED DOUBLE id SEMI { add_periph(0,$3, "double", 1);}		| CHAR STAR id SEMI { add_periph(0, $3, "char *", 0); }		| CHAR STAR id NODUMP SEMI { add_periph(1, $3, "char *", 0); }		| TIMER id id SEMI { add_timer($2, $3); }		| TIMER id SEMI { add_timer_nonperiod($2); }		;complete_messages:  messages		    | transports messages		    ;transports:  TRANSPORTS OBRACE transports_recur CBRACE {	     }			     ;transports_recur:  transport		    | transports_recur transport		    ;transport: id id SEMI { add_transport($1, $2, 0); } |	  id id num SEMI{ add_transport($1, $2, $3); }	    ;messages:   messages1 messages2	    ;

⌨️ 快捷键说明

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