Merge branch 'master' into floatcvt
# Conflicts: # src/g_doom/a_revenant.cpp
This commit is contained in:
commit
11e613f578
7 changed files with 1542 additions and 1061 deletions
|
|
@ -90,7 +90,7 @@ static void SetNodeLine(ZCC_TreeNode *name, int line)
|
|||
for (int j = 1; j < YYERRORSYMBOL; ++j)
|
||||
{
|
||||
int k = i + j;
|
||||
if (k >= 0 && k < YY_SZ_ACTTAB && yy_lookahead[k] == j)
|
||||
if (k >= 0 && k < YY_ACTTAB_COUNT && yy_lookahead[k] == j)
|
||||
{
|
||||
expecting << (expecting.IsEmpty() ? "Expecting " : " or ") << ZCCTokenName(j);
|
||||
}
|
||||
|
|
@ -128,15 +128,15 @@ main ::= translation_unit(A). { stat->TopNode = A; stat->sc.ScriptMessage("Parse
|
|||
|
||||
%type translation_unit {ZCC_TreeNode *}
|
||||
translation_unit(X) ::= . { X = NULL; }
|
||||
translation_unit(X) ::= translation_unit(A) external_declaration(B). { SAFE_APPEND(A,B); X = A; }
|
||||
translation_unit(X) ::= translation_unit(A) EOF. { X = A; }
|
||||
translation_unit(X) ::= translation_unit(X) external_declaration(B). { SAFE_APPEND(X,B); }
|
||||
translation_unit(X) ::= translation_unit(X) EOF.
|
||||
translation_unit(X) ::= error. { X = NULL; }
|
||||
|
||||
%type external_declaration {ZCC_TreeNode *}
|
||||
external_declaration(X) ::= class_definition(A). { X = A; }
|
||||
external_declaration(X) ::= struct_def(A). { X = A; }
|
||||
external_declaration(X) ::= enum_def(A). { X = A; }
|
||||
external_declaration(X) ::= const_def(A). { X = A; }
|
||||
external_declaration(X) ::= class_definition(A). { X = A; /*X-overwrites-A*/ }
|
||||
external_declaration(X) ::= struct_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
external_declaration(X) ::= enum_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
external_declaration(X) ::= const_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
/* Optional bits. */
|
||||
opt_semicolon ::= .
|
||||
|
|
@ -150,10 +150,7 @@ opt_expr(X) ::= .
|
|||
{
|
||||
X = NULL;
|
||||
}
|
||||
opt_expr(X) ::= expr(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
opt_expr(X) ::= expr(X).
|
||||
|
||||
|
||||
/************ Class Definition ************/
|
||||
|
|
@ -168,7 +165,7 @@ opt_expr(X) ::= expr(A).
|
|||
class_definition(X) ::= class_head(A) class_body(B).
|
||||
{
|
||||
A->Body = B;
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
|
||||
class_head(X) ::= CLASS(T) IDENTIFIER(A) class_ancestry(B) class_flags(C).
|
||||
|
|
@ -183,7 +180,7 @@ class_head(X) ::= CLASS(T) IDENTIFIER(A) class_ancestry(B) class_flags(C).
|
|||
|
||||
%type class_ancestry{ZCC_Identifier *}
|
||||
class_ancestry(X) ::= . { X = NULL; }
|
||||
class_ancestry(X) ::= COLON dottable_id(A). { X = A; }
|
||||
class_ancestry(X) ::= COLON dottable_id(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
%type class_flags{ClassFlagsBlock}
|
||||
class_flags(X) ::= . { X.Flags = 0; X.Replaces = NULL; }
|
||||
|
|
@ -207,7 +204,7 @@ dottable_id(X) ::= dottable_id(A) DOT IDENTIFIER(B).
|
|||
NEW_AST_NODE(Identifier,id2,A);
|
||||
id2->Id = B.Name();
|
||||
A->AppendSibling(id2);
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
|
||||
/*------ Class Body ------*/
|
||||
|
|
@ -220,23 +217,23 @@ dottable_id(X) ::= dottable_id(A) DOT IDENTIFIER(B).
|
|||
// * constants
|
||||
// * defaults
|
||||
|
||||
class_body(X) ::= SEMICOLON class_innards(A) EOF. { X = A; }
|
||||
class_body(X) ::= LBRACE class_innards(A) RBRACE. { X = A; }
|
||||
class_body(X) ::= SEMICOLON class_innards(A) EOF. { X = A; /*X-overwrites-A*/ }
|
||||
class_body(X) ::= LBRACE class_innards(A) RBRACE. { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
class_innards(X) ::= . { X = NULL; }
|
||||
class_innards(X) ::= class_innards(A) class_member(B). { SAFE_APPEND(A,B); X = A; }
|
||||
class_innards(X) ::= class_innards(X) class_member(B). { SAFE_APPEND(X,B); }
|
||||
|
||||
%type struct_def{ZCC_Struct *}
|
||||
%type enum_def {ZCC_Enum *}
|
||||
%type states_def {ZCC_States *}
|
||||
%type const_def {ZCC_ConstantDef *}
|
||||
|
||||
class_member(X) ::= declarator(A). { X = A; }
|
||||
class_member(X) ::= enum_def(A). { X = A; }
|
||||
class_member(X) ::= struct_def(A). { X = A; }
|
||||
class_member(X) ::= states_def(A). { X = A; }
|
||||
class_member(X) ::= default_def(A). { X = A; }
|
||||
class_member(X) ::= const_def(A). { X = A; }
|
||||
class_member(X) ::= declarator(A). { X = A; /*X-overwrites-A*/ }
|
||||
class_member(X) ::= enum_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
class_member(X) ::= struct_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
class_member(X) ::= states_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
class_member(X) ::= default_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
class_member(X) ::= const_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
/*----- Struct Definition -----*/
|
||||
/* Structs can define variables and enums. */
|
||||
|
|
@ -254,15 +251,15 @@ struct_def(X) ::= STRUCT(T) IDENTIFIER(A) LBRACE opt_struct_body(B) RBRACE opt_s
|
|||
}
|
||||
|
||||
opt_struct_body(X) ::= . { X = NULL; }
|
||||
opt_struct_body(X) ::= struct_body(A). { X = A; }
|
||||
opt_struct_body(X) ::= struct_body(X).
|
||||
|
||||
struct_body(X) ::= error. { X = NULL; }
|
||||
struct_body(X) ::= struct_member(A). { X = A; }
|
||||
struct_body(X) ::= struct_member(A) struct_body(B). { X = A; A->AppendSibling(B); }
|
||||
struct_body(X) ::= struct_member(X).
|
||||
struct_body(X) ::= struct_member(A) struct_body(B). { X = A; /*X-overwrites-A*/ X->AppendSibling(B); }
|
||||
|
||||
struct_member(X) ::= declarator_no_fun(A). { X = A; }
|
||||
struct_member(X) ::= enum_def(A). { X = A; }
|
||||
struct_member(X) ::= const_def(A). { X = A; }
|
||||
struct_member(X) ::= declarator_no_fun(A). { X = A; /*X-overwrites-A*/ }
|
||||
struct_member(X) ::= enum_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
struct_member(X) ::= const_def(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
/*----- Constant Definition ------*/
|
||||
/* Like UnrealScript, a constant's type is implied by its value's type. */
|
||||
|
|
@ -343,14 +340,14 @@ enum_def(X) ::= ENUM(T) IDENTIFIER(A) enum_type(B) LBRACE opt_enum_list(C) RBRAC
|
|||
}
|
||||
|
||||
enum_type(X) ::= . { X.Int = ZCC_IntAuto; X.SourceLoc = stat->sc.GetMessageLine(); }
|
||||
enum_type(X) ::= COLON int_type(A). { X = A; }
|
||||
enum_type(X) ::= COLON int_type(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
enum_list(X) ::= error. { X = NULL; }
|
||||
enum_list(X) ::= enumerator(A). { X = A; }
|
||||
enum_list(X) ::= enum_list(A) COMMA enumerator(B). { X = A; A->AppendSibling(B); }
|
||||
enum_list(X) ::= enumerator(X).
|
||||
enum_list(X) ::= enum_list(A) COMMA enumerator(B). { X = A; /*X-overwrites-A*/ X->AppendSibling(B); }
|
||||
|
||||
opt_enum_list(X) ::= . { X = NULL; }
|
||||
opt_enum_list(X) ::= enum_list(A) opt_comma. { X = A; }
|
||||
opt_enum_list(X) ::= enum_list(X) opt_comma.
|
||||
|
||||
enumerator(X) ::= IDENTIFIER(A).
|
||||
{
|
||||
|
|
@ -405,9 +402,9 @@ scanner_mode ::= . { stat->sc.SetStateMode(true); }
|
|||
|
||||
states_body(X) ::= . { X = NULL; }
|
||||
states_body(X) ::= error. { X = NULL; }
|
||||
states_body(X) ::= states_body(A) state_line(B). { SAFE_APPEND(A,B); X = A; }
|
||||
states_body(X) ::= states_body(A) state_label(B). { SAFE_APPEND(A,B); X = A; }
|
||||
states_body(X) ::= states_body(A) state_flow(B). { SAFE_APPEND(A,B); X = A; }
|
||||
states_body(X) ::= states_body(X) state_line(B). { SAFE_APPEND(X,B); }
|
||||
states_body(X) ::= states_body(X) state_label(B). { SAFE_APPEND(X,B); }
|
||||
states_body(X) ::= states_body(X) state_flow(B). { SAFE_APPEND(X,B); }
|
||||
|
||||
state_label(X) ::= NWS(A) COLON.
|
||||
{
|
||||
|
|
@ -416,7 +413,7 @@ state_label(X) ::= NWS(A) COLON.
|
|||
X = label;
|
||||
}
|
||||
|
||||
state_flow(X) ::= state_flow_type(A) scanner_mode SEMICOLON. { X = A; }
|
||||
state_flow(X) ::= state_flow_type(X) scanner_mode SEMICOLON.
|
||||
|
||||
state_flow_type(X) ::= STOP(A). { NEW_AST_NODE(StateStop, flow, A); X = flow; }
|
||||
state_flow_type(X) ::= WAIT(A). { NEW_AST_NODE(StateWait, flow, A); X = flow; }
|
||||
|
|
@ -431,7 +428,7 @@ state_flow_type(X) ::= GOTO(T) dottable_id(A) state_goto_offset(B).
|
|||
}
|
||||
|
||||
state_goto_offset(X) ::= . { X = NULL; }
|
||||
state_goto_offset(X) ::= PLUS expr(A). { X = A; } /* Must evaluate to a non-negative integer constant. */
|
||||
state_goto_offset(X) ::= PLUS expr(A). { X = A; /*X-overwrites-A*/ } /* Must evaluate to a non-negative integer constant. */
|
||||
|
||||
state_line(X) ::= NWS(A) NWS(B) expr state_opts(C) state_action(D).
|
||||
{
|
||||
|
|
@ -457,21 +454,21 @@ state_line(X) ::= NWS(A) NWS(B) expr state_opts(C) state_action(D).
|
|||
}
|
||||
|
||||
state_opts(X) ::= . { StateOpts opts; opts.Zero(); X = opts; }
|
||||
state_opts(X) ::= state_opts(A) BRIGHT. { A.Bright = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) FAST. { A.Fast = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) SLOW. { A.Slow = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) NODELAY. { A.NoDelay = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) CANRAISE. { A.CanRaise = true; X = A; }
|
||||
state_opts(X) ::= state_opts(A) OFFSET LPAREN expr(B) COMMA expr(C) RPAREN. { A.Offset = B; B->AppendSibling(C); X = A; }
|
||||
state_opts(X) ::= state_opts(A) LIGHT LPAREN light_list RPAREN. { X = A; } ///FIXME: GZDoom would want to know this
|
||||
state_opts(X) ::= state_opts(A) BRIGHT. { A.Bright = true; X = A; /*X-overwrites-A*/ }
|
||||
state_opts(X) ::= state_opts(A) FAST. { A.Fast = true; X = A; /*X-overwrites-A*/ }
|
||||
state_opts(X) ::= state_opts(A) SLOW. { A.Slow = true; X = A; /*X-overwrites-A*/ }
|
||||
state_opts(X) ::= state_opts(A) NODELAY. { A.NoDelay = true; X = A; /*X-overwrites-A*/ }
|
||||
state_opts(X) ::= state_opts(A) CANRAISE. { A.CanRaise = true; X = A; /*X-overwrites-A*/ }
|
||||
state_opts(X) ::= state_opts(A) OFFSET LPAREN expr(B) COMMA expr(C) RPAREN. { A.Offset = B; B->AppendSibling(C); X = A; /*X-overwrites-A*/ }
|
||||
state_opts(X) ::= state_opts(A) LIGHT LPAREN light_list RPAREN. { X = A; /*X-overwrites-A*/ } ///FIXME: GZDoom would want to know this
|
||||
|
||||
light_list ::= STRCONST.
|
||||
light_list ::= light_list COMMA STRCONST.
|
||||
|
||||
/* A state action can be either a compound statement or a single action function call. */
|
||||
state_action(X) ::= LBRACE statement_list(A) scanner_mode RBRACE. { X = A; }
|
||||
state_action(X) ::= LBRACE statement_list(A) scanner_mode RBRACE. { X = A; /*X-overwrites-A*/ }
|
||||
state_action(X) ::= LBRACE error scanner_mode RBRACE. { X = NULL; }
|
||||
state_action(X) ::= state_call(A) scanner_mode SEMICOLON. { X = A; }
|
||||
state_action(X) ::= state_call(A) scanner_mode SEMICOLON. { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
state_call(X) ::= . { X = NULL; }
|
||||
state_call(X) ::= IDENTIFIER(A) state_call_params(B).
|
||||
|
|
@ -488,11 +485,11 @@ state_call(X) ::= IDENTIFIER(A) state_call_params(B).
|
|||
}
|
||||
|
||||
state_call_params(X) ::= . { X = NULL; }
|
||||
state_call_params(X) ::= LPAREN func_expr_list(A) RPAREN. { X = A; }
|
||||
state_call_params(X) ::= LPAREN func_expr_list(A) RPAREN. { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
/* Definition of a default class instance. */
|
||||
%type default_def {ZCC_CompoundStmt *}
|
||||
default_def(X) ::= DEFAULT compound_statement(A). { X = A; }
|
||||
default_def(X) ::= DEFAULT compound_statement(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
/* Type names */
|
||||
%type type_name {ZCC_BasicType *}
|
||||
|
|
@ -505,7 +502,7 @@ int_type(X) ::= INT(T). { X.Int = ZCC_SInt32; X.SourceLoc = T.SourceLoc; }
|
|||
int_type(X) ::= UINT(T). { X.Int = ZCC_UInt32; X.SourceLoc = T.SourceLoc; }
|
||||
|
||||
type_name1(X) ::= BOOL(T). { X.Int = ZCC_Bool; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= int_type(A). { X = A; }
|
||||
type_name1(X) ::= int_type(X).
|
||||
type_name1(X) ::= FLOAT(T). { X.Int = ZCC_FloatAuto; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= DOUBLE(T). { X.Int = ZCC_Float64; X.SourceLoc = T.SourceLoc; }
|
||||
type_name1(X) ::= STRING(T). { X.Int = ZCC_String; X.SourceLoc = T.SourceLoc; }
|
||||
|
|
@ -540,6 +537,7 @@ type_name(X) ::= DOT dottable_id(A).
|
|||
* (Well, actually, I'm not sure if 4D ones are going to happen
|
||||
* straight away.)
|
||||
*/
|
||||
%token_class intconst INTCONST|UINTCONST.
|
||||
vector_size(X) ::= . { X.Int = ZCC_Vector3; X.SourceLoc = stat->sc.GetMessageLine(); }
|
||||
vector_size(X) ::= LT intconst(A) GT.
|
||||
{
|
||||
|
|
@ -554,8 +552,6 @@ vector_size(X) ::= LT intconst(A) GT.
|
|||
}
|
||||
X.SourceLoc = A.SourceLoc;
|
||||
}
|
||||
intconst(X) ::= INTCONST(A). { X = A; }
|
||||
intconst(X) ::= UINTCONST(A). { X = A; }
|
||||
|
||||
/* Type names can also be used as identifiers in contexts where type names
|
||||
* are not normally allowed. */
|
||||
|
|
@ -594,19 +590,19 @@ aggregate_type(X) ::= CLASS(T) class_restrictor(A). /* class<type> */
|
|||
X = cls;
|
||||
}
|
||||
class_restrictor(X) ::= . { X = NULL; }
|
||||
class_restrictor(X) ::= LT dottable_id(A) GT. { X = A; }
|
||||
class_restrictor(X) ::= LT dottable_id(A) GT. { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
type(X) ::= type_name(A). { X = A; A->ArraySize = NULL; }
|
||||
type(X) ::= aggregate_type(A). { X = A; A->ArraySize = NULL; }
|
||||
type(X) ::= type_name(A). { X = A; /*X-overwrites-A*/ X->ArraySize = NULL; }
|
||||
type(X) ::= aggregate_type(A). { X = A; /*X-overwrites-A*/ X->ArraySize = NULL; }
|
||||
|
||||
type_or_array(X) ::= type(A). { X = A; }
|
||||
type_or_array(X) ::= type(A) array_size(B). { X = A; A->ArraySize = B; }
|
||||
type_or_array(X) ::= type(X).
|
||||
type_or_array(X) ::= type(A) array_size(B). { X = A; /*X-overwrites-A*/ X->ArraySize = B; }
|
||||
|
||||
type_list(X) ::= type_or_array(A). { X = A; }/* A comma-separated list of types */
|
||||
type_list(X) ::= type_list(A) COMMA type_or_array(B). { X = A; A->AppendSibling(B); }
|
||||
type_list(X) ::= type_or_array(X). /* A comma-separated list of types */
|
||||
type_list(X) ::= type_list(A) COMMA type_or_array(B). { X = A; /*X-overwrites-A*/ X->AppendSibling(B); }
|
||||
|
||||
type_list_or_void(X) ::= VOID. { X = NULL; }
|
||||
type_list_or_void(X) ::= type_list(A). { X = A; }
|
||||
type_list_or_void(X) ::= type_list(X).
|
||||
|
||||
array_size_expr(X) ::= LBRACKET opt_expr(A) RBRACKET.
|
||||
{
|
||||
|
|
@ -622,14 +618,11 @@ array_size_expr(X) ::= LBRACKET opt_expr(A) RBRACKET.
|
|||
X = A;
|
||||
}
|
||||
}
|
||||
array_size(X) ::= array_size_expr(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
array_size(X) ::= array_size_expr(X).
|
||||
array_size(X) ::= array_size(A) array_size_expr(B).
|
||||
{
|
||||
A->AppendSibling(B);
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
|
||||
%type variables_or_function {VarOrFun}
|
||||
|
|
@ -738,14 +731,11 @@ variable_name(X) ::= IDENTIFIER(A) array_size(B).
|
|||
X = var;
|
||||
}
|
||||
|
||||
variable_list(X) ::= variable_name(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
variable_list(X) ::= variable_name(X).
|
||||
variable_list(X) ::= variable_list(A) COMMA variable_name(B).
|
||||
{
|
||||
A->AppendSibling(B);
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
|
||||
decl_flags(X) ::= . { X.Int = 0; X.SourceLoc = 0; }
|
||||
|
|
@ -764,7 +754,7 @@ func_const(X) ::= . { X.Int = 0; X.SourceLoc = stat->sc.GetMessageLine();
|
|||
func_const(X) ::= CONST(T). { X.Int = ZCC_FuncConst; X.SourceLoc = T.SourceLoc; }
|
||||
|
||||
opt_func_body(X) ::= SEMICOLON. { X = NULL; }
|
||||
opt_func_body(X) ::= function_body(A). { X = A; }
|
||||
opt_func_body(X) ::= function_body(X).
|
||||
|
||||
%type func_params {ZCC_FuncParamDecl *}
|
||||
%type func_param_list {ZCC_FuncParamDecl *}
|
||||
|
|
@ -772,10 +762,10 @@ opt_func_body(X) ::= function_body(A). { X = A; }
|
|||
|
||||
func_params(X) ::= . /* empty */ { X = NULL; }
|
||||
func_params(X) ::= VOID. { X = NULL; }
|
||||
func_params(X) ::= func_param_list(A). { X = A; }
|
||||
func_params(X) ::= func_param_list(X).
|
||||
|
||||
func_param_list(X) ::= func_param(A). { X = A; }
|
||||
func_param_list(X) ::= func_param_list(A) COMMA func_param(B). { X = A; A->AppendSibling(B); }
|
||||
func_param_list(X) ::= func_param(X).
|
||||
func_param_list(X) ::= func_param_list(A) COMMA func_param(B). { X = A; /*X-overwrites-A*/ X->AppendSibling(B); }
|
||||
|
||||
func_param(X) ::= func_param_flags(A) type(B) IDENTIFIER(C).
|
||||
{
|
||||
|
|
@ -819,10 +809,7 @@ primary(X) ::= SUPER(T).
|
|||
expr->Type = NULL;
|
||||
X = expr;
|
||||
}
|
||||
primary(X) ::= constant(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
primary(X) ::= constant(A). { X = A; /*X-overwrites-A*/ }
|
||||
primary(X) ::= SELF(T).
|
||||
{
|
||||
NEW_AST_NODE(Expression, expr, T);
|
||||
|
|
@ -832,7 +819,7 @@ primary(X) ::= SELF(T).
|
|||
}
|
||||
primary(X) ::= LPAREN expr(A) RPAREN.
|
||||
{
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
primary ::= LPAREN error RPAREN.
|
||||
primary(X) ::= primary(A) LPAREN func_expr_list(B) RPAREN. [DOT] // Function call
|
||||
|
|
@ -881,10 +868,7 @@ primary(X) ::= SCOPE primary(B).
|
|||
*/
|
||||
/*----- Unary Expressions -----*/
|
||||
|
||||
unary_expr(X) ::= primary(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
unary_expr(X) ::= primary(X).
|
||||
unary_expr(X) ::= SUB unary_expr(A). [UNARY]
|
||||
{
|
||||
ZCC_ExprConstant *con = static_cast<ZCC_ExprConstant *>(A);
|
||||
|
|
@ -959,10 +943,7 @@ unary_expr(X) ::= ALIGNOF unary_expr(A). [UNARY]
|
|||
|
||||
/*----- Binary Expressions -----*/
|
||||
|
||||
expr(X) ::= unary_expr(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
expr(X) ::= unary_expr(X).
|
||||
expr(X) ::= expr(A) ADD expr(B). /* a + b */
|
||||
{
|
||||
BINARY_EXPR(A,B,PEX_Add);
|
||||
|
|
@ -1118,14 +1099,11 @@ expr(X) ::= expr(A) QUESTION expr(B) COLON expr(C).
|
|||
|
||||
%type expr_list{ZCC_Expression *}
|
||||
|
||||
expr_list(X) ::= expr(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
expr_list(X) ::= expr(X).
|
||||
expr_list(X) ::= expr_list(A) COMMA expr(B).
|
||||
{
|
||||
X = A;
|
||||
A->AppendSibling(B);
|
||||
X = A; /*X-overwrites-A*/
|
||||
X->AppendSibling(B);
|
||||
}
|
||||
|
||||
/*----- Function argument lists -----*/
|
||||
|
|
@ -1137,10 +1115,7 @@ expr_list(X) ::= expr_list(A) COMMA expr(B).
|
|||
%type func_expr_item{ZCC_FuncParm *}
|
||||
%type named_expr{ZCC_FuncParm *}
|
||||
|
||||
func_expr_list(X) ::= func_expr_item(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
func_expr_list(X) ::= func_expr_item(X).
|
||||
func_expr_list(X) ::= func_expr_list(A) COMMA(T) func_expr_item(B).
|
||||
{
|
||||
// Omitted parameters still need to appear as nodes in the list.
|
||||
|
|
@ -1158,18 +1133,15 @@ func_expr_list(X) ::= func_expr_list(A) COMMA(T) func_expr_item(B).
|
|||
nil_b->Label = NAME_None;
|
||||
B = nil_b;
|
||||
}
|
||||
X = A;
|
||||
A->AppendSibling(B);
|
||||
X = A; /*X-overwrites-A*/
|
||||
X->AppendSibling(B);
|
||||
}
|
||||
|
||||
func_expr_item(X) ::= .
|
||||
{
|
||||
X = NULL;
|
||||
}
|
||||
func_expr_item(X) ::= named_expr(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
func_expr_item(X) ::= named_expr(X).
|
||||
|
||||
named_expr(X) ::= IDENTIFIER(A) COLON expr(B).
|
||||
{
|
||||
|
|
@ -1208,10 +1180,7 @@ string_constant(X) ::= string_constant(A) STRCONST(B).
|
|||
X = strconst;
|
||||
}
|
||||
|
||||
constant(X) ::= string_constant(A).
|
||||
{
|
||||
X = A;
|
||||
}
|
||||
constant(X) ::= string_constant(X).
|
||||
constant(X) ::= INTCONST(A).
|
||||
{
|
||||
NEW_INTCONST_NODE(intconst, TypeSInt32, A.Int, A);
|
||||
|
|
@ -1251,18 +1220,18 @@ constant(X) ::= TRUE(A).
|
|||
|
||||
/************ Statements ************/
|
||||
|
||||
function_body(X) ::= compound_statement(A). { X = A; }
|
||||
function_body(X) ::= compound_statement(X).
|
||||
|
||||
%type statement{ZCC_Statement *}
|
||||
statement(X) ::= SEMICOLON. { X = NULL; }
|
||||
statement(X) ::= labeled_statement(A). { X = A; }
|
||||
statement(X) ::= compound_statement(A). { X = A; }
|
||||
statement(X) ::= expression_statement(A) SEMICOLON. { X = A; }
|
||||
statement(X) ::= selection_statement(A). { X = A; }
|
||||
statement(X) ::= iteration_statement(A). { X = A; }
|
||||
statement(X) ::= jump_statement(A). { X = A; }
|
||||
statement(X) ::= assign_statement(A) SEMICOLON. { X = A; }
|
||||
statement(X) ::= local_var(A) SEMICOLON. { X = A; }
|
||||
statement(X) ::= labeled_statement(A). { X = A; /*X-overwrites-A*/ }
|
||||
statement(X) ::= compound_statement(A). { X = A; /*X-overwrites-A*/ }
|
||||
statement(X) ::= expression_statement(A) SEMICOLON. { X = A; /*X-overwrites-A*/ }
|
||||
statement(X) ::= selection_statement(X).
|
||||
statement(X) ::= iteration_statement(X).
|
||||
statement(X) ::= jump_statement(X).
|
||||
statement(X) ::= assign_statement(A) SEMICOLON. { X = A; /*X-overwrites-A*/ }
|
||||
statement(X) ::= local_var(A) SEMICOLON. { X = A; /*X-overwrites-A*/ }
|
||||
statement(X) ::= error SEMICOLON. { X = NULL; }
|
||||
|
||||
/*----- Jump Statements -----*/
|
||||
|
|
@ -1318,12 +1287,11 @@ compound_statement(X) ::= LBRACE(T) error RBRACE.
|
|||
|
||||
statement_list(X) ::= statement(A).
|
||||
{
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
statement_list(X) ::= statement_list(A) statement(B).
|
||||
statement_list(X) ::= statement_list(X) statement(B).
|
||||
{
|
||||
SAFE_APPEND(A,B);
|
||||
X = A;
|
||||
SAFE_APPEND(X,B);
|
||||
}
|
||||
|
||||
/*----- Expression Statements -----*/
|
||||
|
|
@ -1407,13 +1375,13 @@ while_or_until(X) ::= UNTIL(T).
|
|||
}
|
||||
|
||||
%type for_init{ZCC_Statement *}
|
||||
for_init(X) ::= local_var(A). { X = A; }
|
||||
for_init(X) ::= for_bump(A). { X = A; }
|
||||
for_init(X) ::= local_var(A). { X = A /*X-overwrites-A*/; }
|
||||
for_init(X) ::= for_bump(A). { X = A /*X-overwrites-A*/; }
|
||||
|
||||
%type for_bump{ZCC_Statement *}
|
||||
for_bump(X) ::= . { X = NULL; }
|
||||
for_bump(X) ::= expression_statement(A). { X = A; }
|
||||
for_bump(X) ::= assign_statement(A). { X = A; }
|
||||
for_bump(X) ::= expression_statement(A). { X = A; /*X-overwrites-A*/ }
|
||||
for_bump(X) ::= assign_statement(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
||||
/*----- If Statements -----*/
|
||||
|
||||
|
|
@ -1428,12 +1396,12 @@ for_bump(X) ::= assign_statement(A). { X = A; }
|
|||
|
||||
selection_statement(X) ::= if_front(A). [IF]
|
||||
{
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
selection_statement(X) ::= if_front(A) ELSE statement(B). [ELSE]
|
||||
{
|
||||
A->FalsePath = B;
|
||||
X = A;
|
||||
X = A; /*X-overwrites-A*/
|
||||
}
|
||||
|
||||
if_front(X) ::= IF(T) LPAREN expr(A) RPAREN statement(B).
|
||||
|
|
@ -1512,4 +1480,4 @@ local_var(X) ::= type(A) variable_list(B) var_init(C).
|
|||
|
||||
%type var_init{ZCC_Expression *}
|
||||
var_init(X) ::= . { X = NULL; }
|
||||
var_init(X) ::= EQ expr_list(A). { X = A; }
|
||||
var_init(X) ::= EQ expr_list(A). { X = A; /*X-overwrites-A*/ }
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ ZCCCompiler::ZCCCompiler(ZCC_AST &ast, DObject *_outer, PSymbolTable &_symbols)
|
|||
case AST_Class: Classes.Push(static_cast<ZCC_Class *>(node)); break;
|
||||
case AST_Struct: Structs.Push(static_cast<ZCC_Struct *>(node)); break;
|
||||
case AST_ConstantDef: Constants.Push(static_cast<ZCC_ConstantDef *>(node)); break;
|
||||
default: assert(0 && "Default case is just here to make GCC happy. It should never be reached");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ private:
|
|||
ZCC_Expression *NodeFromSymbol(PSymbol *sym, ZCC_Expression *source, PSymbolTable *table);
|
||||
ZCC_ExprConstant *NodeFromSymbolConst(PSymbolConst *sym, ZCC_Expression *idnode);
|
||||
ZCC_ExprTypeRef *NodeFromSymbolType(PSymbolType *sym, ZCC_Expression *idnode);
|
||||
PSymbol *ZCCCompiler::CompileNode(ZCC_NamedNode *node);
|
||||
PSymbol *CompileNode(ZCC_NamedNode *node);
|
||||
|
||||
|
||||
void Warn(ZCC_TreeNode *node, const char *msg, ...);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue