Merge topic/actor-system throug a squashed commit.

This commit is contained in:
Robin Sommer 2018-05-16 23:48:07 +00:00
parent 7a6f5020f6
commit fe7e1ee7f0
466 changed files with 12559 additions and 9655 deletions

View file

@ -2,7 +2,10 @@
// See the file "COPYING" in the main distribution directory for copyright.
%}
%expect 78
// Switching parser table type fixes ambiguity problems.
%define lr.type ielr
%expect 142
%token TOK_ADD TOK_ADD_TO TOK_ADDR TOK_ANY
%token TOK_ATENDIF TOK_ATELSE TOK_ATIF TOK_ATIFDEF TOK_ATIFNDEF
@ -16,7 +19,7 @@
%token TOK_REMOVE_FROM TOK_RETURN TOK_SCHEDULE TOK_SET
%token TOK_STRING TOK_SUBNET TOK_SWITCH TOK_TABLE
%token TOK_TIME TOK_TIMEOUT TOK_TIMER TOK_TYPE TOK_UNION TOK_VECTOR TOK_WHEN
%token TOK_WHILE
%token TOK_WHILE TOK_AS TOK_IS
%token TOK_ATTR_ADD_FUNC TOK_ATTR_ENCRYPT TOK_ATTR_DEFAULT
%token TOK_ATTR_OPTIONAL TOK_ATTR_REDEF TOK_ATTR_ROTATE_INTERVAL
@ -44,11 +47,12 @@
%left TOK_INCR TOK_DECR
%right '!'
%left '$' '[' ']' '(' ')' TOK_HAS_FIELD TOK_HAS_ATTR
%nonassoc TOK_AS TOK_IS
%type <b> opt_no_test opt_no_test_block opt_deprecated
%type <str> TOK_ID TOK_PATTERN_TEXT single_pattern
%type <id> local_id global_id def_global_id event_id global_or_event_id resolve_id begin_func
%type <id_l> local_id_list
%type <id> local_id global_id def_global_id event_id global_or_event_id resolve_id begin_func case_type
%type <id_l> local_id_list case_type_list
%type <ic> init_class
%type <expr> opt_init
%type <val> TOK_CONSTANT
@ -705,6 +709,18 @@ expr:
set_location(@1, @3);
$$ = new SizeExpr($2);
}
| expr TOK_AS type
{
set_location(@1, @3);
$$ = new CastExpr($1, $3);
}
| expr TOK_IS type
{
set_location(@1, @3);
$$ = new IsExpr($1, $3);
}
;
expr_list:
@ -1506,12 +1522,48 @@ case_list:
case:
TOK_CASE expr_list ':' stmt_list
{ $$ = new Case($2, $4); }
{ $$ = new Case($2, 0, $4); }
|
TOK_CASE case_type_list ':' stmt_list
{ $$ = new Case(0, $2, $4); }
|
TOK_DEFAULT ':' stmt_list
{ $$ = new Case(0, $3); }
{ $$ = new Case(0, 0, $3); }
;
case_type_list:
case_type_list ',' case_type
{ $1->append($3); }
|
case_type
{
$$ = new id_list;
$$->append($1);
}
;
case_type:
TOK_TYPE type
{
$$ = new ID(0, SCOPE_FUNCTION, 0);
$$->SetType($2);
}
| TOK_TYPE type TOK_AS TOK_ID
{
const char* name = $4;
BroType* type = $2;
ID* case_var = lookup_ID(name, current_module.c_str());
if ( case_var && case_var->IsGlobal() )
case_var->Error("already a global identifier");
else
case_var = install_ID(name, current_module.c_str(), false, false);
add_local(case_var, type, INIT_NONE, 0, 0, VAR_REGULAR);
$$ = case_var;
}
for_head:
TOK_FOR '(' TOK_ID TOK_IN expr ')'
{