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

📄 macedon.l

📁 这是一个著名的应用层组播中间件的源码
💻 L
字号:
/*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 "macedon-conv.h"#include <string.h>  extern int lineno;  extern char* mac_name;  extern FILE* hfile;  extern FILE* cfilefuncs;  extern int parse_stage;  extern const int PARSE_INIT;  extern const int PARSE_TRANSITIONS;  extern const int PARSE_PERIPHERALS;   extern const int PARSE_ROUTINES;  extern char the_param_list[128];extern char *protocol_name;  extern char include_buf[1024];  extern char *include_ptr;  int saved_state;  /* C-style-comment handling taken from the online GNU Flex tutorial */%}%x comment%x protocol_block%x routines_block%%"//".*          { }"/*"	        { saved_state = YY_START; BEGIN(comment); }\n		{ sprintf(include_ptr,"%c",yytext[0]); include_ptr++; lineno++; }[^p\/\n]+       { sprintf(include_ptr,"%s",yytext); include_ptr += strlen(include_ptr); }.		{ sprintf(include_ptr,"%c",yytext[0]); include_ptr++; }protocol	{ BEGIN(protocol_block); return PROTOCOL; }<comment>{  [^*\n]*        { /* eat anything that's not a '*' */ }  \*+[^*/\n]*    { /* eat up '*'s not followed by '/'s */ }  \n             { lineno++; }  \*+\/          { BEGIN(saved_state); }   }<protocol_block>{  [ \t]+		{ }  "//".*      	{ }  "/*"		{ saved_state = YY_START; BEGIN(comment); }  addressing      { return ADDRESSING; }  routines	{ BEGIN(routines_block); return ROUTINES; }  ip              { return IP; }  class		{ return CLASS; }  fail_detect		{ return FAIL_DETECT; }  hash		{ return HASH; }  nodump		{ return NODUMP; }  trace_high      { return TRACE_HIGH; }  trace_med       { return TRACE_MED; }  trace_low       { return TRACE_LOW; }  trace_off       { return TRACE_OFF; }  uses		{ return USES; }  constants	{ return CONSTANTS; }  transports	{ return TRANSPORTS; }  node_types	{ return NODE_TYPES; }  states		{ return STATES; }  /*peripherals	{ return PERIPHERALS; }*/  state_variables	{ return PERIPHERALS; }  messages	{ return MESSAGES; }  int		{ return INT; }  timer		{ return TIMER; }  double		{ return DOUBLE; }  char		{ return CHAR; }  string		{ return STRING; }  recv		{ return RECV; }  forward		{ return FORWARD; }  exported	{ return EXPORTED; }  ;               { return SEMI; }  locking	    { return LOCKING; }  transitions	{ return TRANSITIONS; }  \)		{ return CPAREN; }  =		{ return EQ; }  neighbor_types  { return NEIGHBOR_TYPES; }  API		{ return API;}  \{		{ return graft(); }  \(		{ return check_if_param_list(); }  \}		{ return CBRACE; }  \*		{ return STAR; }  \[		{ return OBRACKET; }  \]		{ return CBRACKET; }  [0-9][0-9]*			    { yylval.intval = atof(yytext); return NUM; }  [0!a-zA-Z][\[.\]\->_a-zA-Z0-9<>]*   { yylval.string = strdup(yytext); return ID; }  [!0-9a-zA-Z][*/\-+_a-zA-Z0-9]*	    { yylval.string = strdup(yytext); return IDCOMP; }  [_!|\(\)a-zA-Z*\?0-9]+		    { yylval.string = strdup(yytext); return STATE_EXPR; }}<routines_block>{  [ \t]+      { }  "//".*	{ }  "/*"	{ saved_state = YY_START; BEGIN(comment); }  \{		{ return graft(); }  \(		{ return check_if_param_list(); }  \}		{ return CBRACE; }  \*		{ return STAR; }  [0!a-zA-Z][\[.\]\->_a-zA-Z0-9<>]*  { yylval.string = strdup(yytext); return ID; }}<*>\n	{ lineno++; }%%check_if_param_list(){  int ch,i=0;  if (parse_stage == PARSE_ROUTINES)  {    while ((ch = input()) != 0)    {      if (ch == '\n') lineno++;      if (ch == ')')      {        the_param_list[i]=0;        return PARAM_LIST;      }	      the_param_list[i++] = ch;    }    yyerror("Unexpected EOF while copying param list.\n");  }  else  {    return OPAREN;  }}graft(){  int ch, count=1;  static int funcsCount = 0;  funcsCount++;  if (parse_stage == PARSE_TRANSITIONS)  {    /* useful for debugging */    fprintf(cfilefuncs,"\n#line %d \"%s\"\n",lineno,mac_name);     while ((ch = input()) != 0)    {      if (ch == '\n') lineno++;      if (ch == '}')      {          count--;        if (count == 0) {          fprintf(cfilefuncs,"\n#line %d000 \"%s-funcs.cc\"\n",funcsCount,protocol_name);           return GRAFT_BODY;        }        }      if (ch == '{')        count++;      fputc(ch, cfilefuncs);    }    yyerror("Unexpected EOF while grafting transition.\n");  }  else if (parse_stage == PARSE_PERIPHERALS)  {    while ((ch = input()) != 0)    {      if (ch == '\n') lineno++;      if (ch == '}')      {          count--;        if (count == 0) return GRAFT_BODY;      }      if (ch == '{')        count++;      fputc(ch, hfile);    }    yyerror("Unexpected EOF while grafting peripherals.\n");  }  else if (parse_stage == PARSE_ROUTINES)  {    /* useful for debugging */    fprintf(cfilefuncs,"\n#line %d \"%s\"\n",lineno,mac_name);     while ((ch = input()) != 0)    {      if (ch == '\n') lineno++;      if (ch == '}')      {        count--;        if (count == 0) {          fprintf(cfilefuncs,"\n#line %d000 \"%s-funcs.cc\"\n",funcsCount,protocol_name);           return GRAFT_BODY;        }        }      if (ch == '{')        count++;      fputc(ch, cfilefuncs);    }    yyerror("Unexpeced EOF while grafting routines.\n");  }  else  {    return OBRACE;  }}

⌨️ 快捷键说明

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