|
Definition at line 1570 of file parse.cc.
References add_global(), add_local(), add_type(), EnumType::AddName(), EnumType::AddNamesFrom(), TypeList::Append(), arg_list_name, args, BroType::AsEnumType(), Stmt::AsStmtList(), YYSTYPE::attr, ATTR_ADD_FUNC, ATTR_DEFAULT, ATTR_DEL_FUNC, ATTR_ENCRYPT, ATTR_EXPIRE_CREATE, ATTR_EXPIRE_FUNC, ATTR_EXPIRE_READ, ATTR_EXPIRE_WRITE, YYSTYPE::attr_l, ATTR_MATCH, ATTR_OPTIONAL, ATTR_PERSISTENT, ATTR_REDEF, ATTR_ROTATE_INTERVAL, ATTR_ROTATE_SIZE, ATTR_SYNCHRONIZED, base_type(), begin_func(), begin_RE(), bro_prefix, bro_this, YYSTYPE::c_case, c_prefix, YYSTYPE::case_l, concat(), current_module, current_scope(), decl_name, definition_type, do_atelse(), do_atendif(), do_atif(), do_atifdef(), do_atifndef(), end_func(), end_RE(), ID::Error(), BroObj::Error(), error(), error_type(), EVENT_DEF, YYSTYPE::event_expr, YYSTYPE::expr, EXPR_AND, EXPR_DECR, EXPR_EQ, EXPR_FIELD_ASSIGN, EXPR_GE, EXPR_GT, EXPR_INCR, EXPR_LE, EXPR_LT, EXPR_NE, EXPR_OR, fmt(), fp_bro_init, fp_func_def, fp_func_h, fp_func_init, fp_netvar_def, fp_netvar_h, fp_netvar_init, FUNC_DEF, FUNC_FLAVOR_EVENT, FUNC_FLAVOR_FUNCTION, func_id, YYSTYPE::func_type, g_curr_debug_expr, Scope::GenerateTemporary(), get_assign_expr(), global_attributes_type, YYSTYPE::ic, YYSTYPE::id, id, YYSTYPE::id_l, ID::ID_Val(), in_c_code, in_debug, in_global_attr_decl, in_init, INIT_EXTRA, INIT_FULL, INIT_NONE, INIT_REMOVE, input_filename, install_ID(), internal_error(), is_export, ID::IsGlobal(), YYSTYPE::list, EnumType::Lookup(), lookup_ID(), Expr::MarkParen(), no_location, optimize, print_line_directive, BuiltinFuncArg::PrintBro(), YYSTYPE::re, RE_Matcher, YYSTYPE::record, Ref(), Expr::Ref(), refine_type(), resolving_global_ID, REWRITER_DEF, set_definition_type(), set_location(), ID::SetInferReturnType(), YYSTYPE::stmt, StmtList::Stmts(), stmts, YYSTYPE::str, BroType::Tag(), Expr::Tag(), trace_rewriter_name, YYSTYPE::type, Expr::Type(), TYPE_ADDR, TYPE_ANY, TYPE_BOOL, TYPE_COUNT, TYPE_COUNTER, YYSTYPE::type_decl, YYSTYPE::type_decl_l, TYPE_DOUBLE, TYPE_INT, TYPE_INTERVAL, YYSTYPE::type_l, TYPE_NET, TYPE_PATTERN, TYPE_PORT, TYPE_RECORD, TYPE_STRING, TYPE_SUBNET, TYPE_TIME, TYPE_TIMER, TYPE_VOID, val, var_arg, VAR_CONST, VAR_REDEF, VAR_REGULAR, YY_REDUCE_PRINT, YY_STACK_PRINT, YYABORT, YYACCEPT, yychar, yycheck, yydefact, yydefgoto, yydestruct(), YYDPRINTF, YYDSYMPRINTF, YYEMPTY, YYEOF, YYERROR, yyerror, YYFINAL, YYINITDEPTH, YYLAST, YYLEX, yylloc, YYLLOC_DEFAULT, yylval, YYMAXDEPTH, yynerrs, YYNTOKENS, yypact, YYPACT_NINF, yypgoto, YYPOPSTACK, yyr1, yyr2, YYSIZE_T, YYSTACK_ALLOC, YYSTACK_BYTES, YYSTACK_FREE, YYSTACK_RELOCATE, yystos, yytable, YYTABLE_NINF, YYTERROR, yytname, YYTRANSLATE, and yytype.
01574 {
01575
01576 register int yystate;
01577 register int yyn;
01578 int yyresult;
01579
01580 int yyerrstatus;
01581
01582 int yytoken = 0;
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593 short yyssa[YYINITDEPTH];
01594 short *yyss = yyssa;
01595 register short *yyssp;
01596
01597
01598 YYSTYPE yyvsa[YYINITDEPTH];
01599 YYSTYPE *yyvs = yyvsa;
01600 register YYSTYPE *yyvsp;
01601
01602
01603 YYLTYPE yylsa[YYINITDEPTH];
01604 YYLTYPE *yyls = yylsa;
01605 YYLTYPE *yylsp;
01606 YYLTYPE *yylerrsp;
01607
01608 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
01609
01610 YYSIZE_T yystacksize = YYINITDEPTH;
01611
01612
01613
01614 YYSTYPE yyval;
01615 YYLTYPE yyloc;
01616
01617
01618
01619 int yylen;
01620
01621 YYDPRINTF ((stderr, "Starting parse\n"));
01622
01623 yystate = 0;
01624 yyerrstatus = 0;
01625 yynerrs = 0;
01626 yychar = YYEMPTY;
01627
01628
01629
01630
01631
01632
01633 yyssp = yyss;
01634 yyvsp = yyvs;
01635 yylsp = yyls;
01636 goto yysetstate;
01637
01638
01639
01640
01641 yynewstate:
01642
01643
01644
01645 yyssp++;
01646
01647 yysetstate:
01648 *yyssp = yystate;
01649
01650 if (yyss + yystacksize - 1 <= yyssp)
01651 {
01652
01653 YYSIZE_T yysize = yyssp - yyss + 1;
01654
01655 #ifdef yyoverflow
01656 {
01657
01658
01659
01660 YYSTYPE *yyvs1 = yyvs;
01661 short *yyss1 = yyss;
01662 YYLTYPE *yyls1 = yyls;
01663
01664
01665
01666
01667
01668 yyoverflow ("parser stack overflow",
01669 &yyss1, yysize * sizeof (*yyssp),
01670 &yyvs1, yysize * sizeof (*yyvsp),
01671 &yyls1, yysize * sizeof (*yylsp),
01672 &yystacksize);
01673 yyls = yyls1;
01674 yyss = yyss1;
01675 yyvs = yyvs1;
01676 }
01677 #else
01678 # ifndef YYSTACK_RELOCATE
01679 goto yyoverflowlab;
01680 # else
01681
01682 if (YYMAXDEPTH <= yystacksize)
01683 goto yyoverflowlab;
01684 yystacksize *= 2;
01685 if (YYMAXDEPTH < yystacksize)
01686 yystacksize = YYMAXDEPTH;
01687
01688 {
01689 short *yyss1 = yyss;
01690 union yyalloc *yyptr =
01691 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
01692 if (! yyptr)
01693 goto yyoverflowlab;
01694 YYSTACK_RELOCATE (yyss);
01695 YYSTACK_RELOCATE (yyvs);
01696 YYSTACK_RELOCATE (yyls);
01697 # undef YYSTACK_RELOCATE
01698 if (yyss1 != yyssa)
01699 YYSTACK_FREE (yyss1);
01700 }
01701 # endif
01702 #endif
01703
01704 yyssp = yyss + yysize - 1;
01705 yyvsp = yyvs + yysize - 1;
01706 yylsp = yyls + yysize - 1;
01707
01708 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
01709 (unsigned long int) yystacksize));
01710
01711 if (yyss + yystacksize - 1 <= yyssp)
01712 YYABORT;
01713 }
01714
01715 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
01716
01717 goto yybackup;
01718
01719
01720
01721
01722 yybackup:
01723
01724
01725
01726
01727
01728
01729
01730 yyn = yypact[yystate];
01731 if (yyn == YYPACT_NINF)
01732 goto yydefault;
01733
01734
01735
01736
01737 if (yychar == YYEMPTY)
01738 {
01739 YYDPRINTF ((stderr, "Reading a token: "));
01740 yychar = YYLEX;
01741 }
01742
01743 if (yychar <= YYEOF)
01744 {
01745 yychar = yytoken = YYEOF;
01746 YYDPRINTF ((stderr, "Now at end of input.\n"));
01747 }
01748 else
01749 {
01750 yytoken = YYTRANSLATE (yychar);
01751 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
01752 }
01753
01754
01755
01756 yyn += yytoken;
01757 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
01758 goto yydefault;
01759 yyn = yytable[yyn];
01760 if (yyn <= 0)
01761 {
01762 if (yyn == 0 || yyn == YYTABLE_NINF)
01763 goto yyerrlab;
01764 yyn = -yyn;
01765 goto yyreduce;
01766 }
01767
01768 if (yyn == YYFINAL)
01769 YYACCEPT;
01770
01771
01772 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
01773
01774
01775 if (yychar != YYEOF)
01776 yychar = YYEMPTY;
01777
01778 *++yyvsp = yylval;
01779 *++yylsp = yylloc;
01780
01781
01782
01783 if (yyerrstatus)
01784 yyerrstatus--;
01785
01786 yystate = yyn;
01787 goto yynewstate;
01788
01789
01790
01791
01792
01793 yydefault:
01794 yyn = yydefact[yystate];
01795 if (yyn == 0)
01796 goto yyerrlab;
01797 goto yyreduce;
01798
01799
01800
01801
01802
01803 yyreduce:
01804
01805 yylen = yyr2[yyn];
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815 yyval = yyvsp[1-yylen];
01816
01817
01818 YYLLOC_DEFAULT (yyloc, yylsp - yylen, yylen);
01819 YY_REDUCE_PRINT (yyn);
01820 switch (yyn)
01821 {
01822 case 2:
01823 #line 152 "parse.y"
01824 {
01825 if ( optimize )
01826 yyvsp[0].stmt = yyvsp[0].stmt->Simplify();
01827
01828 if ( stmts )
01829 stmts->AsStmtList()->Stmts().append(yyvsp[0].stmt);
01830 else
01831 stmts = yyvsp[0].stmt;
01832
01833
01834
01835 set_location(no_location);
01836 }
01837 break;
01838
01839 case 3:
01840 #line 169 "parse.y"
01841 { in_debug = true; }
01842 break;
01843
01844 case 4:
01845 #line 170 "parse.y"
01846 {
01847 g_curr_debug_expr = yyvsp[0].expr;
01848 in_debug = false;
01849 }
01850 break;
01851
01852 case 7:
01853 #line 183 "parse.y"
01854 {
01855 set_location(yylsp[-2], yylsp[0]);
01856 yyval.expr = yyvsp[-1].expr; yyval.expr->MarkParen();
01857 }
01858 break;
01859
01860 case 8:
01861 #line 189 "parse.y"
01862 {
01863 set_location(yylsp[-1], yylsp[0]);
01864 yyval.expr = new IncrExpr(EXPR_INCR, yyvsp[0].expr);
01865 }
01866 break;
01867
01868 case 9:
01869 #line 195 "parse.y"
01870 {
01871 set_location(yylsp[-1], yylsp[0]);
01872 yyval.expr = new IncrExpr(EXPR_DECR, yyvsp[0].expr);
01873 }
01874 break;
01875
01876 case 10:
01877 #line 201 "parse.y"
01878 {
01879 set_location(yylsp[-1], yylsp[0]);
01880 yyval.expr = new NotExpr(yyvsp[0].expr);
01881 }
01882 break;
01883
01884 case 11:
01885 #line 207 "parse.y"
01886 {
01887 set_location(yylsp[-1], yylsp[0]);
01888 yyval.expr = new NegExpr(yyvsp[0].expr);
01889 }
01890 break;
01891
01892 case 12:
01893 #line 213 "parse.y"
01894 {
01895 set_location(yylsp[-1], yylsp[0]);
01896 yyval.expr = new PosExpr(yyvsp[0].expr);
01897 }
01898 break;
01899
01900 case 13:
01901 #line 219 "parse.y"
01902 {
01903 set_location(yylsp[-2], yylsp[0]);
01904 yyval.expr = new AddExpr(yyvsp[-2].expr, yyvsp[0].expr);
01905 }
01906 break;
01907
01908 case 14:
01909 #line 225 "parse.y"
01910 {
01911 set_location(yylsp[-2], yylsp[0]);
01912 yyval.expr = new SubExpr(yyvsp[-2].expr, yyvsp[0].expr);
01913 }
01914 break;
01915
01916 case 15:
01917 #line 231 "parse.y"
01918 {
01919 set_location(yylsp[-2], yylsp[0]);
01920 yyval.expr = new TimesExpr(yyvsp[-2].expr, yyvsp[0].expr);
01921 }
01922 break;
01923
01924 case 16:
01925 #line 237 "parse.y"
01926 {
01927 set_location(yylsp[-2], yylsp[0]);
01928 yyval.expr = new DivideExpr(yyvsp[-2].expr, yyvsp[0].expr);
01929 }
01930 break;
01931
01932 case 17:
01933 #line 243 "parse.y"
01934 {
01935 set_location(yylsp[-2], yylsp[0]);
01936 yyval.expr = new ModExpr(yyvsp[-2].expr, yyvsp[0].expr);
01937 }
01938 break;
01939
01940 case 18:
01941 #line 249 "parse.y"
01942 {
01943 set_location(yylsp[-2], yylsp[0]);
01944 yyval.expr = new BoolExpr(EXPR_AND, yyvsp[-2].expr, yyvsp[0].expr);
01945 }
01946 break;
01947
01948 case 19:
01949 #line 255 "parse.y"
01950 {
01951 set_location(yylsp[-2], yylsp[0]);
01952 yyval.expr = new BoolExpr(EXPR_OR, yyvsp[-2].expr, yyvsp[0].expr);
01953 }
01954 break;
01955
01956 case 20:
01957 #line 261 "parse.y"
01958 {
01959 set_location(yylsp[-2], yylsp[0]);
01960 yyval.expr = new EqExpr(EXPR_EQ, yyvsp[-2].expr, yyvsp[0].expr);
01961 }
01962 break;
01963
01964 case 21:
01965 #line 267 "parse.y"
01966 {
01967 set_location(yylsp[-2], yylsp[0]);
01968 yyval.expr = new EqExpr(EXPR_NE, yyvsp[-2].expr, yyvsp[0].expr);
01969 }
01970 break;
01971
01972 case 22:
01973 #line 273 "parse.y"
01974 {
01975 set_location(yylsp[-2], yylsp[0]);
01976 yyval.expr = new RelExpr(EXPR_LT, yyvsp[-2].expr, yyvsp[0].expr);
01977 }
01978 break;
01979
01980 case 23:
01981 #line 279 "parse.y"
01982 {
01983 set_location(yylsp[-2], yylsp[0]);
01984 yyval.expr = new RelExpr(EXPR_LE, yyvsp[-2].expr, yyvsp[0].expr);
01985 }
01986 break;
01987
01988 case 24:
01989 #line 285 "parse.y"
01990 {
01991 set_location(yylsp[-2], yylsp[0]);
01992 yyval.expr = new RelExpr(EXPR_GT, yyvsp[-2].expr, yyvsp[0].expr);
01993 }
01994 break;
01995
01996 case 25:
01997 #line 291 "parse.y"
01998 {
01999 set_location(yylsp[-2], yylsp[0]);
02000 yyval.expr = new RelExpr(EXPR_GE, yyvsp[-2].expr, yyvsp[0].expr);
02001 }
02002 break;
02003
02004 case 26:
02005 #line 297 "parse.y"
02006 {
02007 set_location(yylsp[-4], yylsp[0]);
02008 yyval.expr = new CondExpr(yyvsp[-4].expr, yyvsp[-2].expr, yyvsp[0].expr);
02009 }
02010 break;
02011
02012 case 27:
02013 #line 303 "parse.y"
02014 {
02015 set_location(yylsp[-2], yylsp[0]);
02016 yyval.expr = get_assign_expr(yyvsp[-2].expr, yyvsp[0].expr, in_init);
02017 }
02018 break;
02019
02020 case 28:
02021 #line 309 "parse.y"
02022 {
02023 set_location(yylsp[-3], yylsp[0]);
02024 yyval.expr = new IndexExpr(yyvsp[-3].expr, yyvsp[-1].list);
02025 }
02026 break;
02027
02028 case 29:
02029 #line 315 "parse.y"
02030 {
02031 set_location(yylsp[-2], yylsp[0]);
02032 yyval.expr = new FieldExpr(yyvsp[-2].expr, yyvsp[0].str);
02033 }
02034 break;
02035
02036 case 30:
02037 #line 321 "parse.y"
02038 {
02039 set_location(yylsp[-3], yylsp[0]);
02040 yyval.expr = new FieldAssignExpr(yyvsp[-2].str, yyvsp[0].expr);
02041 }
02042 break;
02043
02044 case 31:
02045 #line 327 "parse.y"
02046 {
02047 func_id = current_scope()->GenerateTemporary("anonymous-function");
02048 func_id->SetInferReturnType(true);
02049 begin_func(func_id,
02050 current_module.c_str(),
02051 FUNC_FLAVOR_FUNCTION,
02052 0,
02053 yyvsp[-1].func_type);
02054 }
02055 break;
02056
02057 case 32:
02058 #line 337 "parse.y"
02059 {
02060 yyval.expr = new FieldAssignExpr(yyvsp[-4].str, new ConstExpr(func_id->ID_Val()));
02061 }
02062 break;
02063
02064 case 33:
02065 #line 342 "parse.y"
02066 {
02067 set_location(yylsp[-2], yylsp[0]);
02068 yyval.expr = new InExpr(yyvsp[-2].expr, yyvsp[0].expr);
02069 }
02070 break;
02071
02072 case 34:
02073 #line 348 "parse.y"
02074 {
02075 set_location(yylsp[-2], yylsp[0]);
02076 yyval.expr = new NotExpr(new InExpr(yyvsp[-2].expr, yyvsp[0].expr));
02077 }
02078 break;
02079
02080 case 35:
02081 #line 354 "parse.y"
02082 {
02083
02084
02085
02086
02087
02088
02089 set_location(yylsp[-2], yylsp[0]);
02090
02091 Expr* e0 = yyvsp[-1].list->Exprs()[0];
02092 if ( e0->Tag() == EXPR_FIELD_ASSIGN ||
02093 e0->Type()->Tag() == TYPE_RECORD )
02094 yyval.expr = new RecordConstructorExpr(yyvsp[-1].list);
02095 else
02096 yyval.expr = yyvsp[-1].list;
02097 }
02098 break;
02099
02100 case 36:
02101 #line 372 "parse.y"
02102 {
02103 set_location(yylsp[-3], yylsp[0]);
02104 yyval.expr = new RecordMatchExpr(yyvsp[-2].expr, yyvsp[0].expr);
02105 }
02106 break;
02107
02108 case 37:
02109 #line 378 "parse.y"
02110 {
02111 set_location(yylsp[-3], yylsp[0]);
02112 yyval.expr = new CallExpr(yyvsp[-3].expr, yyvsp[-1].list);
02113 }
02114 break;
02115
02116 case 38:
02117 #line 384 "parse.y"
02118 {
02119 set_location(yylsp[-2], yylsp[0]);
02120 yyval.expr = new HasFieldExpr(yyvsp[-2].expr, yyvsp[0].str, false);
02121 }
02122 break;
02123
02124 case 39:
02125 #line 390 "parse.y"
02126 {
02127 set_location(yylsp[-2], yylsp[0]);
02128 yyval.expr = new HasFieldExpr(yyvsp[-2].expr, yyvsp[0].str, true);
02129 }
02130 break;
02131
02132 case 41:
02133 #line 398 "parse.y"
02134 {
02135 set_location(yylsp[-4], yylsp[0]);
02136 yyval.expr = new ScheduleExpr(yyvsp[-3].expr, yyvsp[-1].event_expr);
02137 }
02138 break;
02139
02140 case 42:
02141 #line 404 "parse.y"
02142 {
02143 set_location(yylsp[0]);
02144
02145 ID* id = lookup_ID(yyvsp[0].str, current_module.c_str());
02146 if ( ! id )
02147 {
02148 if ( ! in_debug )
02149 {
02150
02151
02152
02153
02154
02155 yyerror(fmt("unknown identifier %s", yyvsp[0].str));
02156 YYERROR;
02157 }
02158 else
02159 {
02160 yyerror(fmt("unknown identifier %s", yyvsp[0].str));
02161 YYERROR;
02162 }
02163 }
02164 else
02165 {
02166 if ( ! id->Type() )
02167 {
02168 id->Error("undeclared variable");
02169 id->SetType(error_type());
02170 yyval.expr = new NameExpr(id);
02171 }
02172
02173 else if ( id->IsEnumConst() )
02174 {
02175 EnumType* t = id->Type()->AsEnumType();
02176 int intval = t->Lookup(id->ModuleName(),
02177 id->Name());
02178 if ( intval < 0 )
02179 internal_error("enum value not found for %s", id->Name());
02180 yyval.expr = new ConstExpr(new EnumVal(intval, t));
02181 }
02182 else
02183 yyval.expr = new NameExpr(id);
02184 }
02185 }
02186 break;
02187
02188 case 43:
02189 #line 450 "parse.y"
02190 {
02191 set_location(yylsp[0]);
02192 yyval.expr = new ConstExpr(yyvsp[0].val);
02193 }
02194 break;
02195
02196 case 44:
02197 #line 456 "parse.y"
02198 {
02199 set_location(yylsp[0]);
02200 yyvsp[0].re->Compile();
02201 yyval.expr = new ConstExpr(new PatternVal(yyvsp[0].re));
02202 }
02203 break;
02204
02205 case 45:
02206 #line 463 "parse.y"
02207 {
02208 set_location(yylsp[0]);
02209 yyval.expr = bro_this->Ref();
02210 }
02211 break;
02212
02213 case 46:
02214 #line 471 "parse.y"
02215 {
02216 set_location(yylsp[-2], yylsp[0]);
02217 yyvsp[-2].list->Append(yyvsp[0].expr);
02218 }
02219 break;
02220
02221 case 47:
02222 #line 477 "parse.y"
02223 {
02224 set_location(yylsp[0]);
02225 yyval.list = new ListExpr(yyvsp[0].expr);
02226 }
02227 break;
02228
02229 case 49:
02230 #line 486 "parse.y"
02231 { yyval.list = new ListExpr(); }
02232 break;
02233
02234 case 52:
02235 #line 496 "parse.y"
02236 {
02237 yyvsp[-2].re->AddPat(yyvsp[0].str);
02238 delete [] yyvsp[0].str;
02239 }
02240 break;
02241
02242 case 53:
02243 #line 502 "parse.y"
02244 {
02245 yyval.re = new RE_Matcher(yyvsp[0].str);
02246 delete [] yyvsp[0].str;
02247 }
02248 break;
02249
02250 case 54:
02251 #line 509 "parse.y"
02252 { begin_RE(); }
02253 break;
02254
02255 case 55:
02256 #line 509 "parse.y"
02257 { end_RE(); }
02258 break;
02259
02260 case 56:
02261 #line 510 "parse.y"
02262 { yyval.str = yyvsp[-2].str; }
02263 break;
02264
02265 case 57:
02266 #line 515 "parse.y"
02267 {
02268 set_location(yylsp[0]);
02269
02270 EnumType* et = new EnumType(is_export);
02271 if ( et->AddName(current_module, yyvsp[0].str) < 0 )
02272 error("identifier in enumerated type definition already exists");
02273 yyval.type = et;
02274 }
02275 break;
02276
02277 case 58:
02278 #line 525 "parse.y"
02279 {
02280 set_location(yylsp[-2], yylsp[0]);
02281
02282 if ( yyvsp[-2].type->AsEnumType()->AddName(current_module, yyvsp[0].str) < 1 )
02283 error("identifier in enumerated type definition already exists");
02284 yyval.type = yyvsp[-2].type;
02285 }
02286 break;
02287
02288 case 59:
02289 #line 535 "parse.y"
02290 {
02291 set_location(yylsp[0]);
02292 yyval.type = base_type(TYPE_BOOL);
02293 }
02294 break;
02295
02296 case 60:
02297 #line 540 "parse.y"
02298 {
02299 set_location(yylsp[0]);
02300 yyval.type = base_type(TYPE_INT);
02301 }
02302 break;
02303
02304 case 61:
02305 #line 545 "parse.y"
02306 {
02307 set_location(yylsp[0]);
02308 yyval.type = base_type(TYPE_COUNT);
02309 }
02310 break;
02311
02312 case 62:
02313 #line 550 "parse.y"
02314 {
02315 set_location(yylsp[0]);
02316 yyval.type = base_type(TYPE_COUNTER);
02317 }
02318 break;
02319
02320 case 63:
02321 #line 555 "parse.y"
02322 {
02323 set_location(yylsp[0]);
02324 yyval.type = base_type(TYPE_DOUBLE);
02325 }
02326 break;
02327
02328 case 64:
02329 #line 560 "parse.y"
02330 {
02331 set_location(yylsp[0]);
02332 yyval.type = base_type(TYPE_TIME);
02333 }
02334 break;
02335
02336 case 65:
02337 #line 565 "parse.y"
02338 {
02339 set_location(yylsp[0]);
02340 yyval.type = base_type(TYPE_INTERVAL);
02341 }
02342 break;
02343
02344 case 66:
02345 #line 570 "parse.y"
02346 {
02347 set_location(yylsp[0]);
02348 yyval.type = base_type(TYPE_STRING);
02349 }
02350 break;
02351
02352 case 67:
02353 #line 575 "parse.y"
02354 {
02355 set_location(yylsp[0]);
02356 yyval.type = base_type(TYPE_PATTERN);
02357 }
02358 break;
02359
02360 case 68:
02361 #line 580 "parse.y"
02362 {
02363 set_location(yylsp[0]);
02364 yyval.type = base_type(TYPE_TIMER);
02365 }
02366 break;
02367
02368 case 69:
02369 #line 585 "parse.y"
02370 {
02371 set_location(yylsp[0]);
02372 yyval.type = base_type(TYPE_PORT);
02373 }
02374 break;
02375
02376 case 70:
02377 #line 590 "parse.y"
02378 {
02379 set_location(yylsp[0]);
02380 yyval.type = base_type(TYPE_ADDR);
02381 }
02382 break;
02383
02384 case 71:
02385 #line 595 "parse.y"
02386 {
02387 set_location(yylsp[0]);
02388 yyval.type = base_type(TYPE_NET);
02389 }
02390 break;
02391
02392 case 72:
02393 #line 600 "parse.y"
02394 {
02395 set_location(yylsp[0]);
02396 yyval.type = base_type(TYPE_SUBNET);
02397 }
02398 break;
02399
02400 case 73:
02401 #line 605 "parse.y"
02402 {
02403 set_location(yylsp[0]);
02404 yyval.type = base_type(TYPE_ANY);
02405 }
02406 break;
02407
02408 case 74:
02409 #line 611 "parse.y"
02410 {
02411 set_location(yylsp[-5], yylsp[0]);
02412 yyval.type = new TableType(yyvsp[-3].type_l, yyvsp[0].type);
02413 }
02414 break;
02415
02416 case 75:
02417 #line 617 "parse.y"
02418 {
02419 set_location(yylsp[-3], yylsp[0]);
02420 yyval.type = new SetType(yyvsp[-1].type_l, 0);
02421 }
02422 break;
02423
02424 case 76:
02425 #line 623 "parse.y"
02426 {
02427 set_location(yylsp[-3], yylsp[0]);
02428 yyval.type = new SetType((TypeList*) 0, yyvsp[-1].list);
02429 }
02430 break;
02431
02432 case 77:
02433 #line 629 "parse.y"
02434 {
02435 set_location(yylsp[-3], yylsp[0]);
02436 yyval.type = new RecordType(yyvsp[-1].type_decl_l);
02437 }
02438 break;
02439
02440 case 78:
02441 #line 635 "parse.y"
02442 {
02443 set_location(yylsp[-3], yylsp[0]);
02444 error("union type not implemented");
02445 yyval.type = 0;
02446 }
02447 break;
02448
02449 case 79:
02450 #line 642 "parse.y"
02451 {
02452 set_location(yylsp[-4], yylsp[-1]);
02453 yyval.type = yyvsp[-2].type;
02454 }
02455 break;
02456
02457 case 80:
02458 #line 648 "parse.y"
02459 {
02460 set_location(yylsp[0]);
02461
02462 error("list type not implemented");
02463 yyval.type = 0;
02464 }
02465 break;
02466
02467 case 81:
02468 #line 656 "parse.y"
02469 {
02470 set_location(yylsp[-2]);
02471
02472 error("list type not implemented");
02473 yyval.type = 0;
02474 }
02475 break;
02476
02477 case 82:
02478 #line 664 "parse.y"
02479 {
02480 set_location(yylsp[-2], yylsp[0]);
02481 yyval.type = new VectorType(yyvsp[0].type);
02482 }
02483 break;
02484
02485 case 83:
02486 #line 670 "parse.y"
02487 {
02488 set_location(yylsp[-1], yylsp[0]);
02489 yyval.type = yyvsp[0].func_type;
02490 }
02491 break;
02492
02493 case 84:
02494 #line 676 "parse.y"
02495 {
02496 set_location(yylsp[-3], yylsp[-1]);
02497 yyval.type = new FuncType(yyvsp[-1].record, 0, 1);
02498 }
02499 break;
02500
02501 case 85:
02502 #line 682 "parse.y"
02503 {
02504 set_location(yylsp[-2], yylsp[0]);
02505 yyval.type = new FileType(yyvsp[0].type);
02506 }
02507 break;
02508
02509 case 86:
02510 #line 688 "parse.y"
02511 {
02512 set_location(yylsp[0]);
02513 yyval.type = new FileType(base_type(TYPE_STRING));
02514 }
02515 break;
02516
02517 case 87:
02518 #line 694 "parse.y"
02519 {
02520 if ( ! yyvsp[0].id || ! (yyval.type = yyvsp[0].id->AsType()) )
02521 {
02522 NullStmt here;
02523 if ( yyvsp[0].id )
02524 yyvsp[0].id->Error("not a BRO type", &here);
02525 yyval.type = error_type();
02526 }
02527 else
02528 Ref(yyval.type);
02529 }
02530 break;
02531
02532 case 88:
02533 #line 709 "parse.y"
02534 { yyvsp[-2].type_l->AppendEvenIfNotPure(yyvsp[0].type); }
02535 break;
02536
02537 case 89:
02538 #line 711 "parse.y"
02539 {
02540 yyval.type_l = new TypeList(yyvsp[0].type);
02541 yyval.type_l->Append(yyvsp[0].type);
02542 }
02543 break;
02544
02545 case 90:
02546 #line 719 "parse.y"
02547 { yyvsp[-1].type_decl_l->append(yyvsp[0].type_decl); }
02548 break;
02549
02550 case 91:
02551 #line 721 "parse.y"
02552 { yyval.type_decl_l = new type_decl_list(); }
02553 break;
02554
02555 case 92:
02556 #line 726 "parse.y"
02557 {
02558 set_location(yylsp[-4], yylsp[0]);
02559 yyval.type_decl = new TypeDecl(yyvsp[-2].type, yyvsp[-4].str, yyvsp[-1].attr_l);
02560 }
02561 break;
02562
02563 case 93:
02564 #line 734 "parse.y"
02565 { yyval.record = new RecordType(yyvsp[0].type_decl_l); }
02566 break;
02567
02568 case 94:
02569 #line 736 "parse.y"
02570 { yyval.record = new RecordType(yyvsp[-1].type_decl_l); }
02571 break;
02572
02573 case 95:
02574 #line 738 "parse.y"
02575 { yyval.record = new RecordType(new type_decl_list()); }
02576 break;
02577
02578 case 96:
02579 #line 743 "parse.y"
02580 { yyvsp[-2].type_decl_l->append(yyvsp[0].type_decl); }
02581 break;
02582
02583 case 97:
02584 #line 745 "parse.y"
02585 { yyvsp[-2].type_decl_l->append(yyvsp[0].type_decl); }
02586 break;
02587
02588 case 98:
02589 #line 747 "parse.y"
02590 { yyval.type_decl_l = new type_decl_list(); yyval.type_decl_l->append(yyvsp[0].type_decl); }
02591 break;
02592
02593 case 99:
02594 #line 752 "parse.y"
02595 {
02596 set_location(yylsp[-3], yylsp[0]);
02597 yyval.type_decl = new TypeDecl(yyvsp[-1].type, yyvsp[-3].str, yyvsp[0].attr_l);
02598 }
02599 break;
02600
02601 case 100:
02602 #line 760 "parse.y"
02603 { current_module = yyvsp[-1].str; }
02604 break;
02605
02606 case 101:
02607 #line 762 "parse.y"
02608 { is_export = true; }
02609 break;
02610
02611 case 102:
02612 #line 763 "parse.y"
02613 { is_export = false; }
02614 break;
02615
02616 case 103:
02617 #line 766 "parse.y"
02618 { add_global(yyvsp[-5].id, yyvsp[-4].type, yyvsp[-3].ic, yyvsp[-2].expr, yyvsp[-1].attr_l, VAR_REGULAR); }
02619 break;
02620
02621 case 104:
02622 #line 769 "parse.y"
02623 { add_global(yyvsp[-5].id, yyvsp[-4].type, yyvsp[-3].ic, yyvsp[-2].expr, yyvsp[-1].attr_l, VAR_CONST); }
02624 break;
02625
02626 case 105:
02627 #line 772 "parse.y"
02628 { add_global(yyvsp[-5].id, yyvsp[-4].type, yyvsp[-3].ic, yyvsp[-2].expr, yyvsp[-1].attr_l, VAR_REDEF); }
02629 break;
02630
02631 case 106:
02632 #line 776 "parse.y"
02633 {
02634 if ( ! yyvsp[-6].id->Type() )
02635 yyvsp[-6].id->Error("unknown identifier");
02636 else
02637 {
02638 EnumType* add_to = yyvsp[-6].id->Type()->AsEnumType();
02639 if ( ! add_to )
02640 yyvsp[-6].id->Error("not an enum");
02641 else
02642 add_to->AddNamesFrom(current_module,
02643 yyvsp[-3].type->AsEnumType());
02644 }
02645 }
02646 break;
02647
02648 case 107:
02649 #line 791 "parse.y"
02650 {
02651 add_type(yyvsp[-5].id, yyvsp[-3].type, yyvsp[-2].attr_l, 0);
02652 if ( yyvsp[-1].type_decl_l )
02653 yyvsp[-5].id->AsType()->SetAttributesType(yyvsp[-1].type_decl_l);
02654 }
02655 break;
02656
02657 case 108:
02658 #line 797 "parse.y"
02659 { in_global_attr_decl = true; }
02660 break;
02661
02662 case 109:
02663 #line 798 "parse.y"
02664 { in_global_attr_decl = false; }
02665 break;
02666
02667 case 110:
02668 #line 799 "parse.y"
02669 {
02670 global_attributes_type = new RecordType(yyvsp[-3].type_decl_l);
02671 }
02672 break;
02673
02674 case 111:
02675 #line 804 "parse.y"
02676 { add_type(yyvsp[-4].id, yyvsp[-2].type, yyvsp[-1].attr_l, 1); }
02677 break;
02678
02679 case 112:
02680 #line 807 "parse.y"
02681 { }
02682 break;
02683
02684 case 114:
02685 #line 814 "parse.y"
02686 { do_atif(yyvsp[-1].expr); }
02687 break;
02688
02689 case 115:
02690 #line 816 "parse.y"
02691 { do_atifdef(yyvsp[-1].str); }
02692 break;
02693
02694 case 116:
02695 #line 818 "parse.y"
02696 { do_atifndef(yyvsp[-1].str); }
02697 break;
02698
02699 case 117:
02700 #line 820 "parse.y"
02701 { do_atendif(); }
02702 break;
02703
02704 case 118:
02705 #line 822 "parse.y"
02706 { do_atelse(); }
02707 break;
02708
02709 case 119:
02710 #line 827 "parse.y"
02711 { yyval.type_decl_l = yyvsp[-1].type_decl_l; }
02712 break;
02713
02714 case 120:
02715 #line 829 "parse.y"
02716 { yyval.type_decl_l = 0; }
02717 break;
02718
02719 case 121:
02720 #line 834 "parse.y"
02721 {
02722 begin_func(yyvsp[-1].id, current_module.c_str(),
02723 FUNC_FLAVOR_FUNCTION, 0, yyvsp[0].func_type);
02724 yyval.func_type = yyvsp[0].func_type;
02725 }
02726 break;
02727
02728 case 122:
02729 #line 840 "parse.y"
02730 {
02731 begin_func(yyvsp[-1].id, current_module.c_str(),
02732 FUNC_FLAVOR_EVENT, 0, yyvsp[0].func_type);
02733 yyval.func_type = yyvsp[0].func_type;
02734 }
02735 break;
02736
02737 case 123:
02738 #line 846 "parse.y"
02739 {
02740 begin_func(yyvsp[-1].id, current_module.c_str(),
02741 FUNC_FLAVOR_EVENT, 1, yyvsp[0].func_type);
02742 yyval.func_type = yyvsp[0].func_type;
02743 }
02744 break;
02745
02746 case 124:
02747 #line 855 "parse.y"
02748 {
02749 if ( optimize )
02750 yyvsp[-1].stmt = yyvsp[-1].stmt->Simplify();
02751
02752 end_func(yyvsp[-1].stmt);
02753 }
02754 break;
02755
02756 case 125:
02757 #line 865 "parse.y"
02758 { yyval.expr = new ConstExpr(yyvsp[-1].id->ID_Val()); }
02759 break;
02760
02761 case 126:
02762 #line 870 "parse.y"
02763 {
02764 yyval.id = current_scope()->GenerateTemporary("anonymous-function");
02765 begin_func(yyval.id, current_module.c_str(),
02766 FUNC_FLAVOR_FUNCTION, 0, yyvsp[0].func_type);
02767 }
02768 break;
02769
02770 case 127:
02771 #line 879 "parse.y"
02772 { yyval.func_type = new FuncType(yyvsp[-3].record, yyvsp[0].type, 0); }
02773 break;
02774
02775 case 128:
02776 #line 881 "parse.y"
02777 { yyval.func_type = new FuncType(yyvsp[-1].record, base_type(TYPE_VOID), 0); }
02778 break;
02779
02780 case 129:
02781 #line 886 "parse.y"
02782 { yyval.type = refine_type(yyvsp[-3].type_l, yyvsp[-1].type_decl_l); }
02783 break;
02784
02785 case 130:
02786 #line 888 "parse.y"
02787 { yyval.type = refine_type(yyvsp[0].type_l, 0); }
02788 break;
02789
02790 case 131:
02791 #line 893 "parse.y"
02792 { yyval.type = yyvsp[0].type; }
02793 break;
02794
02795 case 132:
02796 #line 895 "parse.y"
02797 { yyval.type = 0; }
02798 break;
02799
02800 case 133:
02801 #line 899 "parse.y"
02802 { yyval.ic = INIT_NONE; }
02803 break;
02804
02805 case 134:
02806 #line 900 "parse.y"
02807 { yyval.ic = INIT_FULL; }
02808 break;
02809
02810 case 135:
02811 #line 901 "parse.y"
02812 { yyval.ic = INIT_EXTRA; }
02813 break;
02814
02815 case 136:
02816 #line 902 "parse.y"
02817 { yyval.ic = INIT_REMOVE; }
02818 break;
02819
02820 case 137:
02821 #line 906 "parse.y"
02822 { ++in_init; }
02823 break;
02824
02825 case 138:
02826 #line 906 "parse.y"
02827 { --in_init; }
02828 break;
02829
02830 case 139:
02831 #line 907 "parse.y"
02832 { yyval.expr = yyvsp[-1].expr; }
02833 break;
02834
02835 case 140:
02836 #line 909 "parse.y"
02837 { yyval.expr = 0; }
02838 break;
02839
02840 case 141:
02841 #line 914 "parse.y"
02842 { yyval.expr = yyvsp[-1].list; }
02843 break;
02844
02845 case 142:
02846 #line 916 "parse.y"
02847 { yyval.expr = yyvsp[-2].list; }
02848 break;
02849
02850 case 145:
02851 #line 923 "parse.y"
02852 { yyval.attr_l = 0; }
02853 break;
02854
02855 case 146:
02856 #line 928 "parse.y"
02857 { yyvsp[-1].attr_l->append(yyvsp[0].attr); }
02858 break;
02859
02860 case 147:
02861 #line 930 "parse.y"
02862 {
02863 yyval.attr_l = new attr_list;
02864 yyval.attr_l->append(yyvsp[0].attr);
02865 }
02866 break;
02867
02868 case 148:
02869 #line 938 "parse.y"
02870 { yyval.attr = new Attr(ATTR_DEFAULT, yyvsp[0].expr); }
02871 break;
02872
02873 case 149:
02874 #line 940 "parse.y"
02875 { yyval.attr = new Attr(ATTR_OPTIONAL); }
02876 break;
02877
02878 case 150:
02879 #line 942 "parse.y"
02880 { yyval.attr = new Attr(ATTR_REDEF); }
02881 break;
02882
02883 case 151:
02884 #line 944 "parse.y"
02885 { yyval.attr = new Attr(ATTR_ROTATE_INTERVAL, yyvsp[0].expr); }
02886 break;
02887
02888 case 152:
02889 #line 946 "parse.y"
02890 { yyval.attr = new Attr(ATTR_ROTATE_SIZE, yyvsp[0].expr); }
02891 break;
02892
02893 case 153:
02894 #line 948 "parse.y"
02895 { yyval.attr = new Attr(ATTR_ADD_FUNC, yyvsp[0].expr); }
02896 break;
02897
02898 case 154:
02899 #line 950 "parse.y"
02900 { yyval.attr = new Attr(ATTR_DEL_FUNC, yyvsp[0].expr); }
02901 break;
02902
02903 case 155:
02904 #line 952 "parse.y"
02905 { yyval.attr = new Attr(ATTR_EXPIRE_FUNC, yyvsp[0].expr); }
02906 break;
02907
02908 case 156:
02909 #line 954 "parse.y"
02910 { yyval.attr = new Attr(ATTR_EXPIRE_CREATE, yyvsp[0].expr); }
02911 break;
02912
02913 case 157:
02914 #line 956 "parse.y"
02915 { yyval.attr = new Attr(ATTR_EXPIRE_READ, yyvsp[0].expr); }
02916 break;
02917
02918 case 158:
02919 #line 958 "parse.y"
02920 { yyval.attr = new Attr(ATTR_EXPIRE_WRITE, yyvsp[0].expr); }
02921 break;
02922
02923 case 159:
02924 #line 960 "parse.y"
02925 { yyval.attr = new Attr(ATTR_PERSISTENT); }
02926 break;
02927
02928 case 160:
02929 #line 962 "parse.y"
02930 { yyval.attr = new Attr(ATTR_SYNCHRONIZED); }
02931 break;
02932
02933 case 161:
02934 #line 964 "parse.y"
02935 { yyval.attr = new Attr(ATTR_ENCRYPT); }
02936 break;
02937
02938 case 162:
02939 #line 966 "parse.y"
02940 { yyval.attr = new Attr(ATTR_ENCRYPT, yyvsp[0].expr); }
02941 break;
02942
02943 case 163:
02944 #line 968 "parse.y"
02945 { yyval.attr = new Attr(ATTR_MATCH); }
02946 break;
02947
02948 case 164:
02949 #line 973 "parse.y"
02950 {
02951 set_location(yylsp[-2], yylsp[0]);
02952 yyval.stmt = yyvsp[-1].stmt;
02953 }
02954 break;
02955
02956 case 165:
02957 #line 979 "parse.y"
02958 {
02959 set_location(yylsp[-2], yylsp[0]);
02960 yyval.stmt = new AlarmStmt(yyvsp[-1].list);
02961 }
02962 break;
02963
02964 case 166:
02965 #line 985 "parse.y"
02966 {
02967 set_location(yylsp[-2], yylsp[0]);
02968 yyval.stmt = new PrintStmt(yyvsp[-1].list);
02969 }
02970 break;
02971
02972 case 167:
02973 #line 991 "parse.y"
02974 {
02975 set_location(yylsp[-2], yylsp[0]);
02976 yyval.stmt = new EventStmt(yyvsp[-1].event_expr);
02977 }
02978 break;
02979
02980 case 168:
02981 #line 997 "parse.y"
02982 {
02983 set_location(yylsp[-4], yylsp[-1]);
02984 yyval.stmt = new IfStmt(yyvsp[-2].expr, yyvsp[0].stmt, new NullStmt());
02985 }
02986 break;
02987
02988 case 169:
02989 #line 1003 "parse.y"
02990 {
02991 set_location(yylsp[-6], yylsp[-3]);
02992 yyval.stmt = new IfStmt(yyvsp[-4].expr, yyvsp[-2].stmt, yyvsp[0].stmt);
02993 }
02994 break;
02995
02996 case 170:
02997 #line 1009 "parse.y"
02998 {
02999 set_location(yylsp[-4], yylsp[-3]);
03000 yyval.stmt = new SwitchStmt(yyvsp[-3].expr, yyvsp[-1].case_l);
03001 }
03002 break;
03003
03004 case 171:
03005 #line 1015 "parse.y"
03006 { yyvsp[-1].stmt->AsForStmt()->AddBody(yyvsp[0].stmt); }
03007 break;
03008
03009 case 172:
03010 #line 1018 "parse.y"
03011 {
03012 set_location(yylsp[-1], yylsp[0]);
03013 yyval.stmt = new NextStmt;
03014 }
03015 break;
03016
03017 case 173:
03018 #line 1024 "parse.y"
03019 {
03020 set_location(yylsp[-1], yylsp[0]);
03021 yyval.stmt = new BreakStmt;
03022 }
03023 break;
03024
03025 case 174:
03026 #line 1030 "parse.y"
03027 {
03028 set_location(yylsp[-1], yylsp[0]);
03029 yyval.stmt = new ReturnStmt(0);
03030 }
03031 break;
03032
03033 case 175:
03034 #line 1036 "parse.y"
03035 {
03036 set_location(yylsp[-2], yylsp[-1]);
03037 yyval.stmt = new ReturnStmt(yyvsp[-1].expr);
03038 }
03039 break;
03040
03041 case 176:
03042 #line 1042 "parse.y"
03043 {
03044 set_location(yylsp[-2], yylsp[0]);
03045 yyval.stmt = new AddStmt(yyvsp[-1].expr);
03046 }
03047 break;
03048
03049 case 177:
03050 #line 1048 "parse.y"
03051 {
03052 set_location(yylsp[-2], yylsp[0]);
03053 yyval.stmt = new DelStmt(yyvsp[-1].expr);
03054 }
03055 break;
03056
03057 case 178:
03058 #line 1054 "parse.y"
03059 {
03060 set_location(yylsp[-6], yylsp[0]);
03061 yyval.stmt = add_local(yyvsp[-5].id, yyvsp[-4].type, yyvsp[-3].ic, yyvsp[-2].expr, yyvsp[-1].attr_l, VAR_REGULAR);
03062 }
03063 break;
03064
03065 case 179:
03066 #line 1060 "parse.y"
03067 {
03068 set_location(yylsp[-6], yylsp[-1]);
03069 yyval.stmt = add_local(yyvsp[-5].id, yyvsp[-4].type, yyvsp[-3].ic, yyvsp[-2].expr, yyvsp[-1].attr_l, VAR_CONST);
03070 }
03071 break;
03072
03073 case 180:
03074 #line 1066 "parse.y"
03075 {
03076 set_location(yylsp[-1], yylsp[0]);
03077 yyval.stmt = new ExprStmt(yyvsp[-1].expr);
03078 }
03079 break;
03080
03081 case 181:
03082 #line 1072 "parse.y"
03083 {
03084 set_location(yylsp[0], yylsp[0]);
03085 yyval.stmt = new NullStmt;
03086 }
03087 break;
03088
03089 case 182:
03090 #line 1078 "parse.y"
03091 { yyval.stmt = new NullStmt; }
03092 break;
03093
03094 case 183:
03095 #line 1083 "parse.y"
03096 {
03097 set_location(yylsp[-1], yylsp[0]);
03098 yyvsp[-1].stmt->AsStmtList()->Stmts().append(yyvsp[0].stmt);
03099 }
03100 break;
03101
03102 case 184:
03103 #line 1088 "parse.y"
03104 { yyval.stmt = new StmtList(); }
03105 break;
03106
03107 case 185:
03108 #line 1093 "parse.y"
03109 {
03110 set_location(yylsp[-3], yylsp[0]);
03111 yyval.event_expr = new EventExpr(yyvsp[-3].str, yyvsp[-1].list);
03112 }
03113 break;
03114
03115 case 186:
03116 #line 1101 "parse.y"
03117 { yyvsp[-1].case_l->append(yyvsp[0].c_case); }
03118 break;
03119
03120 case 187:
03121 #line 1103 "parse.y"
03122 { yyval.case_l = new case_list; }
03123 break;
03124
03125 case 188:
03126 #line 1108 "parse.y"
03127 { yyval.c_case = new Case(yyvsp[-2].list, yyvsp[0].stmt); }
03128 break;
03129
03130 case 189:
03131 #line 1111 "parse.y"
03132 { yyval.c_case = new Case(0, yyvsp[0].stmt); }
03133 break;
03134
03135 case 190:
03136 #line 1116 "parse.y"
03137 {
03138 set_location(yylsp[-5], yylsp[0]);
03139
03140
03141
03142
03143
03144 ID* loop_var = lookup_ID(yyvsp[-3].str, current_module.c_str());
03145
03146 if ( loop_var )
03147 {
03148 if ( loop_var->IsGlobal() )
03149 loop_var->Error("global used in for loop");
03150 }
03151
03152 else
03153 loop_var = install_ID(yyvsp[-3].str, current_module.c_str(),
03154 false, false);
03155
03156 id_list* loop_vars = new id_list;
03157 loop_vars->append(loop_var);
03158
03159 yyval.stmt = new ForStmt(loop_vars, yyvsp[-1].expr);
03160 }
03161 break;
03162
03163 case 191:
03164 #line 1142 "parse.y"
03165 { yyval.stmt = new ForStmt(yyvsp[-4].id_l, yyvsp[-1].expr); }
03166 break;
03167
03168 case 192:
03169 #line 1147 "parse.y"
03170 { yyvsp[-2].id_l->append(yyvsp[0].id); }
03171 break;
03172
03173 case 193:
03174 #line 1149 "parse.y"
03175 {
03176 yyval.id_l = new id_list;
03177 yyval.id_l->append(yyvsp[0].id);
03178 }
03179 break;
03180
03181 case 194:
03182 #line 1157 "parse.y"
03183 {
03184 set_location(yylsp[0]);
03185
03186 yyval.id = lookup_ID(yyvsp[0].str, current_module.c_str());
03187 if ( yyval.id )
03188 {
03189 if ( yyval.id->IsGlobal() )
03190 yyval.id->Error("already a global identifier");
03191 delete [] yyvsp[0].str;
03192 }
03193
03194 else
03195 {
03196 yyval.id = install_ID(yyvsp[0].str, current_module.c_str(),
03197 false, is_export);
03198 }
03199 }
03200 break;
03201
03202 case 195:
03203 #line 1177 "parse.y"
03204 { resolving_global_ID = 1; }
03205 break;
03206
03207 case 196:
03208 #line 1178 "parse.y"
03209 { yyval.id = yyvsp[0].id; }
03210 break;
03211
03212 case 197:
03213 #line 1182 "parse.y"
03214 { resolving_global_ID = 0; }
03215 break;
03216
03217 case 198:
03218 #line 1183 "parse.y"
03219 { yyval.id = yyvsp[0].id; }
03220 break;
03221
03222 case 199:
03223 #line 1188 "parse.y"
03224 {
03225 set_location(yylsp[0]);
03226
03227 yyval.id = lookup_ID(yyvsp[0].str, current_module.c_str(), false);
03228 if ( yyval.id )
03229 {
03230 if ( ! yyval.id->IsGlobal() )
03231 yyval.id->Error("already a local identifier");
03232
03233 delete [] yyvsp[0].str;
03234 }
03235
03236 else
03237 {
03238 const char* module_name =
03239 resolving_global_ID ?
03240 current_module.c_str() : 0;
03241
03242 yyval.id = install_ID(yyvsp[0].str, module_name,
03243 true, is_export);
03244 }
03245 }
03246 break;
03247
03248 case 200:
03249 #line 1215 "parse.y"
03250 {
03251 set_location(yylsp[0]);
03252 yyval.id = lookup_ID(yyvsp[0].str, current_module.c_str());
03253 if ( ! yyval.id )
03254 error("identifier not defined:", yyvsp[0].str);
03255 delete [] yyvsp[0].str;
03256 }
03257 break;
03258
03259
03260 }
03261
03262
03263 #line 3264 "y.tab.c"
03264
03265 yyvsp -= yylen;
03266 yyssp -= yylen;
03267 yylsp -= yylen;
03268
03269 YY_STACK_PRINT (yyss, yyssp);
03270
03271 *++yyvsp = yyval;
03272 *++yylsp = yyloc;
03273
03274
03275
03276
03277
03278 yyn = yyr1[yyn];
03279
03280 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
03281 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
03282 yystate = yytable[yystate];
03283 else
03284 yystate = yydefgoto[yyn - YYNTOKENS];
03285
03286 goto yynewstate;
03287
03288
03289
03290
03291
03292 yyerrlab:
03293
03294 if (!yyerrstatus)
03295 {
03296 ++yynerrs;
03297 #if YYERROR_VERBOSE
03298 yyn = yypact[yystate];
03299
03300 if (YYPACT_NINF < yyn && yyn < YYLAST)
03301 {
03302 YYSIZE_T yysize = 0;
03303 int yytype = YYTRANSLATE (yychar);
03304 const char* yyprefix;
03305 char *yymsg;
03306 int yyx;
03307
03308
03309
03310 int yyxbegin = yyn < 0 ? -yyn : 0;
03311
03312
03313 int yychecklim = YYLAST - yyn;
03314 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
03315 int yycount = 0;
03316
03317 yyprefix = ", expecting ";
03318 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
03319 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
03320 {
03321 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
03322 yycount += 1;
03323 if (yycount == 5)
03324 {
03325 yysize = 0;
03326 break;
03327 }
03328 }
03329 yysize += (sizeof ("syntax error, unexpected ")
03330 + yystrlen (yytname[yytype]));
03331 yymsg = (char *) YYSTACK_ALLOC (yysize);
03332 if (yymsg != 0)
03333 {
03334 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
03335 yyp = yystpcpy (yyp, yytname[yytype]);
03336
03337 if (yycount < 5)
03338 {
03339 yyprefix = ", expecting ";
03340 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
03341 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
03342 {
03343 yyp = yystpcpy (yyp, yyprefix);
03344 yyp = yystpcpy (yyp, yytname[yyx]);
03345 yyprefix = " or ";
03346 }
03347 }
03348 yyerror (yymsg);
03349 YYSTACK_FREE (yymsg);
03350 }
03351 else
03352 yyerror ("syntax error; also virtual memory exhausted");
03353 }
03354 else
03355 #endif
03356 yyerror ("syntax error");
03357 }
03358
03359 yylerrsp = yylsp;
03360
03361 if (yyerrstatus == 3)
03362 {
03363
03364
03365
03366 if (yychar <= YYEOF)
03367 {
03368
03369
03370 if (yychar == YYEOF)
03371 for (;;)
03372 {
03373 YYPOPSTACK;
03374 if (yyssp == yyss)
03375 YYABORT;
03376 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
03377 yydestruct (yystos[*yyssp], yyvsp, yylsp);
03378 }
03379 }
03380 else
03381 {
03382 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
03383 yydestruct (yytoken, &yylval, &yylloc);
03384 yychar = YYEMPTY;
03385 *++yylerrsp = yylloc;
03386 }
03387 }
03388
03389
03390
03391 goto yyerrlab1;
03392
03393
03394
03395
03396
03397 yyerrorlab:
03398
03399 #ifdef __GNUC__
03400
03401
03402 if (0)
03403 goto yyerrorlab;
03404 #endif
03405
03406 yyvsp -= yylen;
03407 yyssp -= yylen;
03408 yystate = *yyssp;
03409 yylerrsp = yylsp;
03410 *++yylerrsp = yyloc;
03411 yylsp -= yylen;
03412 goto yyerrlab1;
03413
03414
03415
03416
03417
03418 yyerrlab1:
03419 yyerrstatus = 3;
03420
03421 for (;;)
03422 {
03423 yyn = yypact[yystate];
03424 if (yyn != YYPACT_NINF)
03425 {
03426 yyn += YYTERROR;
03427 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
03428 {
03429 yyn = yytable[yyn];
03430 if (0 < yyn)
03431 break;
03432 }
03433 }
03434
03435
03436 if (yyssp == yyss)
03437 YYABORT;
03438
03439 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
03440 yydestruct (yystos[yystate], yyvsp, yylsp);
03441 YYPOPSTACK;
03442 yystate = *yyssp;
03443 YY_STACK_PRINT (yyss, yyssp);
03444 }
03445
03446 if (yyn == YYFINAL)
03447 YYACCEPT;
03448
03449 YYDPRINTF ((stderr, "Shifting error token, "));
03450
03451 *++yyvsp = yylval;
03452 YYLLOC_DEFAULT (yyloc, yylsp, yylerrsp - yylsp);
03453 *++yylsp = yyloc;
03454
03455 yystate = yyn;
03456 goto yynewstate;
03457
03458
03459
03460
03461
03462 yyacceptlab:
03463 yyresult = 0;
03464 goto yyreturn;
03465
03466
03467
03468
03469 yyabortlab:
03470 yyresult = 1;
03471 goto yyreturn;
03472
03473 #ifndef yyoverflow
03474
03475
03476
03477 yyoverflowlab:
03478 yyerror ("parser stack overflow");
03479 yyresult = 2;
03480
03481 #endif
03482
03483 yyreturn:
03484 #ifndef yyoverflow
03485 if (yyss != yyssa)
03486 YYSTACK_FREE (yyss);
03487 #endif
03488 return yyresult;
03489 }
|