#include <map>
#include <vector>
#include <typeinfo>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "nodes/protomake.h"
Include dependency graph for protomakeParse.cpp:
Go to the source code of this file.
Compounds | |
struct | FieldTypeInfo |
union | yyalloc |
union | yystype |
Defines | |
#define | YYBISON 1 |
#define | tBEHAVIOR 257 |
#define | tID 258 |
#define | tSTRING 259 |
#define | tTERMSTRING 260 |
#define | tNUMBER 261 |
#define | tMESSAGE 262 |
#define | tIMPORT 263 |
#define | tEXTERNAL 264 |
#define | tBEGIN 265 |
#define | tEND 266 |
#define | tBITS 267 |
#define | tBYTES 268 |
#define | tSTRTYPE 269 |
#define | tBLANKS 270 |
#define | tPROCESS 271 |
#define | tGLOBAL 272 |
#define | tCONST 273 |
#define | tVAR 274 |
#define | tINTEGER 275 |
#define | tADDRESS 276 |
#define | tCLIENTADDRESS 277 |
#define | tSERVERADDRESS 278 |
#define | tARRAY 279 |
#define | tOF 280 |
#define | tRCV 281 |
#define | tFROM 282 |
#define | tTIMEOUT 283 |
#define | tSKIP 284 |
#define | tSEND 285 |
#define | tTO 286 |
#define | tIF 287 |
#define | tFI 288 |
#define | tDO 289 |
#define | tOD 290 |
#define | tACT 291 |
#define | tIN 292 |
#define | tPLUS 293 |
#define | tMINUS 294 |
#define | tTIMES 295 |
#define | tDIVIDE 296 |
#define | tBAND 297 |
#define | tBOR 298 |
#define | tNEG 299 |
#define | tDIFFERENT 300 |
#define | tLTE 301 |
#define | tGTE 302 |
#define | tEQUAL 303 |
#define | tLT 304 |
#define | tGT 305 |
#define | tGUARD 306 |
#define | tLBRACKET 307 |
#define | tRBRACKET 308 |
#define | tLPAR 309 |
#define | tRPAR 310 |
#define | tCOMMA 311 |
#define | tCOLON 312 |
#define | tSCOLON 313 |
#define | tACTION 314 |
#define | tDOT 315 |
#define | tRANGE 316 |
#define | tASSIGN 317 |
#define | tDQUOTE 318 |
#define | tSTART 319 |
#define | tSTOP 320 |
#define | UMINUS 321 |
#define | YYSTYPE yystype |
#define | YYSTYPE_IS_TRIVIAL 1 |
#define | YYDEBUG 0 |
#define | YYFINAL 223 |
#define | YYFLAG -32768 |
#define | YYNTBASE 68 |
#define | YYTRANSLATE(x) ((unsigned)(x) <= 321 ? yytranslate[x] : 106) |
#define | YYLAST 311 |
#define | YYSTACK_ALLOC malloc |
#define | YYSTACK_FREE free |
#define | YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) |
#define | YYSTACK_BYTES(N) |
#define | YYCOPY(To, From, Count) |
#define | YYSTACK_RELOCATE(Stack) |
#define | YYSIZE_T unsigned int |
#define | yyerrok (yyerrstatus = 0) |
#define | yyclearin (yychar = YYEMPTY) |
#define | YYEMPTY -2 |
#define | YYEOF 0 |
#define | YYACCEPT goto yyacceptlab |
#define | YYABORT goto yyabortlab |
#define | YYERROR goto yyerrlab1 |
#define | YYFAIL goto yyerrlab |
#define | YYRECOVERING() (!!yyerrstatus) |
#define | YYBACKUP(Token, Value) |
#define | YYTERROR 1 |
#define | YYERRCODE 256 |
#define | YYLLOC_DEFAULT(Current, Rhs, N) |
#define | YYLEX yylex() |
#define | YYDPRINTF(Args) |
#define | YYINITDEPTH 200 |
#define | YYMAXDEPTH 10000 |
#define | YYPARSE_PARAM_ARG |
#define | YYPARSE_PARAM_DECL |
#define | YY_DECL_NON_LSP_VARIABLES |
#define | YY_DECL_VARIABLES YY_DECL_NON_LSP_VARIABLES |
#define | YYPOPSTACK (yyvsp--, yyssp--) |
Typedefs | |
typedef FieldTypeInfo | FieldTypeInfo |
Functions | |
int | yylex (void) |
int | yyerror (char *msg) |
YY_DECL_VARIABLES int | yyparse (YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL |
int | main (int argc, char **argv) |
void | generateEtherealPlugin (map< string, vector< FieldInfo > > *fiMap, multimap< EtherType, EtherInfoType > *eit) |
void | writeHeader (FILE *plugin, char *fileName, multimap< EtherType, EtherInfoType > *eit) |
void | writeDissector (FILE *plugin, map< string, vector< FieldInfo > > *fiMap, multimap< EtherType, EtherInfoType > *eit) |
void | writeRest (FILE *plugin, char *trans, char *port, char *abbrev) |
Variables | |
int | lines |
Program * | root |
const char | yytranslate [] |
const short | yyr1 [] |
const short | yyr2 [] |
const short | yydefact [] |
const short | yydefgoto [] |
const short | yypact [] |
const short | yypgoto [] |
const short | yytable [] |
const short | yycheck [] |
|
Definition at line 40 of file protomakeParse.cpp. |
|
Definition at line 63 of file protomakeParse.cpp. |
|
Definition at line 25 of file protomakeParse.cpp. |
|
Definition at line 28 of file protomakeParse.cpp. |
|
Definition at line 66 of file protomakeParse.cpp. |
|
Definition at line 46 of file protomakeParse.cpp. |
|
Definition at line 14 of file protomakeParse.cpp. |
|
Definition at line 6 of file protomakeParse.cpp. |
|
Definition at line 16 of file protomakeParse.cpp. |
|
Definition at line 19 of file protomakeParse.cpp. |
|
Definition at line 47 of file protomakeParse.cpp. |
|
Definition at line 17 of file protomakeParse.cpp. |
|
Definition at line 26 of file protomakeParse.cpp. |
|
Definition at line 61 of file protomakeParse.cpp. |
|
Definition at line 60 of file protomakeParse.cpp. |
|
Definition at line 22 of file protomakeParse.cpp. |
|
Definition at line 49 of file protomakeParse.cpp. |
|
Definition at line 45 of file protomakeParse.cpp. |
|
Definition at line 38 of file protomakeParse.cpp. |
|
Definition at line 64 of file protomakeParse.cpp. |
|
Definition at line 67 of file protomakeParse.cpp. |
|
Definition at line 15 of file protomakeParse.cpp. |
|
Definition at line 52 of file protomakeParse.cpp. |
|
Definition at line 13 of file protomakeParse.cpp. |
|
Definition at line 37 of file protomakeParse.cpp. |
|
Definition at line 31 of file protomakeParse.cpp. |
|
Definition at line 21 of file protomakeParse.cpp. |
|
Definition at line 54 of file protomakeParse.cpp. |
|
Definition at line 51 of file protomakeParse.cpp. |
|
Definition at line 55 of file protomakeParse.cpp. |
|
Definition at line 7 of file protomakeParse.cpp. |
|
Definition at line 36 of file protomakeParse.cpp. |
|
Definition at line 12 of file protomakeParse.cpp. |
|
Definition at line 41 of file protomakeParse.cpp. |
|
Definition at line 24 of file protomakeParse.cpp. |
|
Definition at line 56 of file protomakeParse.cpp. |
|
Definition at line 58 of file protomakeParse.cpp. |
|
Definition at line 53 of file protomakeParse.cpp. |
|
Definition at line 50 of file protomakeParse.cpp. |
|
Definition at line 11 of file protomakeParse.cpp. |
|
Definition at line 43 of file protomakeParse.cpp. |
|
Definition at line 48 of file protomakeParse.cpp. |
|
Definition at line 10 of file protomakeParse.cpp. |
|
Definition at line 39 of file protomakeParse.cpp. |
|
Definition at line 29 of file protomakeParse.cpp. |
|
Definition at line 42 of file protomakeParse.cpp. |
|
Definition at line 20 of file protomakeParse.cpp. |
|
Definition at line 65 of file protomakeParse.cpp. |
|
Definition at line 57 of file protomakeParse.cpp. |
|
Definition at line 30 of file protomakeParse.cpp. |
|
Definition at line 59 of file protomakeParse.cpp. |
|
Definition at line 62 of file protomakeParse.cpp. |
|
Definition at line 34 of file protomakeParse.cpp. |
|
Definition at line 27 of file protomakeParse.cpp. |
|
Definition at line 33 of file protomakeParse.cpp. |
|
Definition at line 68 of file protomakeParse.cpp. |
|
Definition at line 69 of file protomakeParse.cpp. |
|
Definition at line 8 of file protomakeParse.cpp. |
|
Definition at line 18 of file protomakeParse.cpp. |
|
Definition at line 9 of file protomakeParse.cpp. |
|
Definition at line 32 of file protomakeParse.cpp. |
|
Definition at line 44 of file protomakeParse.cpp. |
|
Definition at line 35 of file protomakeParse.cpp. |
|
Definition at line 23 of file protomakeParse.cpp. |
|
Definition at line 70 of file protomakeParse.cpp. |
|
Value: \ int yychar; \ \ YYSTYPE yylval; \ \ \ int yynerrs; Definition at line 861 of file protomakeParse.cpp. |
|
Definition at line 877 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 672 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 671 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Value: do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up"); \ YYERROR; \ } \ while (0) Definition at line 679 of file protomakeParse.cpp. |
|
Definition at line 4 of file protomakeParse.cpp. |
|
Definition at line 668 of file protomakeParse.cpp. |
|
Value: do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) Definition at line 621 of file protomakeParse.cpp. |
|
Definition at line 175 of file protomakeParse.cpp. |
|
Definition at line 752 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 669 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 670 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 697 of file protomakeParse.cpp. |
|
Definition at line 667 of file protomakeParse.cpp. |
|
Definition at line 673 of file protomakeParse.cpp. |
|
Definition at line 677 of file protomakeParse.cpp. |
|
Definition at line 180 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 181 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 757 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 439 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 731 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Value: Current.last_line = Rhs[N].last_line; \ Current.last_column = Rhs[N].last_column; Definition at line 708 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 772 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 182 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 845 of file protomakeParse.cpp. |
|
Definition at line 846 of file protomakeParse.cpp. Referenced by yyparse(). |
|
|
|
Definition at line 678 of file protomakeParse.cpp. |
|
Definition at line 664 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 579 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Value: ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAX) Definition at line 609 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 580 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 600 of file protomakeParse.cpp. |
|
Value: do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) Definition at line 637 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 171 of file protomakeParse.cpp. |
|
Definition at line 172 of file protomakeParse.cpp. |
|
Definition at line 696 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 185 of file protomakeParse.cpp. Referenced by yyparse(). |
|
|
|
Generates an Ethereal plugin Check if more than one or if no name/port/transport protocol was defined! Create a file with the correct name to write the plugin This alters the element in the multimap. Any statement like this will. Write file header Declare necessary globals Write protocol dissector Write protocol register function Setup the list of header fields Write rest of file Definition at line 2075 of file protomakeParse.cpp. References FieldType::BIT, NAME, PORT, TRANSPORT, writeDissector(), writeHeader(), and writeRest(). Referenced by main().
02077 { 02078 multimap<EtherType, EtherInfoType>::iterator itr; 02079 02081 if (eit->count(NAME) > 1) 02082 { 02083 itr = eit->find(NAME); 02084 itr++; 02085 fprintf(stderr, "Line %d: More than one name was defined for the protocol!\n", 02086 (*itr).second.lines + 1); 02087 exit(1); 02088 } 02089 else if (eit->count(NAME) == 0) 02090 { 02091 fprintf(stderr, "No name was defined for the protocol!\n"); 02092 exit(1); 02093 } 02094 if (eit->count(ABBREV) > 1) 02095 { 02096 itr = eit->find(ABBREV); 02097 itr++; 02098 fprintf(stderr, "Line %d: More than one short name was defined for the protocol!\n", 02099 (*itr).second.lines + 1); 02100 exit(1); 02101 } 02102 else if (eit->count(ABBREV) == 0) 02103 { 02104 fprintf(stderr, "No short name was defined for the protocol!\n"); 02105 exit(1); 02106 } 02107 else if (eit->count(PORT) > 1) 02108 { 02109 itr = eit->find(PORT); 02110 itr++; 02111 fprintf(stderr, "Line %d: More than one port was defined for the protocol!\n", 02112 (*itr).second.lines + 1); 02113 exit(1); 02114 } 02115 else if (eit->count(PORT) == 0) 02116 { 02117 fprintf(stderr, "No port was defined for the protocol!\n"); 02118 exit(1); 02119 } 02120 else if (eit->count(TRANSPORT) > 1) 02121 { 02122 itr = eit->find(TRANSPORT); 02123 itr++; 02124 fprintf(stderr, "Line %d: More than one transport protocol was defined for the protocol!\n", 02125 (*itr).second.lines + 1); 02126 exit(1); 02127 } 02128 else if (eit->count(TRANSPORT) == 0) 02129 { 02130 fprintf(stderr, "No transport protocol was defined for the protocol!\n"); 02131 exit(1); 02132 } 02133 02135 itr = eit->find(ABBREV); 02136 FILE *plugin; 02137 char fileName[256]; 02138 char *abbrev = ++((*itr).second.string); 02139 unsigned i; 02140 02144 abbrev[strlen(abbrev)-1] = '\0'; 02145 for (i = 0; abbrev[i]; i++) 02146 abbrev[i] = tolower(abbrev[i]); 02147 02148 02149 sprintf(fileName, "./plugin/packet-%s.c", (*itr).second.string); 02150 if ((plugin = fopen(fileName, "w")) == NULL) 02151 { 02152 fprintf(stderr, "Unable to create %s!\n", fileName); 02153 exit(1); 02154 } 02155 02157 writeHeader(plugin, fileName, eit); 02158 02160 // Gambiarra para adicionar 02161 int j; 02162 FieldInfo fi; 02163 fi.identifier = "code"; 02164 fi.bitByte = FieldType::BIT; 02165 fi.size = NULL; 02166 02167 j = 1; 02168 fprintf(plugin, "/** Message structures. Inicialize the protocol and registered fields */\n"); 02169 for (map<string, vector<FieldInfo> >::iterator itr = fiMap->begin(); 02170 itr != fiMap->end(); 02171 itr++, j++) 02172 { 02173 fi.init = new IntegerLiteral(NULL, j); 02174 ((*itr).second).push_back(fi); 02175 02176 fprintf(plugin, "typedef struct {\n"); 02177 for (i = 0; i < (*itr).second.size(); i++) 02178 fprintf(plugin, "\tint %s_%s;\n", abbrev, ((*itr).second)[i].identifier); 02179 fprintf(plugin, "} hf_%s_fields;\n", (*itr).first.c_str()); 02180 fprintf(plugin, "static hf_%s_fields hf_%s = { ", (*itr).first.c_str(), (*itr).first.c_str()); 02181 for (i = 0; i < (*itr).second.size(); i++) 02182 { 02183 if (!i) fprintf(plugin, "-1"); 02184 else fprintf(plugin, ", -1"); 02185 } 02186 fprintf(plugin, " };\n\n"); 02187 } 02188 fprintf(plugin, "static int proto_%s = -1;\n\n", abbrev); 02189 fprintf(plugin, "/* Initialize the subtree pointers */\n"); 02190 fprintf(plugin, "static gint ett_%s = -1;\n\n", abbrev); 02191 02193 writeDissector(plugin, fiMap, eit); 02194 02196 fprintf(plugin, "void proto_register_%s(void)\n{\n", abbrev); 02197 fprintf(plugin, "/** Setup list of header fields */\n"); 02198 fprintf(plugin, "\t static hf_register_info hf[] = {\n"); 02199 02201 for (map<string, vector<FieldInfo> >::iterator itr = fiMap->begin(); 02202 itr != fiMap->end(); 02203 itr++) 02204 { 02205 if (itr != fiMap->begin()) 02206 fprintf(plugin, ",\n"); 02207 02208 for (i = 0; i < (*itr).second.size(); i++) 02209 { 02210 if (i) 02211 fprintf(plugin, ",\n"); 02212 fprintf(plugin, "\t\t{ &(hf_%s.%s_%s),\n", (*itr).first.c_str(), abbrev, 02213 ((*itr).second)[i].identifier); 02214 fprintf(plugin, "\t\t\t{ \"%s\", \"%s.%s_%s\",\n", ((*itr).second)[i].identifier, 02215 abbrev, 02216 (*itr).first.c_str(), 02217 ((*itr).second)[i].identifier); 02218 02219 if ((*itr).second[i].bitByte == FieldType::BIT) 02220 fprintf(plugin, "\t\t\tFT_INT32, BASE_DEC, NULL, 0x0,\n\t\t\t\"%s\" }\n", ((*itr).second)[i].identifier); 02221 else 02222 fprintf(plugin, "\t\t\tFT_STRING, BASE_NONE, NULL, 0x0,\n\t\t\t\"%s\" }\n", ((*itr).second)[i].identifier); 02223 fprintf(plugin, "\t\t}"); 02224 } 02225 } 02226 fprintf(plugin, "\n\t};\n\n"); 02227 02228 fprintf(plugin, "/** Setup protocol subtree array */\n"); 02229 fprintf(plugin, "\tstatic gint *ett[] = { &ett_%s };\n\n", abbrev); 02230 02231 fprintf(plugin, "/** Register the protocol name and description */\n"); 02232 char *ABBREV = strdup(abbrev); 02233 for (i = 0; ABBREV[i]; i++) 02234 ABBREV[i] = toupper(ABBREV[i]); 02235 02236 char *name = (*(eit->find(NAME))).second.string; 02237 fprintf(plugin, "\tproto_%s = proto_register_protocol(\"%s\",\n" 02238 "\t \"%s\",\n" 02239 "\t \"%s\");\n\n", 02240 abbrev, name, ABBREV, abbrev); 02241 02242 fprintf(plugin, "/** Required function calls to register the header fields and subtrees used */\n"); 02243 fprintf(plugin, "\tproto_register_field_array(proto_%s, hf, array_length(hf));\n", abbrev); 02244 fprintf(plugin, "\tproto_register_subtree_array(ett, array_length(ett));\n}"); 02245 02247 writeRest(plugin, (*(eit->find(TRANSPORT))).second.string, (*(eit->find(PORT))).second.string, abbrev); 02248 fclose(plugin); 02249 02250 FILE *makefile = fopen("./plugin/Makefile.am", "w"); 02251 if (makefile) 02252 { 02253 fprintf(makefile, "INCLUDES = -I$(top_src_dir)\n\n"); 02254 02255 fprintf(makefile, "plugindir = @plugindir@\n\n"); 02256 02257 fprintf(makefile, "plugin_LTLIBRARIES = %s.la\n", abbrev); 02258 fprintf(makefile, "%s_la_SOURCES = packet-%s.c\n", abbrev, abbrev); 02259 fprintf(makefile, "%s_la_LDFLAGS = -module -avoid-version\n\n", abbrev); 02260 02261 fprintf(makefile, "LIB = \n\n"); 02262 02263 fprintf(makefile, "%s_la_DEPENDENCIES = packet-%s-static.o\n\n", abbrev, abbrev); 02264 02265 fprintf(makefile, "packet-%s-static.o: packet-%s.c\n", abbrev, abbrev); 02266 fprintf(makefile, "\t$(LTCOMPILE) -c -o packet-%s-static.o -D__ETHEREAL_STATIC__ $(srcdir)/packet-%s.c\n", 02267 abbrev, abbrev); 02268 02269 fprintf(makefile, "CLEANFILES = %s \n", abbrev); 02270 fprintf(makefile, "EXTRA_DIST = Makefile.nmake\n"); 02271 } 02272 else fprintf(stderr, "Unable to create Makfile.am!\n"); 02273 fclose(makefile); 02274 02275 makefile = fopen("./plugin/Makefile.nmake", "w"); 02276 if (makefile) 02277 { 02278 fprintf(makefile, "include ..\\..\\config.nmake\n\n"); 02279 02280 fprintf(makefile, "CFLAGS=/DHAVE_CONFIG_H /I../.. /I../../wiretap \\\n"); 02281 fprintf(makefile, "\t/I$(GLIB_DIR) /I$(GTK_DIR) /I$(GLIB_DIR)/gmodule \\\n"); 02282 fprintf(makefile, "/I$(PCAP_DIR)\\include $(LOCAL_CFLAGS)\n\n"); 02283 02284 fprintf(makefile, "OBJECTS=packet-%s.obj\n\n", abbrev); 02285 fprintf(makefile, "%s.dll %s.exp %s.lib : packet-%s.obj ..\\plugin_api.obj\n", 02286 abbrev, abbrev, abbrev, abbrev); 02287 fprintf(makefile, "\tlink -dll /out:%s.dll packet-%s.obj ..\\plugin_api.obj \\\n", 02288 abbrev, abbrev); 02289 fprintf(makefile, "$(GLIB_DIR)\\glib-$(GLIB_VERSION).lib\n\n"); 02290 fprintf(makefile, "clean:\n\trm -f $(OBJECTS) %s.dll %s.exp %s.lib\n", 02291 abbrev, abbrev, abbrev); 02292 } 02293 else fprintf(stderr, "Unable to create Makefile.nmake!\n"); 02294 fclose(makefile); 02295 } |
|
Definition at line 2022 of file protomakeParse.cpp. References generateEtherealPlugin(), root, Program::visit(), yyin, and yyparse().
02023 { 02024 extern FILE *yyin; 02025 02026 if (argc != 2) 02027 { 02028 fprintf(stderr, "Uso: protomake <arquivo-entrada>\n"); 02029 exit(1); 02030 } 02031 02032 if ((yyin = fopen(argv[1], "r")) == NULL) 02033 { 02034 fprintf(stderr, "Erro ao tentar abrir o arquivo %s!\n", argv[1]); 02035 exit(1); 02036 } 02037 02038 if (yyparse()) 02039 { 02040 fprintf(stderr, "Não foi possível compilar %s!\n", argv[1]); 02041 exit(1); 02042 } 02043 02044 TypeCheckerVisitor typeChecker; 02045 root->visit(typeChecker); 02046 02047 CCodeGeneratorVisitor ccodeGenerator; 02048 root->visit(ccodeGenerator); 02049 02050 JavaCodeGeneratorVisitor java("./code/teste.java"); 02051 root->visit(java); 02052 02053 fprintf(stderr, "Sintaxe de %s correta!\n", argv[1]); 02054 fclose(yyin); 02055 02056 if (etherInfo != NULL) 02057 { 02058 fprintf(stderr, "Gerando o plugin do ethereal para o protocolo...\n"); 02059 generateEtherealPlugin(&fiMap, etherInfo); 02060 fprintf(stderr, "Plugin gerado!\n"); 02061 } 02062 02063 return 0; 02064 } |
|
Really dissect the message now! :)_/ Definition at line 2382 of file protomakeParse.cpp. References FieldType::BIT, FieldType::BYTE, and IntegerLiteral::getValue(). Referenced by generateEtherealPlugin().
02384 { 02385 char *abbrev = (*(eit->find(ABBREV))).second.string; 02386 char *ABBREV = strdup(abbrev); 02387 unsigned i; 02388 02389 for (i = 0; ABBREV[i]; i++) 02390 ABBREV[i] = toupper(ABBREV[i]); 02391 02392 fprintf(plugin, "/** Dissector main code! */\n"); 02393 fprintf(plugin, "void dissect_%s(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)\n{\n", abbrev); 02394 02395 fprintf(plugin, "/** Set up structures needed to add the protocol subtree and manage it */\n"); 02396 fprintf(plugin, "\tproto_item *tree_item;\n\tproto_tree *%s_tree;\n\tguint16 code;\n", abbrev); 02397 02398 for (map<string, vector<FieldInfo> >::iterator itr = fiMap->begin(); 02399 itr != fiMap->end(); 02400 itr++) 02401 { 02402 fprintf(plugin, "\tstatic struct {\n"); 02403 for (i = 0; i < (*itr).second.size(); i++) 02404 { 02405 if (((*itr).second)[i].bitByte == FieldType::BIT) 02406 fprintf(plugin, "\t\tguint32 "); 02407 else 02408 fprintf(plugin, "\t\tguint8 *"); 02409 fprintf(plugin, "%s_%s;\n", abbrev, ((*itr).second)[i].identifier); 02410 } 02411 fprintf(plugin, "\t} msg_%s;\n\n", (*itr).first.c_str()); 02412 } 02413 02414 fprintf(plugin, "/** Make entries in Protocol column and Info column on summary display */\n"); 02415 fprintf(plugin, "\tif (check_col(pinfo->cinfo, COL_PROTOCOL))\n"); 02416 fprintf(plugin, "\t\tcol_set_str(pinfo->cinfo, COL_PROTOCOL, \"%s\");\n\n", ABBREV); 02417 02418 fprintf(plugin, "/** Verify the message sent and dissect it properly */\n"); 02419 fprintf(plugin, "\tif (tree) {\n"); 02420 fprintf(plugin, "\t\tcode = tvb_get_ntohs(tvb, 0);\n\n"); 02421 02422 fprintf(plugin, "\t\ttree_item = proto_tree_add_item(tree, proto_%s, tvb, 0, -1, FALSE);\n", abbrev); 02423 fprintf(plugin, "\t\t%s_tree = proto_item_add_subtree(tree_item, ett_%s);\n\n", abbrev, abbrev); 02424 02425 fprintf(plugin, "\t\tif ("); 02426 02427 for (map<string, vector<FieldInfo> >::iterator itr = fiMap->begin(); 02428 itr != fiMap->end(); 02429 itr++) 02430 { 02431 if (itr != fiMap->begin()) 02432 fprintf(plugin, "\t\telse if ("); 02433 vector <FieldInfo> temp = ((*itr).second); 02434 IntegerLiteral *msgCode = dynamic_cast<IntegerLiteral*> (temp[temp.size() - 1].init); 02435 fprintf(plugin, "code == %d)\n\t\t{\n", msgCode->getValue()); 02436 fprintf(plugin, "\t\t\tint offset = 2; //sizeof(code) == 2 since code is a guint16 :)\n\n"); 02437 02439 for (i = 0; i < (*itr).second.size() - 1; i++) 02440 { 02441 FieldInfo fi = (*itr).second[i]; 02442 02443 if (fi.bitByte == FieldType::BIT) 02444 { 02445 int value = (dynamic_cast<IntegerLiteral*> (fi.size))->getValue(); 02446 02447 if (value <= 8) 02448 { 02449 fprintf(plugin, "\t\t\tmsg_%s.%s_%s = tvb_get_guint8(tvb, offset);\n", 02450 (*itr).first.c_str(), abbrev, fi.identifier); 02451 fprintf(plugin, "\t\t\tproto_tree_add_item(%s_tree, hf_%s.%s_%s, tvb, offset, 1, FALSE);\n", 02452 abbrev, (*itr).first.c_str(), abbrev, fi.identifier); 02453 fprintf(plugin, "\t\t\toffset++;\n\n"); 02454 } 02455 else if (value <= 16) 02456 { 02457 fprintf(plugin, "\t\t\tmsg_%s.%s_%s = tvb_get_ntohs(tvb, offset);\n", 02458 (*itr).first.c_str(), abbrev, fi.identifier); 02459 fprintf(plugin, "\t\t\tproto_tree_add_item(%s_tree, hf_%s.%s_%s, tvb, offset, 2, FALSE);\n", 02460 abbrev, (*itr).first.c_str(), abbrev, fi.identifier); 02461 fprintf(plugin, "\t\t\toffset += 2;\n\n"); 02462 } 02463 else if (value <= 32 || value > 16) // This might be a problem for > 32 bits! 02464 { 02465 fprintf(plugin, "\t\t\tmsg_%s.%s_%s = tvb_get_ntohl(tvb, offset);\n", 02466 (*itr).first.c_str(), abbrev, fi.identifier); 02467 fprintf(plugin, "\t\t\tproto_tree_add_item(%s_tree, hf_%s.%s_%s, tvb, offset, 4, FALSE);\n", 02468 abbrev, (*itr).first.c_str(), abbrev, fi.identifier); 02469 fprintf(plugin, "\t\t\toffset += 4;\n\n"); 02470 } 02471 } 02472 else if (fi.bitByte == FieldType::BYTE && 02473 typeid(*(fi.size)) == typeid(IntegerLiteral)) 02474 { 02475 int value = (dynamic_cast<IntegerLiteral*> (fi.size))->getValue(); 02476 02477 fprintf(plugin, "\t\t\tmsg_%s.%s_%s = tvb_memdup(tvb, offset, %d);\n", 02478 (*itr).first.c_str(), abbrev, fi.identifier, value); 02479 fprintf(plugin, "\t\t\tproto_tree_add_string(%s_tree, hf_%s.%s_%s, tvb, offset, %d, msg_%s.%s_%s);\n", 02480 abbrev, (*itr).first.c_str(), abbrev, fi.identifier, value, (*itr).first.c_str(), abbrev, fi.identifier); 02481 fprintf(plugin, "\t\t\toffset += %d;\n\n", value); 02482 } 02483 else if (fi.bitByte == FieldType::BYTE && 02484 typeid(*(fi.size)) == typeid(Identifier)) 02485 { 02486 const char *name = (dynamic_cast<Identifier*>(fi.size))->getName().c_str(); 02487 02488 fprintf(plugin, "\t\t\tmsg_%s.%s_%s = tvb_memdup(tvb, offset, msg_%s.%s_%s);\n", 02489 (*itr).first.c_str(), abbrev, fi.identifier, (*itr).first.c_str(), 02490 abbrev, name); 02491 fprintf(plugin, "\t\t\tproto_tree_add_string(%s_tree, hf_%s.%s_%s, tvb, offset, msg_%s.%s_%s, msg_%s.%s_%s);\n", 02492 abbrev, (*itr).first.c_str(), abbrev, fi.identifier, (*itr).first.c_str(), abbrev, name, 02493 (*itr).first.c_str(), abbrev, fi.identifier); 02494 fprintf(plugin, "\t\t\toffset += msg_%s.%s_%s;\n\n", (*itr).first.c_str(), abbrev, name); 02495 } 02496 } 02497 02498 fprintf(plugin, "\t\t}\n"); 02499 } 02500 fprintf(plugin, "\t}\n"); 02501 fprintf(plugin, "}\n\n"); 02502 } |
|
Definition at line 2297 of file protomakeParse.cpp. References AUTHOR, EMAIL, and NAME. Referenced by generateEtherealPlugin().
02299 { 02300 int total; 02301 char *author, *email; 02302 char *name = ++((*(eit->find(NAME))).second.string); 02303 multimap<EtherType, EtherInfoType>::iterator itr; 02304 02305 name[strlen(name)-1] = '\0'; 02306 fprintf(plugin, "/* %s\n", &fileName[2]); 02307 fprintf(plugin, " * Routines for %s dissection\n", name); 02308 02309 fprintf(plugin, " * Copyright 2003"); 02310 for (total = eit->count(AUTHOR), itr = eit->find(AUTHOR); 02311 total > 0; 02312 itr++, total--) 02313 { 02314 author = ++((*itr).second.string); 02315 02316 author[strlen(author) - 1] = '\0'; 02317 fprintf(plugin, ", %s", author); 02318 } 02319 02320 fprintf(plugin, " <"); 02321 for (total = eit->count(EMAIL), itr = eit->find(EMAIL); 02322 total > 0; 02323 itr++, total--) 02324 { 02325 email = ++((*itr).second.string); 02326 02327 email[strlen(email) - 1] = '\0'; 02328 fprintf(plugin, "%s, ", email); 02329 } 02330 fprintf(plugin, ">\n"); 02331 02332 char *header = " * \n\ 02333 * Ethereal - Network traffic analyzer\n\ 02334 * By Gerald Combs <gerald@ethereal.com>\n\ 02335 * Copyright 1998 Gerald Combs\n\ 02336 * \n\ 02337 * Generated from ProtoMake by Igor Cananéa, Fábio Guerra, Rodrigo Araújo &\n\ 02338 * Thiago Souto Maior, Copyright 2003.\n\ 02339 *\n\ 02340 * This program is free software; you can redistribute it and/or\n\ 02341 * modify it under the terms of the GNU General Public License\n\ 02342 * as published by the Free Software Foundation; either version 2\n\ 02343 * of the License, or (at your option) any later version.\n\ 02344 *\n\ 02345 * This program is distributed in the hope that it will be useful,\n\ 02346 * but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ 02347 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ 02348 * GNU General Public License for more details.\n\ 02349 *\n\ 02350 * You should have received a copy of the GNU General Public License\n\ 02351 * along with this program; if not, write to the Free Software\n\ 02352 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n\ 02353 */\n\ 02354 \n\ 02355 #ifdef HAVE_CONFIG_H\n\ 02356 # include \"config.h\"\n\ 02357 #endif\n\ 02358 \n\ 02359 #include <stdio.h>\n\ 02360 #include <stdlib.h>\n\ 02361 #include <string.h>\n\ 02362 \n\ 02363 /* Includes glib.h! */\n\ 02364 #include <gmodule.h>\n\ 02365 \n\ 02366 #ifdef NEED_SNPRINTF_H\n\ 02367 # include \"snprintf.h\"\n\ 02368 #endif\n\ 02369 \n\ 02370 #include <epan/packet.h>\n\ 02371 #include \"plugins/plugin_api.h\"\n\ 02372 #include \"plugins/plugin_api_defs.h\"\n\ 02373 \n\ 02374 #ifndef __ETHEREAL_STATIC__\n\ 02375 G_MODULE_EXPORT const gchar version[] = \"1.0\";\n\ 02376 #endif\n\n"; 02377 02378 fprintf(plugin, "%s", header); 02379 } |
|
Definition at line 2505 of file protomakeParse.cpp. Referenced by generateEtherealPlugin().
02506 { 02507 char *rest = "\n\n/* If this dissector uses sub-dissector registration add a registration routine.\n\ 02508 This format is required because a script is used to find these routines and\n\ 02509 create the code that calls these routines.\n\ 02510 */\n"; 02511 02512 fprintf(plugin, "%s", rest); 02513 fprintf(plugin, "void proto_reg_handoff_%s(void)\n{\n", abbrev); 02514 fprintf(plugin, "\tdissector_handle_t %s_handle;\n\n", abbrev); 02515 02516 fprintf(plugin, "\t%s_handle = create_dissector_handle(dissect_%s,\n\t\tproto_%s);\n", abbrev, abbrev, abbrev); 02517 fprintf(plugin, " dissector_add(\"%s.port\", %s, %s_handle);\n", trans, port, abbrev); 02518 02519 rest = "}\n\ 02520 \n\ 02521 #ifndef __ETHEREAL_STATIC__\n\ 02522 G_MODULE_EXPORT void plugin_init(plugin_address_table_t *pat)\n\ 02523 {\n\ 02524 /* initialise the table of pointers needed in Win32 DLLs */\n\ 02525 plugin_address_table_init(pat);\n\ 02526 \n\ 02527 /* register the new protocol, protocol fields, and subtrees */\n"; 02528 fprintf(plugin, "%s", rest); 02529 fprintf(plugin, "\tif (proto_%s == -1) /* execute protocol initialization only once */\n", abbrev); 02530 fprintf(plugin, "\t\tproto_register_%s();\n}\n", abbrev); 02531 rest = "#endif\n\ 02532 \n\ 02533 #ifndef __ETHEREAL_STATIC__\n\ 02534 G_MODULE_EXPORT void plugin_reg_handoff(void)\n\ 02535 {\n\ 02536 proto_reg_handoff_"; 02537 fprintf(plugin, "%s%s();\n}\n#endif\n", rest, abbrev); 02538 } |
|
Definition at line 8646 of file protomake.y. Referenced by yyparse(). |
|
Forward defenition of yylex so the c++ compiler won't complain! :) |
|
O último SequentialImport só tem um SimpleImport Gera um SimpleImport Definition at line 889 of file protomakeParse.cpp. References Type::ADDRESS, Type::ARRAY, FieldType::BIT, FieldType::BLANKS, FieldType::BYTE, Type::CLIENTADDRESS, Ast::getPosition(), Identifier(), Type::INTEGER, lines, number, Program, Type::RANGE, root, Type::SERVERADDRESS, str, FieldType::STRCTE, FieldType::STRN, FieldType::STRTERM, YY_DECL_VARIABLES, YYABORT, YYACCEPT, yycheck, yydefact, yydefgoto, YYDPRINTF, YYEMPTY, YYEOF, yyerror(), YYFINAL, YYFLAG, YYINITDEPTH, YYLAST, YYLEX, YYLLOC_DEFAULT, YYMAXDEPTH, YYNTBASE, yypact, YYPARSE_PARAM_DECL, yypgoto, yyr1, yyr2, YYSIZE_T, YYSTACK_ALLOC, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, yytable, YYTERROR, and YYTRANSLATE. Referenced by main().
00891 { 00892 /* If reentrant, generate the variables here. */ 00893 #if YYPURE 00894 YY_DECL_VARIABLES 00895 #endif /* !YYPURE */ 00896 00897 register int yystate; 00898 register int yyn; 00899 int yyresult; 00900 /* Number of tokens to shift before error messages enabled. */ 00901 int yyerrstatus; 00902 /* Lookahead token as an internal (translated) token number. */ 00903 int yychar1 = 0; 00904 00905 /* Three stacks and their tools: 00906 `yyss': related to states, 00907 `yyvs': related to semantic values, 00908 `yyls': related to locations. 00909 00910 Refer to the stacks thru separate pointers, to allow yyoverflow 00911 to reallocate them elsewhere. */ 00912 00913 /* The state stack. */ 00914 short yyssa[YYINITDEPTH]; 00915 short *yyss = yyssa; 00916 register short *yyssp; 00917 00918 /* The semantic value stack. */ 00919 YYSTYPE yyvsa[YYINITDEPTH]; 00920 YYSTYPE *yyvs = yyvsa; 00921 register YYSTYPE *yyvsp; 00922 00923 #if YYLSP_NEEDED 00924 /* The location stack. */ 00925 YYLTYPE yylsa[YYINITDEPTH]; 00926 YYLTYPE *yyls = yylsa; 00927 YYLTYPE *yylsp; 00928 #endif 00929 00930 #if YYLSP_NEEDED 00931 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) 00932 #else 00933 # define YYPOPSTACK (yyvsp--, yyssp--) 00934 #endif 00935 00936 YYSIZE_T yystacksize = YYINITDEPTH; 00937 00938 00939 /* The variables used to return semantic value and location from the 00940 action routines. */ 00941 YYSTYPE yyval; 00942 #if YYLSP_NEEDED 00943 YYLTYPE yyloc; 00944 #endif 00945 00946 /* When reducing, the number of symbols on the RHS of the reduced 00947 rule. */ 00948 int yylen; 00949 00950 YYDPRINTF ((stderr, "Starting parse\n")); 00951 00952 yystate = 0; 00953 yyerrstatus = 0; 00954 yynerrs = 0; 00955 yychar = YYEMPTY; /* Cause a token to be read. */ 00956 00957 /* Initialize stack pointers. 00958 Waste one element of value and location stack 00959 so that they stay on the same level as the state stack. 00960 The wasted elements are never initialized. */ 00961 00962 yyssp = yyss; 00963 yyvsp = yyvs; 00964 #if YYLSP_NEEDED 00965 yylsp = yyls; 00966 #endif 00967 goto yysetstate; 00968 00969 /*------------------------------------------------------------. 00970 | yynewstate -- Push a new state, which is found in yystate. | 00971 `------------------------------------------------------------*/ 00972 yynewstate: 00973 /* In all cases, when you get here, the value and location stacks 00974 have just been pushed. so pushing a state here evens the stacks. 00975 */ 00976 yyssp++; 00977 00978 yysetstate: 00979 *yyssp = yystate; 00980 00981 if (yyssp >= yyss + yystacksize - 1) 00982 { 00983 /* Get the current used size of the three stacks, in elements. */ 00984 YYSIZE_T yysize = yyssp - yyss + 1; 00985 00986 #ifdef yyoverflow 00987 { 00988 /* Give user a chance to reallocate the stack. Use copies of 00989 these so that the &'s don't force the real ones into 00990 memory. */ 00991 YYSTYPE *yyvs1 = yyvs; 00992 short *yyss1 = yyss; 00993 00994 /* Each stack pointer address is followed by the size of the 00995 data in use in that stack, in bytes. */ 00996 # if YYLSP_NEEDED 00997 YYLTYPE *yyls1 = yyls; 00998 /* This used to be a conditional around just the two extra args, 00999 but that might be undefined if yyoverflow is a macro. */ 01000 yyoverflow ("parser stack overflow", 01001 &yyss1, yysize * sizeof (*yyssp), 01002 &yyvs1, yysize * sizeof (*yyvsp), 01003 &yyls1, yysize * sizeof (*yylsp), 01004 &yystacksize); 01005 yyls = yyls1; 01006 # else 01007 yyoverflow ("parser stack overflow", 01008 &yyss1, yysize * sizeof (*yyssp), 01009 &yyvs1, yysize * sizeof (*yyvsp), 01010 &yystacksize); 01011 # endif 01012 yyss = yyss1; 01013 yyvs = yyvs1; 01014 } 01015 #else /* no yyoverflow */ 01016 # ifndef YYSTACK_RELOCATE 01017 goto yyoverflowlab; 01018 # else 01019 /* Extend the stack our own way. */ 01020 if (yystacksize >= YYMAXDEPTH) 01021 goto yyoverflowlab; 01022 yystacksize *= 2; 01023 if (yystacksize > YYMAXDEPTH) 01024 yystacksize = YYMAXDEPTH; 01025 01026 { 01027 short *yyss1 = yyss; 01028 union yyalloc *yyptr = 01029 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 01030 if (! yyptr) 01031 goto yyoverflowlab; 01032 YYSTACK_RELOCATE (yyss); 01033 YYSTACK_RELOCATE (yyvs); 01034 # if YYLSP_NEEDED 01035 YYSTACK_RELOCATE (yyls); 01036 # endif 01037 # undef YYSTACK_RELOCATE 01038 if (yyss1 != yyssa) 01039 YYSTACK_FREE (yyss1); 01040 } 01041 # endif 01042 #endif /* no yyoverflow */ 01043 01044 yyssp = yyss + yysize - 1; 01045 yyvsp = yyvs + yysize - 1; 01046 #if YYLSP_NEEDED 01047 yylsp = yyls + yysize - 1; 01048 #endif 01049 01050 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 01051 (unsigned long int) yystacksize)); 01052 01053 if (yyssp >= yyss + yystacksize - 1) 01054 YYABORT; 01055 } 01056 01057 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 01058 01059 goto yybackup; 01060 01061 01062 /*-----------. 01063 | yybackup. | 01064 `-----------*/ 01065 yybackup: 01066 01067 /* Do appropriate processing given the current state. */ 01068 /* Read a lookahead token if we need one and don't already have one. */ 01069 /* yyresume: */ 01070 01071 /* First try to decide what to do without reference to lookahead token. */ 01072 01073 yyn = yypact[yystate]; 01074 if (yyn == YYFLAG) 01075 goto yydefault; 01076 01077 /* Not known => get a lookahead token if don't already have one. */ 01078 01079 /* yychar is either YYEMPTY or YYEOF 01080 or a valid token in external form. */ 01081 01082 if (yychar == YYEMPTY) 01083 { 01084 YYDPRINTF ((stderr, "Reading a token: ")); 01085 yychar = YYLEX; 01086 } 01087 01088 /* Convert token to internal form (in yychar1) for indexing tables with */ 01089 01090 if (yychar <= 0) /* This means end of input. */ 01091 { 01092 yychar1 = 0; 01093 yychar = YYEOF; /* Don't call YYLEX any more */ 01094 01095 YYDPRINTF ((stderr, "Now at end of input.\n")); 01096 } 01097 else 01098 { 01099 yychar1 = YYTRANSLATE (yychar); 01100 01101 #if YYDEBUG 01102 /* We have to keep this `#if YYDEBUG', since we use variables 01103 which are defined only if `YYDEBUG' is set. */ 01104 if (yydebug) 01105 { 01106 YYFPRINTF (stderr, "Next token is %d (%s", 01107 yychar, yytname[yychar1]); 01108 /* Give the individual parser a way to print the precise 01109 meaning of a token, for further debugging info. */ 01110 # ifdef YYPRINT 01111 YYPRINT (stderr, yychar, yylval); 01112 # endif 01113 YYFPRINTF (stderr, ")\n"); 01114 } 01115 #endif 01116 } 01117 01118 yyn += yychar1; 01119 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) 01120 goto yydefault; 01121 01122 yyn = yytable[yyn]; 01123 01124 /* yyn is what to do for this token type in this state. 01125 Negative => reduce, -yyn is rule number. 01126 Positive => shift, yyn is new state. 01127 New state is final state => don't bother to shift, 01128 just return success. 01129 0, or most negative number => error. */ 01130 01131 if (yyn < 0) 01132 { 01133 if (yyn == YYFLAG) 01134 goto yyerrlab; 01135 yyn = -yyn; 01136 goto yyreduce; 01137 } 01138 else if (yyn == 0) 01139 goto yyerrlab; 01140 01141 if (yyn == YYFINAL) 01142 YYACCEPT; 01143 01144 /* Shift the lookahead token. */ 01145 YYDPRINTF ((stderr, "Shifting token %d (%s), ", 01146 yychar, yytname[yychar1])); 01147 01148 /* Discard the token being shifted unless it is eof. */ 01149 if (yychar != YYEOF) 01150 yychar = YYEMPTY; 01151 01152 *++yyvsp = yylval; 01153 #if YYLSP_NEEDED 01154 *++yylsp = yylloc; 01155 #endif 01156 01157 /* Count tokens shifted since error; after three, turn off error 01158 status. */ 01159 if (yyerrstatus) 01160 yyerrstatus--; 01161 01162 yystate = yyn; 01163 goto yynewstate; 01164 01165 01166 /*-----------------------------------------------------------. 01167 | yydefault -- do the default action for the current state. | 01168 `-----------------------------------------------------------*/ 01169 yydefault: 01170 yyn = yydefact[yystate]; 01171 if (yyn == 0) 01172 goto yyerrlab; 01173 goto yyreduce; 01174 01175 01176 /*-----------------------------. 01177 | yyreduce -- Do a reduction. | 01178 `-----------------------------*/ 01179 yyreduce: 01180 /* yyn is the number of a rule to reduce with. */ 01181 yylen = yyr2[yyn]; 01182 01183 /* If YYLEN is nonzero, implement the default value of the action: 01184 `$$ = $1'. 01185 01186 Otherwise, the following line sets YYVAL to the semantic value of 01187 the lookahead token. This behavior is undocumented and Bison 01188 users should not rely upon it. Assigning to YYVAL 01189 unconditionally makes the parser a bit smaller, and it avoids a 01190 GCC warning that YYVAL may be used uninitialized. */ 01191 yyval = yyvsp[1-yylen]; 01192 01193 #if YYLSP_NEEDED 01194 /* Similarly for the default location. Let the user run additional 01195 commands if for instance locations are ranges. */ 01196 yyloc = yylsp[1-yylen]; 01197 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); 01198 #endif 01199 01200 #if YYDEBUG 01201 /* We have to keep this `#if YYDEBUG', since we use variables which 01202 are defined only if `YYDEBUG' is set. */ 01203 if (yydebug) 01204 { 01205 int yyi; 01206 01207 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", 01208 yyn, yyrline[yyn]); 01209 01210 /* Print the symbols being reduced, and their result. */ 01211 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) 01212 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); 01213 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); 01214 } 01215 #endif 01216 01217 switch (yyn) { 01218 01219 case 1: 01220 #line 223 "protomake.y" 01221 { 01222 root = new Program(new SrcPosition(1), yyvsp[-3].import, yyvsp[-2].behavior, yyvsp[-1].message, yyvsp[0].proc); 01223 ; 01224 break;} 01225 case 2: 01226 #line 230 "protomake.y" 01227 { yyval.import = yyvsp[0].import; ; 01228 break;} 01229 case 3: 01230 #line 231 "protomake.y" 01231 { yyval.import = NULL; ; 01232 break;} 01233 case 4: 01234 #line 236 "protomake.y" 01235 { 01237 yyval.import = yyvsp[0].simpImp; 01238 ; 01239 break;} 01240 case 5: 01241 #line 241 "protomake.y" 01242 { 01243 yyval.import = new SequentialImport(yyvsp[0].simpImp->getPosition(), yyvsp[-1].import, yyvsp[0].simpImp); 01244 ; 01245 break;} 01246 case 6: 01247 #line 248 "protomake.y" 01248 { 01250 SrcPosition *srcPos = new SrcPosition(lines); 01251 StringLiteral *str = new StringLiteral(srcPos, yyvsp[0].string); 01252 yyval.simpImp = new SimpleImport(srcPos, str); 01253 ; 01254 break;} 01255 case 7: 01256 #line 254 "protomake.y" 01257 { yyerror("Import sintax error!"); ; 01258 break;} 01259 case 8: 01260 #line 259 "protomake.y" 01261 { yyval.behavior = yyvsp[0].behavior; ; 01262 break;} 01263 case 9: 01264 #line 260 "protomake.y" 01265 { yyval.behavior = NULL; 01266 break;} 01267 case 10: 01268 #line 265 "protomake.y" 01269 { 01270 yyval.behavior = yyvsp[0].simpBhv; 01271 ; 01272 break;} 01273 case 11: 01274 #line 269 "protomake.y" 01275 { 01276 yyval.behavior = new SequentialBehavior(yyvsp[0].simpBhv->getPosition(), yyvsp[-1].behavior, yyvsp[0].simpBhv); 01277 ; 01278 break;} 01279 case 12: 01280 #line 276 "protomake.y" 01281 { 01282 yyval.simpBhv = new SimpleBehavior(yyvsp[0].idLst->getPosition(), yyvsp[0].idLst); 01283 ; 01284 break;} 01285 case 13: 01286 #line 283 "protomake.y" 01287 { yyval.message = yyvsp[0].simpMsg; ; 01288 break;} 01289 case 14: 01290 #line 284 "protomake.y" 01291 { yyval.message = new SequentialMessage(yyvsp[0].simpMsg->getPosition(), yyvsp[-1].message, yyvsp[0].simpMsg); ; 01292 break;} 01293 case 15: 01294 #line 290 "protomake.y" 01295 { 01296 yyval.simpMsg = new SimpleMessage(yyvsp[0].fieldDcl->getPosition(), new Identifier(yyvsp[0].fieldDcl->getPosition(), yyvsp[-6].string), 01297 yyvsp[0].fieldDcl, new Identifier(yyvsp[0].fieldDcl->getPosition(), yyvsp[-4].string), 01298 new Identifier(yyvsp[0].fieldDcl->getPosition(), yyvsp[-2].string), yyvsp[-8].number); 01299 ; 01300 break;} 01301 case 16: 01302 #line 296 "protomake.y" 01303 { 01304 yyval.simpMsg = new SimpleMessage(yyvsp[0].fieldDcl->getPosition(), new Identifier(yyvsp[0].fieldDcl->getPosition(), yyvsp[-1].string), 01305 yyvsp[0].fieldDcl, NULL, NULL, yyvsp[-3].number); 01306 ; 01307 break;} 01308 case 17: 01309 #line 304 "protomake.y" 01310 { yyval.number = 1; ; 01311 break;} 01312 case 18: 01313 #line 305 "protomake.y" 01314 { yyval.number = 0 ; 01315 break;} 01316 case 19: 01317 #line 310 "protomake.y" 01318 { yyval.fieldDcl = yyvsp[-1].fieldDcl; ; 01319 break;} 01320 case 20: 01321 #line 311 "protomake.y" 01322 { yyerror("Message body sintax error!"); ; 01323 break;} 01324 case 21: 01325 #line 316 "protomake.y" 01326 { yyval.fieldDcl = yyvsp[0].simpFld; ; 01327 break;} 01328 case 22: 01329 #line 317 "protomake.y" 01330 { yyval.fieldDcl = new SequentialFieldDeclaration(yyvsp[0].simpFld->getPosition(), yyvsp[-2].fieldDcl, yyvsp[0].simpFld); ; 01331 break;} 01332 case 23: 01333 #line 323 "protomake.y" 01334 { 01335 Identifier *id = new Identifier(yyvsp[-3].string->getPosition(), yyvsp[-3].string); 01336 yyval.simpFld = new SimpleFieldDeclaration(yyvsp[-3].string->getPosition(), id, yyvsp[-2].number, yyvsp[-1].fieldTyp, yyvsp[0].exp); 01337 ; 01338 break;} 01339 case 24: 01340 #line 329 "protomake.y" 01341 { 01342 // Falta terminar!!!!! 01343 yyval.simpFld = NULL 01344 ; 01345 break;} 01346 case 25: 01347 #line 333 "protomake.y" 01348 { yyerror("Field declaration sintax error!"); ; 01349 break;} 01350 case 26: 01351 #line 338 "protomake.y" 01352 { yyval.exp = yyvsp[0].exp; ; 01353 break;} 01354 case 27: 01355 #line 339 "protomake.y" 01356 { yyval.exp = NULL; ; 01357 break;} 01358 case 28: 01359 #line 345 "protomake.y" 01360 { 01361 yyval.fieldTyp = new FieldType(yyvsp[-1].exp->getPosition(), yyvsp[-1].exp, yyvsp[0].fType); 01362 ; 01363 break;} 01364 case 29: 01365 #line 350 "protomake.y" 01366 { 01367 // Falta terminar!!! 01368 yyval.fieldTyp = NULL; 01369 ; 01370 break;} 01371 case 30: 01372 #line 355 "protomake.y" 01373 { yyerror("Field type sintaxe error!"); ; 01374 break;} 01375 case 31: 01376 #line 360 "protomake.y" 01377 { yyval.fType = FieldType::BIT; ; 01378 break;} 01379 case 32: 01380 #line 361 "protomake.y" 01381 { yyval.fType = FieldType::BYTE; ; 01382 break;} 01383 case 33: 01384 #line 362 "protomake.y" 01385 { yyerror("Undefined field type!"); ; 01386 break;} 01387 case 34: 01388 #line 366 "protomake.y" 01389 { 01390 yyval.fTypeInfo.fType = FieldType::STRN; 01391 yyval.fTypeInfo.info.number = yyvsp[-1].number; 01392 ; 01393 break;} 01394 case 35: 01395 #line 372 "protomake.y" 01396 { 01397 yyval.fTypeInfo.fType = FieldType::STRCTE; 01398 yyval.fTypeInfo.info.cteStr = yyvsp[-1].string; 01399 ; 01400 break;} 01401 case 36: 01402 #line 377 "protomake.y" 01403 { 01404 yyval.fTypeInfo.fType = FieldType::STRTERM; 01405 yyval.fTypeInfo.info.terminator = yyvsp[-1].string; 01406 ; 01407 break;} 01408 case 37: 01409 #line 382 "protomake.y" 01410 { 01411 yyval.fTypeInfo.fType = FieldType::BLANKS; 01412 yyval.fTypeInfo.info.blanks = yyvsp[-1].string; 01413 ; 01414 break;} 01415 case 38: 01416 #line 387 "protomake.y" 01417 { yyerror("Undefined field type!"); ; 01418 break;} 01419 case 39: 01420 #line 393 "protomake.y" 01421 { 01422 yyval.proc = yyvsp[0].simpProc; 01423 ; 01424 break;} 01425 case 40: 01426 #line 397 "protomake.y" 01427 { 01428 yyval.proc = new SequentialProcess(yyvsp[0].simpProc->getPosition(), yyvsp[-1].proc, yyvsp[0].simpProc); 01429 ; 01430 break;} 01431 case 41: 01432 #line 404 "protomake.y" 01433 { 01434 // Falta ajeitar! 01435 yyval.simpProc = new SimpleProcess(yyvsp[-2].string->getPosition(), 01436 new Identifier(yyvsp[-2].string->getPosition(), yyvsp[-3].decl), yyvsp[-2].string, yyvsp[0].string, 0); 01437 ; 01438 break;} 01439 case 42: 01440 #line 409 "protomake.y" 01441 { yyerror("Process defenition sintax error!"); ; 01442 break;} 01443 case 43: 01444 #line 415 "protomake.y" 01445 { 01446 yyval.simpDecl = new SimpleDeclaration(new SrcPosition(lines), yyvsp[-3].idLst, yyvsp[-1].type, yyvsp[0].exp, true); 01447 ; 01448 break;} 01449 case 44: 01450 #line 419 "protomake.y" 01451 { 01452 yyval.simpDecl = new SimpleDeclaration(new SrcPosition(lines), yyvsp[-3].idLst, yyvsp[-1].type, yyvsp[0].exp, false, yyvsp[-5].number); 01453 ; 01454 break;} 01455 case 45: 01456 #line 423 "protomake.y" 01457 { yyval.simpDecl = NULL; ; 01458 break;} 01459 case 46: 01460 #line 424 "protomake.y" 01461 { yyerror("DeclarationType syntax error!"); ; 01462 break;} 01463 case 47: 01464 #line 427 "protomake.y" 01465 { yyval.number = 1;; 01466 break;} 01467 case 48: 01468 #line 428 "protomake.y" 01469 { yyval.number = 0;; 01470 break;} 01471 case 49: 01472 #line 434 "protomake.y" 01473 { 01474 yyval.decl = yyvsp[0].simpDecl; 01475 ; 01476 break;} 01477 case 50: 01478 #line 438 "protomake.y" 01479 { 01480 yyval.decl = new SequentialDeclaration(yyvsp[0].simpDecl->getPosition(), yyvsp[-2].decl, yyvsp[0].simpDecl); 01481 ; 01482 break;} 01483 case 51: 01484 #line 447 "protomake.y" 01485 { 01486 Identifier *identifier = new Identifier(new SrcPosition(lines), yyvsp[0].string); 01487 yyval.idLst = new SimpleIdentifierList(identifier->getPosition(), identifier); 01488 ; 01489 break;} 01490 case 52: 01491 #line 453 "protomake.y" 01492 { 01493 Identifier *identifier = new Identifier(new SrcPosition(lines), yyvsp[0].string); 01494 SimpleIdentifierList *simpIdList = new SimpleIdentifierList(identifier->getPosition(), identifier); 01495 yyval.idLst = new SequentialIdentifierList(identifier->getPosition(), yyvsp[-2].idLst, simpIdList); 01496 ; 01497 break;} 01498 case 53: 01499 #line 459 "protomake.y" 01500 { yyerror("Identifier list sintax error!"); ; 01501 break;} 01502 case 54: 01503 #line 464 "protomake.y" 01504 {yyval.type = new Type(new SrcPosition(lines), Type::INTEGER);; 01505 break;} 01506 case 55: 01507 #line 465 "protomake.y" 01508 { yyval.type = new RangeType(new SrcPosition(lines), Type::RANGE, yyvsp[-2].number, yyvsp[0].number); ; 01509 break;} 01510 case 56: 01511 #line 466 "protomake.y" 01512 { yyval.type = new Type(new SrcPosition(lines), Type::ADDRESS); ; 01513 break;} 01514 case 57: 01515 #line 467 "protomake.y" 01516 { yyval.type = new Type(new SrcPostion(lines), Type::CLIENTADDRESS); ; 01517 break;} 01518 case 58: 01519 #line 468 "protomake.y" 01520 { yyval.type = new Type(new SrcPostion(lines), Type::SERVERADDRESS); ; 01521 break;} 01522 case 59: 01523 #line 469 "protomake.y" 01524 {yyval.type = new ArrayType(new SrcPosition(lines), Type::ARRAY, yyvsp[0].type, yyvsp[-3].number);; 01525 break;} 01526 case 60: 01527 #line 470 "protomake.y" 01528 {yyerror("Undefined type!");; 01529 break;} 01530 case 61: 01531 #line 475 "protomake.y" 01532 {yyval.action = yyvsp[0].simpAct;; 01533 break;} 01534 case 62: 01535 #line 476 "protomake.y" 01536 {yyval.action = new SequentialAction(yyvsp[0].simpAct->getPosition(), yyvsp[-2].action, yyvsp[0].simpAct);; 01537 break;} 01538 case 63: 01539 #line 484 "protomake.y" 01540 {yyval.simpAct = new SimpleAction(yyvsp[-2].guard->getPosition(), yyvsp[-2].guard, yyvsp[0].stmt);; 01541 break;} 01542 case 64: 01543 #line 485 "protomake.y" 01544 {yyerror("Action syntax error!");; 01545 break;} 01546 case 65: 01547 #line 490 "protomake.y" 01548 { yyval.guard = new GuardExpression(yyvsp[0].exp->getPosition(), yyvsp[0].exp); ; 01549 break;} 01550 case 66: 01551 #line 492 "protomake.y" 01552 { 01553 // Falta ajeitar!! 01554 SrcPosition *pos = new SrcPosition(lines); 01555 01556 ReceiveStatement *rs = new ReceiveStatement(pos, new Identifier(pos, yyvsp[-2].string), 01557 new Identifier(pos, yyvsp[0].string), NULL); 01558 yyval.guard = new GuardReceive(pos, rs); 01559 ; 01560 break;} 01561 case 67: 01562 #line 501 "protomake.y" 01563 { 01564 SrcPosition *pos = new SrcPosition(lines); 01565 01566 yyval.guard = new GuardTimeout(pos, new Identifier(pos, yyvsp[0].string)); 01567 ; 01568 break;} 01569 case 68: 01570 #line 506 "protomake.y" 01571 { yyerror("Invalid guard!"); ; 01572 break;} 01573 case 69: 01574 #line 511 "protomake.y" 01575 { yyval.exp = yyvsp[-1].exp; ; 01576 break;} 01577 case 70: 01578 #line 514 "protomake.y" 01579 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01580 break;} 01581 case 71: 01582 #line 517 "protomake.y" 01583 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01584 break;} 01585 case 72: 01586 #line 520 "protomake.y" 01587 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01588 break;} 01589 case 73: 01590 #line 523 "protomake.y" 01591 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01592 break;} 01593 case 74: 01594 #line 526 "protomake.y" 01595 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01596 break;} 01597 case 75: 01598 #line 529 "protomake.y" 01599 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01600 break;} 01601 case 76: 01602 #line 532 "protomake.y" 01603 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01604 break;} 01605 case 77: 01606 #line 535 "protomake.y" 01607 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01608 break;} 01609 case 78: 01610 #line 538 "protomake.y" 01611 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01612 break;} 01613 case 79: 01614 #line 541 "protomake.y" 01615 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01616 break;} 01617 case 80: 01618 #line 544 "protomake.y" 01619 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01620 break;} 01621 case 81: 01622 #line 547 "protomake.y" 01623 { yyval.exp = new BinaryExpression(new SrcPosition(lines), yyvsp[-2].exp, yyvsp[0].exp, yyvsp[-1].string); ; 01624 break;} 01625 case 82: 01626 #line 549 "protomake.y" 01627 { yyval.exp = new UnaryExpression(new SrcPosition(lines), yyvsp[0].exp, yyvsp[-1].string); ; 01628 break;} 01629 case 83: 01630 #line 551 "protomake.y" 01631 { yyval.exp = new UnaryExpression(new SrcPosition(lines), yyvsp[0].exp, yyvsp[-1].string); ; 01632 break;} 01633 case 84: 01634 #line 553 "protomake.y" 01635 { yyval.exp = yyvsp[0].fieldRef; ; 01636 break;} 01637 case 85: 01638 #line 554 "protomake.y" 01639 { yyval.exp = yyvsp[0].arrayRef; ; 01640 break;} 01641 case 86: 01642 #line 555 "protomake.y" 01643 { yyval.exp = new Identifier(new SrcPosition(lines), yyvsp[0].string); ; 01644 break;} 01645 case 87: 01646 #line 556 "protomake.y" 01647 { yyval.exp = new IntegerLiteral(new SrcPosition(lines), yyvsp[0].number); ; 01648 break;} 01649 case 88: 01650 #line 557 "protomake.y" 01651 { yyval.exp = new StringLiteral(new SrcPosition(lines), yyvsp[0].string); ; 01652 break;} 01653 case 89: 01654 #line 563 "protomake.y" 01655 { 01656 SrcPosition *pos = new SrcPosition(lines); 01657 yyval.fieldRef = new FieldReference(pos, new Identifier(pos, yyvsp[-2].string), new Identifier(pos, yyvsp[0].string)); 01658 ; 01659 break;} 01660 case 90: 01661 #line 571 "protomake.y" 01662 { yyval.arrayRef = new SimpleArrayReference(yyvsp[0].exp->getPosition(), new Identifier(yyvsp[0].exp->getPosition(), yyvsp[-1].string), yyvsp[0].exp); ; 01663 break;} 01664 case 91: 01665 #line 572 "protomake.y" 01666 {yyval.arrayRef = new MultipleArrayReference(yyvsp[-1].arrayRef->getPosition(), yyvsp[-1].arrayRef, yyvsp[0].exp);; 01667 break;} 01668 case 92: 01669 #line 577 "protomake.y" 01670 { yyval.exp = yyvsp[-1].exp; ; 01671 break;} 01672 case 93: 01673 #line 582 "protomake.y" 01674 {yyval.stmt = yyvsp[0].simpStmt;; 01675 break;} 01676 case 94: 01677 #line 583 "protomake.y" 01678 {yyval.stmt = new SequentialStatement(yyvsp[0].simpStmt->getPosition(), yyvsp[-2].stmt, yyvsp[0].simpStmt);; 01679 break;} 01680 case 95: 01681 #line 588 "protomake.y" 01682 {yyval.simpStmt = new SkipStatement(new SrcPosition(lines));; 01683 break;} 01684 case 96: 01685 #line 589 "protomake.y" 01686 {yyval.simpStmt = new AssignStatement(yyvsp[-2].leftSideLst->getPosition(), yyvsp[-2].leftSideLst, yyvsp[0].expLst);; 01687 break;} 01688 case 97: 01689 #line 591 "protomake.y" 01690 { 01691 // Falta ajeitar!! 01692 SrcPosition *pos = new SrcPosition(lines); 01693 yyval.simpStmt = new ReceiveStatement(pos, new Identifier(pos, yyvsp[-2].string), new Identifier(pos, yyvsp[0].string), NULL); 01694 ; 01695 break;} 01696 case 98: 01697 #line 597 "protomake.y" 01698 { 01699 // Falta Ajeitar 01700 SrcPosition *pos = new SrcPosition(lines); 01701 yyval.simpStmt = new SendStatement(pos, new Identifier(pos, yyvsp[-2].string), new Identifier(pos, yyvsp[0].string), NULL); 01702 ; 01703 break;} 01704 case 99: 01705 #line 602 "protomake.y" 01706 { yyval.simpStmt = new IfStatement(yyvsp[-1].guardStmt->getPosition(), yyvsp[-1].guardStmt); ; 01707 break;} 01708 case 100: 01709 #line 603 "protomake.y" 01710 { yyval.simpStmt = new DoStatement(yyvsp[-1].simpGuardStmt->getPosition(), yyvsp[-1].simpGuardStmt); ; 01711 break;} 01712 case 101: 01713 #line 604 "protomake.y" 01714 { yyval.simpStmt = new ActStatement(yyvsp[0].exp->getPosition(), new Identifier(yyvsp[0].exp->getPosition(), yyvsp[-2].string) ,yyvsp[0].exp); ; 01715 break;} 01716 case 102: 01717 #line 606 "protomake.y" 01718 { 01719 SrcPosition *pos = new SrcPosition(lines); 01720 yyval.simpStmt = new StartStatement(pos, new Identifier(pos, yyvsp[0].string)); 01721 ; 01722 break;} 01723 case 103: 01724 #line 610 "protomake.y" 01725 { yyval.simpStmt = new StopStatement(new SrcPosition(lines)); ; 01726 break;} 01727 case 104: 01728 #line 613 "protomake.y" 01729 { 01730 yyval.simpStmt = new BehaviorStatement(yyvsp[-1].expLst->getPosition(), 01731 new Identifier(yyvsp[-1].expLst->getPosition(), yyvsp[-5].string), 01732 new Identifier(yyvsp[-1].expLst->getPosition(), yyvsp[-3].string), 01733 yyvsp[-1].expLst); 01734 ; 01735 break;} 01736 case 105: 01737 #line 623 "protomake.y" 01738 { yyval.leftSideLst = new SimpleLeftSideList(yyvsp[0].leftSide->getPosition(), yyvsp[0].leftSide); ; 01739 break;} 01740 case 106: 01741 #line 625 "protomake.y" 01742 { 01743 yyval.leftSideLst = new SequentialLeftSideList(yyvsp[0].leftSide->getPosition(), yyvsp[-2].leftSideLst, 01744 new SimpleLeftSideList(yyvsp[0].leftSide->getPosition(), yyvsp[0].leftSide)); 01745 ; 01746 break;} 01747 case 107: 01748 #line 633 "protomake.y" 01749 { yyval.leftSide = new Identifier(new SrcPosition(lines), yyvsp[0].string); ; 01750 break;} 01751 case 108: 01752 #line 634 "protomake.y" 01753 { yyval.leftSide = yyvsp[0].fieldRef; ; 01754 break;} 01755 case 109: 01756 #line 635 "protomake.y" 01757 { yyval.leftSide = yyvsp[0].arrayRef; ; 01758 break;} 01759 case 110: 01760 #line 640 "protomake.y" 01761 { yyval.expLst = new SimpleExpressionList(yyvsp[0].exp->getPosition(), yyvsp[0].exp); ; 01762 break;} 01763 case 111: 01764 #line 642 "protomake.y" 01765 { 01766 yyval.expLst = new SequentialExpressionList(yyvsp[-2].expLst->getPosition(), yyvsp[-2].expLst, 01767 new SimpleExpressionList(yyvsp[-2].expLst->getPosition(), yyvsp[0].exp)); 01768 ; 01769 break;} 01770 case 112: 01771 #line 650 "protomake.y" 01772 { yyval.guardStmt = yyvsp[0].simpGuardStmt; ; 01773 break;} 01774 case 113: 01775 #line 652 "protomake.y" 01776 { 01777 yyval.guardStmt = new SequentialGuardedStatement(yyvsp[-2].guardStmt->getPosition(), yyvsp[-2].guardStmt, yyvsp[0].simpGuardStmt); 01778 ; 01779 break;} 01780 case 114: 01781 #line 660 "protomake.y" 01782 { 01783 yyval.simpGuardStmt = new SimpleGuardedStatement(yyvsp[-2].exp->getPosition(), yyvsp[-2].exp, yyvsp[0].stmt); 01784 ; 01785 break;} 01786 } 01787 01788 #line 704 "/usr/share/bison/bison.simple" 01789 01790 01791 yyvsp -= yylen; 01792 yyssp -= yylen; 01793 #if YYLSP_NEEDED 01794 yylsp -= yylen; 01795 #endif 01796 01797 #if YYDEBUG 01798 if (yydebug) 01799 { 01800 short *yyssp1 = yyss - 1; 01801 YYFPRINTF (stderr, "state stack now"); 01802 while (yyssp1 != yyssp) 01803 YYFPRINTF (stderr, " %d", *++yyssp1); 01804 YYFPRINTF (stderr, "\n"); 01805 } 01806 #endif 01807 01808 *++yyvsp = yyval; 01809 #if YYLSP_NEEDED 01810 *++yylsp = yyloc; 01811 #endif 01812 01813 /* Now `shift' the result of the reduction. Determine what state 01814 that goes to, based on the state we popped back to and the rule 01815 number reduced by. */ 01816 01817 yyn = yyr1[yyn]; 01818 01819 yystate = yypgoto[yyn - YYNTBASE] + *yyssp; 01820 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) 01821 yystate = yytable[yystate]; 01822 else 01823 yystate = yydefgoto[yyn - YYNTBASE]; 01824 01825 goto yynewstate; 01826 01827 01828 /*------------------------------------. 01829 | yyerrlab -- here on detecting error | 01830 `------------------------------------*/ 01831 yyerrlab: 01832 /* If not already recovering from an error, report this error. */ 01833 if (!yyerrstatus) 01834 { 01835 ++yynerrs; 01836 01837 #ifdef YYERROR_VERBOSE 01838 yyn = yypact[yystate]; 01839 01840 if (yyn > YYFLAG && yyn < YYLAST) 01841 { 01842 YYSIZE_T yysize = 0; 01843 char *yymsg; 01844 int yyx, yycount; 01845 01846 yycount = 0; 01847 /* Start YYX at -YYN if negative to avoid negative indexes in 01848 YYCHECK. */ 01849 for (yyx = yyn < 0 ? -yyn : 0; 01850 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) 01851 if (yycheck[yyx + yyn] == yyx) 01852 yysize += yystrlen (yytname[yyx]) + 15, yycount++; 01853 yysize += yystrlen ("parse error, unexpected ") + 1; 01854 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); 01855 yymsg = (char *) YYSTACK_ALLOC (yysize); 01856 if (yymsg != 0) 01857 { 01858 char *yyp = yystpcpy (yymsg, "parse error, unexpected "); 01859 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); 01860 01861 if (yycount < 5) 01862 { 01863 yycount = 0; 01864 for (yyx = yyn < 0 ? -yyn : 0; 01865 yyx < (int) (sizeof (yytname) / sizeof (char *)); 01866 yyx++) 01867 if (yycheck[yyx + yyn] == yyx) 01868 { 01869 const char *yyq = ! yycount ? ", expecting " : " or "; 01870 yyp = yystpcpy (yyp, yyq); 01871 yyp = yystpcpy (yyp, yytname[yyx]); 01872 yycount++; 01873 } 01874 } 01875 yyerror (yymsg); 01876 YYSTACK_FREE (yymsg); 01877 } 01878 else 01879 yyerror ("parse error; also virtual memory exhausted"); 01880 } 01881 else 01882 #endif /* defined (YYERROR_VERBOSE) */ 01883 yyerror ("parse error"); 01884 } 01885 goto yyerrlab1; 01886 01887 01888 /*--------------------------------------------------. 01889 | yyerrlab1 -- error raised explicitly by an action | 01890 `--------------------------------------------------*/ 01891 yyerrlab1: 01892 if (yyerrstatus == 3) 01893 { 01894 /* If just tried and failed to reuse lookahead token after an 01895 error, discard it. */ 01896 01897 /* return failure if at end of input */ 01898 if (yychar == YYEOF) 01899 YYABORT; 01900 YYDPRINTF ((stderr, "Discarding token %d (%s).\n", 01901 yychar, yytname[yychar1])); 01902 yychar = YYEMPTY; 01903 } 01904 01905 /* Else will try to reuse lookahead token after shifting the error 01906 token. */ 01907 01908 yyerrstatus = 3; /* Each real token shifted decrements this */ 01909 01910 goto yyerrhandle; 01911 01912 01913 /*-------------------------------------------------------------------. 01914 | yyerrdefault -- current state does not do anything special for the | 01915 | error token. | 01916 `-------------------------------------------------------------------*/ 01917 yyerrdefault: 01918 #if 0 01919 /* This is wrong; only states that explicitly want error tokens 01920 should shift them. */ 01921 01922 /* If its default is to accept any token, ok. Otherwise pop it. */ 01923 yyn = yydefact[yystate]; 01924 if (yyn) 01925 goto yydefault; 01926 #endif 01927 01928 01929 /*---------------------------------------------------------------. 01930 | yyerrpop -- pop the current state because it cannot handle the | 01931 | error token | 01932 `---------------------------------------------------------------*/ 01933 yyerrpop: 01934 if (yyssp == yyss) 01935 YYABORT; 01936 yyvsp--; 01937 yystate = *--yyssp; 01938 #if YYLSP_NEEDED 01939 yylsp--; 01940 #endif 01941 01942 #if YYDEBUG 01943 if (yydebug) 01944 { 01945 short *yyssp1 = yyss - 1; 01946 YYFPRINTF (stderr, "Error: state stack now"); 01947 while (yyssp1 != yyssp) 01948 YYFPRINTF (stderr, " %d", *++yyssp1); 01949 YYFPRINTF (stderr, "\n"); 01950 } 01951 #endif 01952 01953 /*--------------. 01954 | yyerrhandle. | 01955 `--------------*/ 01956 yyerrhandle: 01957 yyn = yypact[yystate]; 01958 if (yyn == YYFLAG) 01959 goto yyerrdefault; 01960 01961 yyn += YYTERROR; 01962 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) 01963 goto yyerrdefault; 01964 01965 yyn = yytable[yyn]; 01966 if (yyn < 0) 01967 { 01968 if (yyn == YYFLAG) 01969 goto yyerrpop; 01970 yyn = -yyn; 01971 goto yyreduce; 01972 } 01973 else if (yyn == 0) 01974 goto yyerrpop; 01975 01976 if (yyn == YYFINAL) 01977 YYACCEPT; 01978 01979 YYDPRINTF ((stderr, "Shifting error token, ")); 01980 01981 *++yyvsp = yylval; 01982 #if YYLSP_NEEDED 01983 *++yylsp = yylloc; 01984 #endif 01985 01986 yystate = yyn; 01987 goto yynewstate; 01988 01989 01990 /*-------------------------------------. 01991 | yyacceptlab -- YYACCEPT comes here. | 01992 `-------------------------------------*/ 01993 yyacceptlab: 01994 yyresult = 0; 01995 goto yyreturn; 01996 01997 /*-----------------------------------. 01998 | yyabortlab -- YYABORT comes here. | 01999 `-----------------------------------*/ 02000 yyabortlab: 02001 yyresult = 1; 02002 goto yyreturn; 02003 02004 /*---------------------------------------------. 02005 | yyoverflowab -- parser overflow comes here. | 02006 `---------------------------------------------*/ 02007 yyoverflowlab: 02008 yyerror ("parser stack overflow"); 02009 yyresult = 2; 02010 /* Fall through. */ 02011 02012 yyreturn: 02013 #ifndef yyoverflow 02014 if (yyss != yyssa) 02015 YYSTACK_FREE (yyss); 02016 #endif 02017 return yyresult; 02018 } |
|
Global variable that counts the number of lines read Definition at line 99 of file protomakeParse.cpp. |
|
Global varible that will hold the abstract syntax tree. Definition at line 104 of file protomakeParse.cpp. |
|
Definition at line 478 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Initial value: { 0, 7, 0, 9, 0, 4, 6, 0, 18, 8, 10, 5, 53, 51, 12, 17, 0, 13, 0, 11, 0, 42, 0, 14, 0, 39, 0, 52, 0, 40, 0, 46, 47, 0, 49, 0, 0, 20, 0, 0, 16, 0, 0, 0, 0, 25, 0, 0, 21, 0, 0, 0, 64, 86, 88, 87, 0, 0, 0, 0, 0, 0, 61, 0, 65, 84, 85, 50, 0, 0, 19, 0, 0, 60, 0, 54, 56, 57, 58, 0, 27, 0, 0, 0, 90, 0, 67, 83, 82, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 0, 30, 0, 0, 27, 29, 0, 22, 0, 0, 0, 0, 43, 27, 0, 89, 0, 69, 62, 107, 0, 95, 0, 0, 0, 0, 0, 103, 108, 109, 63, 93, 0, 105, 78, 79, 80, 81, 77, 76, 75, 74, 73, 70, 72, 71, 0, 0, 0, 23, 33, 31, 32, 28, 0, 55, 0, 26, 44, 92, 66, 0, 0, 0, 0, 0, 112, 0, 0, 102, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 89, 0, 0, 0, 99, 0, 100, 0, 94, 107, 106, 110, 96, 0, 35, 36, 34, 37, 0, 0, 97, 98, 114, 113, 101, 0, 0, 59, 0, 111, 0, 104, 0, 0, 24, 0, 0, 0 } Definition at line 368 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Initial value: { 221, 3, 4, 5, 8, 9, 10, 16, 17, 18, 40, 47, 48, 118, 110, 159, 111, 24, 25, 34, 35, 36, 14, 80, 61, 62, 63, 170, 65, 66, 84, 136, 137, 138, 139, 198, 171, 172 } Definition at line 395 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Initial value: { 109,-32768, 20, 44, 113,-32768,-32768, 69, 73, 44, -32768,-32768,-32768,-32768, -46,-32768, 83,-32768, 77,-32768, 86,-32768, 90,-32768, 12,-32768, 93,-32768, 22,-32768, 7,-32768,-32768, 69,-32768, 85, 10,-32768, 74, 99, -32768, 6, 69, 75, 22,-32768, -9, 8,-32768, 56, 133, 71, 81, -31,-32768,-32768, 139, 141, 104, 104, 104, -6,-32768, 82, 200,-32768, 94,-32768, 95, 91, -32768, 74, 144,-32768, 98,-32768,-32768,-32768,-32768, 108, 118, 133, 104, 165,-32768, 148,-32768,-32768, 124, 166, -32768, 75, 1, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,-32768, 168,-32768, 149, 163, 118,-32768, 138,-32768, 140, 196, 212, 104,-32768, 118, 184,-32768, 216,-32768,-32768, -16, 217,-32768, 225, 104, 104, 232, 233,-32768,-32768, 94, 186,-32768, 14,-32768, 96, 96,-32768,-32768, 213, 213, 226, 226, 226, 226, 226, 226, 203, 120, 263,-32768,-32768,-32768,-32768,-32768, 13,-32768, 224, 200,-32768,-32768,-32768, 266, 243, 247, 151, -25,-32768, 244, 245,-32768, 1, 277, 104, 276, 228, 229, 230, 231,-32768, 262, 234, 286, 287, 1, -32768, 104,-32768, 104,-32768, -31,-32768, 200, 235, 237, -32768,-32768,-32768,-32768, 133, 104,-32768,-32768, 186,-32768, 200, 104, 236,-32768, 76, 200, 239,-32768, 289, 240, -32768, 297, 298,-32768 } Definition at line 403 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Initial value: { -32768,-32768,-32768, 295,-32768,-32768, 291,-32768, 285,-32768, 143,-32768, 238, -100,-32768,-32768,-32768,-32768, 280, 261, -32768,-32768, 2, -80,-32768, 215,-32768, -43, -90, -88, -63, 119, 131,-32768, 134, 105,-32768, -123 } Definition at line 430 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Initial value: { 0, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 80, 81, 81, 82, 82, 82, 83, 83, 83, 84, 84, 84, 84, 84, 85, 85, 86, 86, 87, 87, 87, 87, 88, 88, 89, 89, 90, 90, 90, 91, 91, 91, 91, 91, 91, 91, 92, 92, 93, 93, 94, 94, 94, 94, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 96, 97, 97, 98, 99, 99, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 101, 101, 102, 102, 102, 103, 103, 104, 104, 105 } Definition at line 332 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Initial value: { 0, 4, 1, 0, 1, 2, 2, 1, 1, 0, 1, 2, 2, 1, 2, 9, 4, 1, 0, 3, 1, 1, 3, 4, 11, 1, 2, 0, 2, 1, 1, 1, 1, 1, 4, 4, 4, 4, 1, 1, 2, 6, 1, 5, 6, 0, 1, 1, 0, 1, 3, 1, 3, 1, 1, 3, 1, 1, 1, 6, 1, 1, 3, 3, 1, 1, 4, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 1, 1, 1, 1, 1, 3, 2, 2, 3, 1, 3, 1, 3, 4, 4, 3, 3, 4, 2, 1, 6, 1, 3, 1, 1, 1, 1, 3, 1, 3, 3 } Definition at line 349 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 442 of file protomakeParse.cpp. Referenced by yyparse(). |
|
Definition at line 188 of file protomakeParse.cpp. |