#include <vector>#include <stdio.h>#include <stdlib.h>#include "bif_arg.h"Include dependency graph for bif_parse.cc:

Go to the source code of this file.
Classes | |
| union | yyalloc |
| union | YYSTYPE |
Defines | |
| #define | YYBISON 1 |
| #define | YYSKELETON_NAME "yacc.c" |
| #define | YYPURE 0 |
| #define | YYLSP_NEEDED 0 |
| #define | TOK_LPP 258 |
| #define | TOK_RPP 259 |
| #define | TOK_LPB 260 |
| #define | TOK_RPB 261 |
| #define | TOK_LPPB 262 |
| #define | TOK_RPPB 263 |
| #define | TOK_VAR_ARG 264 |
| #define | TOK_BOOL 265 |
| #define | TOK_FUNCTION 266 |
| #define | TOK_REWRITER 267 |
| #define | TOK_EVENT 268 |
| #define | TOK_CONST 269 |
| #define | TOK_ENUM 270 |
| #define | TOK_WRITE 271 |
| #define | TOK_PUSH 272 |
| #define | TOK_EOF 273 |
| #define | TOK_TRACE 274 |
| #define | TOK_ARGS 275 |
| #define | TOK_ARG 276 |
| #define | TOK_ARGC 277 |
| #define | TOK_ID 278 |
| #define | TOK_ATTR 279 |
| #define | TOK_CSTR 280 |
| #define | TOK_LF 281 |
| #define | TOK_WS 282 |
| #define | TOK_COMMENT 283 |
| #define | TOK_ATOM 284 |
| #define | TOK_C_TOKEN 285 |
| #define | print_line_directive(fp) fprintf(fp, "\n#line %d \"%s\"\n", line_number, input_filename) |
| #define | YYDEBUG 1 |
| #define | YYERROR_VERBOSE 0 |
| #define | yystype YYSTYPE |
| #define | YYSTYPE_IS_DECLARED 1 |
| #define | YYSTYPE_IS_TRIVIAL 1 |
| #define | YYSTACK_ALLOC malloc |
| #define | YYSTACK_FREE free |
| #define | YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) |
| #define | YYSTACK_BYTES(N) |
| #define | YYCOPY(To, From, Count) |
| #define | YYSTACK_RELOCATE(Stack) |
| #define | YYFINAL 3 |
| #define | YYLAST 140 |
| #define | YYNTOKENS 35 |
| #define | YYNNTS 35 |
| #define | YYNRULES 60 |
| #define | YYNSTATES 115 |
| #define | YYUNDEFTOK 2 |
| #define | YYMAXUTOK 285 |
| #define | YYTRANSLATE(YYX) ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) |
| #define | YYPACT_NINF -47 |
| #define | YYTABLE_NINF -1 |
| #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 yyerrorlab |
| #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 | YYFPRINTF fprintf |
| #define | YYDPRINTF(Args) |
| #define | YYDSYMPRINT(Args) |
| #define | YYDSYMPRINTF(Title, Token, Value, Location) |
| #define | YY_STACK_PRINT(Bottom, Top) |
| #define | YY_REDUCE_PRINT(Rule) |
| #define | YYINITDEPTH 200 |
| #define | YYMAXDEPTH 10000 |
| #define | YYPOPSTACK (yyvsp--, yyssp--) |
Typedefs | |
| typedef YYSTYPE | YYSTYPE |
| typedef short | yysigned_char |
Enumerations | |
| enum | yytokentype { TOK_LPP = 258, TOK_RPP = 259, TOK_LPB = 260, TOK_RPB = 261, TOK_LPPB = 262, TOK_RPPB = 263, TOK_VAR_ARG = 264, TOK_BOOL = 265, TOK_FUNCTION = 266, TOK_REWRITER = 267, TOK_EVENT = 268, TOK_CONST = 269, TOK_ENUM = 270, TOK_WRITE = 271, TOK_PUSH = 272, TOK_EOF = 273, TOK_TRACE = 274, TOK_ARGS = 275, TOK_ARG = 276, TOK_ARGC = 277, TOK_ID = 278, TOK_ATTR = 279, TOK_CSTR = 280, TOK_LF = 281, TOK_WS = 282, TOK_COMMENT = 283, TOK_ATOM = 284, TOK_C_TOKEN = 285 } |
| enum | { C_SEGMENT_DEF, FUNC_DEF, REWRITER_DEF, EVENT_DEF } |
Functions | |
| void | set_definition_type (int type) |
| int | yyerror (const char[]) |
| int | yylex () |
| char * | concat (char *str1, char *str2) |
| void | yy_stack_print (bottom, top) short *bottom |
| void | yysymprint (yyoutput, yytype, yyvaluep) FILE *yyoutput |
| int | yyparse () |
Variables | |
| int | line_number |
| char * | input_filename |
| FILE * | fp_bro_init |
| FILE * | fp_func_def |
| FILE * | fp_func_h |
| FILE * | fp_func_init |
| FILE * | fp_netvar_h |
| FILE * | fp_netvar_def |
| FILE * | fp_netvar_init |
| int | in_c_code = 0 |
| int | definition_type |
| const char * | bro_prefix |
| const char * | c_prefix |
| const char * | arg_list_name = "BiF_ARGS" |
| const char * | trace_rewriter_name = "trace_rewriter" |
| int | var_arg |
| std::vector< BuiltinFuncArg * > | args |
| const char * | decl_name |
| const unsigned char | yytranslate [] |
| const unsigned char | yyprhs [] |
| const yysigned_char | yyrhs [] |
| const unsigned short | yyrline [] |
| const char *const | yytname [] |
| const unsigned char | yyr1 [] |
| const unsigned char | yyr2 [] |
| const unsigned char | yydefact [] |
| const yysigned_char | yydefgoto [] |
| const yysigned_char | yypact [] |
| const yysigned_char | yypgoto [] |
| const unsigned char | yytable [] |
| const yysigned_char | yycheck [] |
| const unsigned char | yystos [] |
| short * | top |
| int | yytype |
| YYSTYPE * | yyvaluep |
| int | yychar |
| YYSTYPE | yylval |
| int | yynerrs |
| char * | yytext |
|
|
Definition at line 128 of file bif_parse.cc. Referenced by yyparse(). |
|
|
Definition at line 104 of file bif_parse.cc. |
|
|
Definition at line 105 of file bif_parse.cc. |
|
|
Definition at line 103 of file bif_parse.cc. |
|
|
Definition at line 112 of file bif_parse.cc. |
|
|
Definition at line 107 of file bif_parse.cc. |
|
|
Definition at line 93 of file bif_parse.cc. |
|
|
Definition at line 113 of file bif_parse.cc. Referenced by check_c_mode(). |
|
|
Definition at line 111 of file bif_parse.cc. |
|
|
Definition at line 97 of file bif_parse.cc. |
|
|
Definition at line 108 of file bif_parse.cc. |
|
|
Definition at line 98 of file bif_parse.cc. |
|
|
Definition at line 101 of file bif_parse.cc. |
|
|
Definition at line 96 of file bif_parse.cc. |
|
|
Definition at line 94 of file bif_parse.cc. |
|
|
Definition at line 106 of file bif_parse.cc. |
|
|
Definition at line 109 of file bif_parse.cc. |
|
|
Definition at line 88 of file bif_parse.cc. |
|
|
Definition at line 86 of file bif_parse.cc. |
|
|
Definition at line 90 of file bif_parse.cc. |
|
|
Definition at line 100 of file bif_parse.cc. |
|
|
Definition at line 95 of file bif_parse.cc. |
|
|
Definition at line 89 of file bif_parse.cc. |
|
|
Definition at line 87 of file bif_parse.cc. |
|
|
Definition at line 91 of file bif_parse.cc. |
|
|
Definition at line 102 of file bif_parse.cc. |
|
|
Definition at line 92 of file bif_parse.cc. |
|
|
Definition at line 99 of file bif_parse.cc. |
|
|
Definition at line 110 of file bif_parse.cc. |
|
|
Value: |
|
|
Value: do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (0) |
|
|
Definition at line 631 of file bif_parse.cc. |
|
|
Definition at line 630 of file bif_parse.cc. |
|
|
Value: do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { \ yyerror ("syntax error: cannot back up");\ YYERROR; \ } \ while (0) Definition at line 643 of file bif_parse.cc. |
|
|
Definition at line 37 of file bif_parse.cc. |
|
|
Definition at line 626 of file bif_parse.cc. |
|
|
Value: do \ { \ register YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (0) Definition at line 294 of file bif_parse.cc. |
|
|
Definition at line 203 of file bif_parse.cc. |
|
|
Value: Definition at line 690 of file bif_parse.cc. |
|
|
Value: do { \ if (yydebug) \ yysymprint Args; \ } while (0) Definition at line 696 of file bif_parse.cc. |
|
|
Value: do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yysymprint (stderr, \ Token, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (0) Definition at line 702 of file bif_parse.cc. |
|
|
Definition at line 627 of file bif_parse.cc. |
|
|
Definition at line 628 of file bif_parse.cc. |
|
|
Definition at line 661 of file bif_parse.cc. |
|
|
Definition at line 625 of file bif_parse.cc. |
|
|
Definition at line 632 of file bif_parse.cc. |
|
|
Definition at line 211 of file bif_parse.cc. |
|
|
Definition at line 639 of file bif_parse.cc. |
|
|
Definition at line 330 of file bif_parse.cc. |
|
|
Definition at line 687 of file bif_parse.cc. |
|
|
Definition at line 784 of file bif_parse.cc. |
|
|
Definition at line 332 of file bif_parse.cc. |
|
|
Definition at line 679 of file bif_parse.cc. |
|
|
Value: ((Current).first_line = (Rhs)[1].first_line, \
(Current).first_column = (Rhs)[1].first_column, \
(Current).last_line = (Rhs)[N].last_line, \
(Current).last_column = (Rhs)[N].last_column)
Definition at line 667 of file bif_parse.cc. |
|
|
Definition at line 46 of file bif_parse.cc. |
|
|
Definition at line 799 of file bif_parse.cc. |
|
|
Definition at line 345 of file bif_parse.cc. |
|
|
Definition at line 337 of file bif_parse.cc. |
|
|
Definition at line 339 of file bif_parse.cc. |
|
|
Definition at line 341 of file bif_parse.cc. |
|
|
Definition at line 335 of file bif_parse.cc. |
|
|
Definition at line 522 of file bif_parse.cc. |
|
|
|
|
|
Definition at line 43 of file bif_parse.cc. |
|
|
Definition at line 641 of file bif_parse.cc. |
|
|
Definition at line 622 of file bif_parse.cc. |
|
|
Definition at line 40 of file bif_parse.cc. |
|
|
Definition at line 261 of file bif_parse.cc. |
|
|
Value: ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) Definition at line 283 of file bif_parse.cc. |
|
|
Definition at line 262 of file bif_parse.cc. |
|
|
Definition at line 279 of file bif_parse.cc. |
|
|
Value: do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (0) Definition at line 310 of file bif_parse.cc. |
|
|
Definition at line 222 of file bif_parse.cc. |
|
|
Definition at line 223 of file bif_parse.cc. |
|
|
Definition at line 224 of file bif_parse.cc. |
|
|
Definition at line 552 of file bif_parse.cc. |
|
|
Definition at line 660 of file bif_parse.cc. |
|
|
Definition at line 347 of file bif_parse.cc. |
|
|
Definition at line 344 of file bif_parse.cc. |
|
|
Definition at line 326 of file bif_parse.cc. |
|
|
|
|
|
Definition at line 143 of file bif_parse.cc.
00143 {
00144 C_SEGMENT_DEF,
00145 FUNC_DEF,
00146 REWRITER_DEF,
00147 EVENT_DEF,
00148 };
|
|
|
Definition at line 55 of file bif_parse.cc.
00055 {
00056 TOK_LPP = 258,
00057 TOK_RPP = 259,
00058 TOK_LPB = 260,
00059 TOK_RPB = 261,
00060 TOK_LPPB = 262,
00061 TOK_RPPB = 263,
00062 TOK_VAR_ARG = 264,
00063 TOK_BOOL = 265,
00064 TOK_FUNCTION = 266,
00065 TOK_REWRITER = 267,
00066 TOK_EVENT = 268,
00067 TOK_CONST = 269,
00068 TOK_ENUM = 270,
00069 TOK_WRITE = 271,
00070 TOK_PUSH = 272,
00071 TOK_EOF = 273,
00072 TOK_TRACE = 274,
00073 TOK_ARGS = 275,
00074 TOK_ARG = 276,
00075 TOK_ARGC = 277,
00076 TOK_ID = 278,
00077 TOK_ATTR = 279,
00078 TOK_CSTR = 280,
00079 TOK_LF = 281,
00080 TOK_WS = 282,
00081 TOK_COMMENT = 283,
00082 TOK_ATOM = 284,
00083 TOK_C_TOKEN = 285
00084 };
|
|
||||||||||||
|
Definition at line 185 of file bif_parse.cc. Referenced by yyparse().
00186 {
00187 int len1 = strlen(str1);
00188 int len2 = strlen(str2);
00189
00190 char* s = new char[len1 + len2 +1];
00191
00192 memcpy(s, str1, len1);
00193 memcpy(s + len1, str2, len2);
00194
00195 s[len1+len2] = '\0';
00196
00197 return s;
00198 }
|
|
|
Definition at line 150 of file bif_parse.cc. References bro_prefix, c_prefix, C_SEGMENT_DEF, definition_type, EVENT_DEF, FUNC_DEF, and REWRITER_DEF. Referenced by yyparse().
00151 {
00152 definition_type = type;
00153 switch ( type ) {
00154 case FUNC_DEF:
00155 bro_prefix = "";
00156 c_prefix = "bro_";
00157 break;
00158
00159 case REWRITER_DEF:
00160 bro_prefix = "rewrite_";
00161 c_prefix = "bro_rewrite_";
00162 break;
00163
00164 case EVENT_DEF:
00165 bro_prefix = "";
00166 break;
00167
00168 case C_SEGMENT_DEF:
00169 break;
00170 }
00171 }
|
|
||||||||||||
|
|
|
|
Definition at line 1865 of file bif_parse.cc. References input_filename, line_number, and yytext.
01866 {
01867 char* msgbuf = new char[strlen(msg) + strlen(yytext) + 64];
01868
01869 if ( yytext[0] == '\n' )
01870 sprintf(msgbuf, "%s, on previous line", msg);
01871
01872 else if ( yytext[0] == '\0' )
01873 sprintf(msgbuf, "%s, at end of file", msg);
01874
01875 else
01876 sprintf(msgbuf, "%s, at or near \"%s\"", msg, yytext);
01877
01878 /*
01879 extern int column;
01880 sprintf(msgbuf, "%*s\n%*s\n", column, "^", column, msg);
01881 */
01882
01883 if ( input_filename )
01884 fprintf(stderr, "%s:%d: ", input_filename, line_number);
01885 else
01886 fprintf(stderr, "line %d: ", line_number);
01887 fprintf(stderr, "%s\n", msgbuf);
01888
01889 abort();
01890
01891 exit(1);
01892 return 0;
01893 }
|
|
|
|
|
|
Definition at line 969 of file bif_parse.cc.
00973 {
00974
00975 register int yystate;
00976 register int yyn;
00977 int yyresult;
00978 /* Number of tokens to shift before error messages enabled. */
00979 int yyerrstatus;
00980 /* Lookahead token as an internal (translated) token number. */
00981 int yytoken = 0;
00982
00983 /* Three stacks and their tools:
00984 `yyss': related to states,
00985 `yyvs': related to semantic values,
00986 `yyls': related to locations.
00987
00988 Refer to the stacks thru separate pointers, to allow yyoverflow
00989 to reallocate them elsewhere. */
00990
00991 /* The state stack. */
00992 short yyssa[YYINITDEPTH];
00993 short *yyss = yyssa;
00994 register short *yyssp;
00995
00996 /* The semantic value stack. */
00997 YYSTYPE yyvsa[YYINITDEPTH];
00998 YYSTYPE *yyvs = yyvsa;
00999 register YYSTYPE *yyvsp;
01000
01001
01002
01003 #define YYPOPSTACK (yyvsp--, yyssp--)
01004
01005 YYSIZE_T yystacksize = YYINITDEPTH;
01006
01007 /* The variables used to return semantic value and location from the
01008 action routines. */
01009 YYSTYPE yyval;
01010
01011
01012 /* When reducing, the number of symbols on the RHS of the reduced
01013 rule. */
01014 int yylen;
01015
01016 YYDPRINTF ((stderr, "Starting parse\n"));
01017
01018 yystate = 0;
01019 yyerrstatus = 0;
01020 yynerrs = 0;
01021 yychar = YYEMPTY; /* Cause a token to be read. */
01022
01023 /* Initialize stack pointers.
01024 Waste one element of value and location stack
01025 so that they stay on the same level as the state stack.
01026 The wasted elements are never initialized. */
01027
01028 yyssp = yyss;
01029 yyvsp = yyvs;
01030
01031 goto yysetstate;
01032
01033 /*------------------------------------------------------------.
01034 | yynewstate -- Push a new state, which is found in yystate. |
01035 `------------------------------------------------------------*/
01036 yynewstate:
01037 /* In all cases, when you get here, the value and location stacks
01038 have just been pushed. so pushing a state here evens the stacks.
01039 */
01040 yyssp++;
01041
01042 yysetstate:
01043 *yyssp = yystate;
01044
01045 if (yyss + yystacksize - 1 <= yyssp)
01046 {
01047 /* Get the current used size of the three stacks, in elements. */
01048 YYSIZE_T yysize = yyssp - yyss + 1;
01049
01050 #ifdef yyoverflow
01051 {
01052 /* Give user a chance to reallocate the stack. Use copies of
01053 these so that the &'s don't force the real ones into
01054 memory. */
01055 YYSTYPE *yyvs1 = yyvs;
01056 short *yyss1 = yyss;
01057
01058
01059 /* Each stack pointer address is followed by the size of the
01060 data in use in that stack, in bytes. This used to be a
01061 conditional around just the two extra args, but that might
01062 be undefined if yyoverflow is a macro. */
01063 yyoverflow ("parser stack overflow",
01064 &yyss1, yysize * sizeof (*yyssp),
01065 &yyvs1, yysize * sizeof (*yyvsp),
01066
01067 &yystacksize);
01068
01069 yyss = yyss1;
01070 yyvs = yyvs1;
01071 }
01072 #else /* no yyoverflow */
01073 # ifndef YYSTACK_RELOCATE
01074 goto yyoverflowlab;
01075 # else
01076 /* Extend the stack our own way. */
01077 if (YYMAXDEPTH <= yystacksize)
01078 goto yyoverflowlab;
01079 yystacksize *= 2;
01080 if (YYMAXDEPTH < yystacksize)
01081 yystacksize = YYMAXDEPTH;
01082
01083 {
01084 short *yyss1 = yyss;
01085 union yyalloc *yyptr =
01086 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01087 if (! yyptr)
01088 goto yyoverflowlab;
01089 YYSTACK_RELOCATE (yyss);
01090 YYSTACK_RELOCATE (yyvs);
01091
01092 # undef YYSTACK_RELOCATE
01093 if (yyss1 != yyssa)
01094 YYSTACK_FREE (yyss1);
01095 }
01096 # endif
01097 #endif /* no yyoverflow */
01098
01099 yyssp = yyss + yysize - 1;
01100 yyvsp = yyvs + yysize - 1;
01101
01102
01103 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01104 (unsigned long int) yystacksize));
01105
01106 if (yyss + yystacksize - 1 <= yyssp)
01107 YYABORT;
01108 }
01109
01110 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01111
01112 goto yybackup;
01113
01114 /*-----------.
01115 | yybackup. |
01116 `-----------*/
01117 yybackup:
01118
01119 /* Do appropriate processing given the current state. */
01120 /* Read a lookahead token if we need one and don't already have one. */
01121 /* yyresume: */
01122
01123 /* First try to decide what to do without reference to lookahead token. */
01124
01125 yyn = yypact[yystate];
01126 if (yyn == YYPACT_NINF)
01127 goto yydefault;
01128
01129 /* Not known => get a lookahead token if don't already have one. */
01130
01131 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
01132 if (yychar == YYEMPTY)
01133 {
01134 YYDPRINTF ((stderr, "Reading a token: "));
01135 yychar = YYLEX;
01136 }
01137
01138 if (yychar <= YYEOF)
01139 {
01140 yychar = yytoken = YYEOF;
01141 YYDPRINTF ((stderr, "Now at end of input.\n"));
01142 }
01143 else
01144 {
01145 yytoken = YYTRANSLATE (yychar);
01146 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
01147 }
01148
01149 /* If the proper action on seeing token YYTOKEN is to reduce or to
01150 detect an error, take that action. */
01151 yyn += yytoken;
01152 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01153 goto yydefault;
01154 yyn = yytable[yyn];
01155 if (yyn <= 0)
01156 {
01157 if (yyn == 0 || yyn == YYTABLE_NINF)
01158 goto yyerrlab;
01159 yyn = -yyn;
01160 goto yyreduce;
01161 }
01162
01163 if (yyn == YYFINAL)
01164 YYACCEPT;
01165
01166 /* Shift the lookahead token. */
01167 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
01168
01169 /* Discard the token being shifted unless it is eof. */
01170 if (yychar != YYEOF)
01171 yychar = YYEMPTY;
01172
01173 *++yyvsp = yylval;
01174
01175
01176 /* Count tokens shifted since error; after three, turn off error
01177 status. */
01178 if (yyerrstatus)
01179 yyerrstatus--;
01180
01181 yystate = yyn;
01182 goto yynewstate;
01183
01184
01185 /*-----------------------------------------------------------.
01186 | yydefault -- do the default action for the current state. |
01187 `-----------------------------------------------------------*/
01188 yydefault:
01189 yyn = yydefact[yystate];
01190 if (yyn == 0)
01191 goto yyerrlab;
01192 goto yyreduce;
01193
01194
01195 |