%token_prefix PSI_T_
%token_type {PSI_Token *}
%token_destructor {free($$);}
+%default_destructor {(void)P;}
%extra_argument {PSI_Parser *P}
/* TOKEN is defined inside syntax_error */
%syntax_error {
block ::= decl_typedef(def). {
P->defs = add_decl_typedef(P->defs, def);
}
+block ::= constant(constant). {
+ P->consts = add_constant(P->consts, constant);
+}
+
+%type const_type {const_type*}
+const_type(type_) ::= BOOL(T). {
+ type_ = init_const_type(T->type, T->text);
+ free(T);
+}
+const_type(type_) ::= INT(T). {
+ type_ = init_const_type(T->type, T->text);
+ free(T);
+}
+const_type(type_) ::= FLOAT(T). {
+ type_ = init_const_type(T->type, T->text);
+ free(T);
+}
+const_type(type_) ::= STRING(T). {
+ type_ = init_const_type(T->type, T->text);
+ free(T);
+}
+%type constant {constant*}
+constant(constant) ::= CONST const_type(type) NSNAME(T) EQUALS impl_def_val(val) EOS. {
+ constant = init_constant(type, T->text, val);
+ free(T);
+}
%type decl_typedef {decl_typedef*}
decl_typedef(def) ::= TYPEDEF NAME(ALIAS) decl_type(type) EOS. {
%type decl_abi {decl_abi*}
decl_abi(abi) ::= NAME(T). {
abi = init_decl_abi(T->text);
+ free(T);
}
%type decl_var {decl_var*}
decl_var(var) ::= NAME(T). {
- var = init_decl_var(T->text, 0);
+ var = init_decl_var(T->text, 0, 0);
free(T);
}
decl_var(var) ::= pointers(p) NAME(T). {
- var = init_decl_var(T->text, p);
+ var = init_decl_var(T->text, p, 0);
+ free(T);
+}
+decl_var(var) ::= NAME(T) LBRACKET NUMBER(D) RBRACKET. {
+ var = init_decl_var(T->text, 1, atol(D->text));
+ free(T);
+ free(D);
+}
+decl_var(var) ::= pointers(p) NAME(T) LBRACKET DIGITS(D) RBRACKET. {
+ var = init_decl_var(T->text, p+1, atol(D->text));
free(T);
+ free(D);
}
%type decl_vars {decl_vars*}
}
%type impl {impl*}
+%destructor impl {free_impl($$);}
impl(impl) ::= impl_func(func) LBRACE impl_stmts(stmts) RBRACE. {
impl = init_impl(func, stmts);
}
%type impl_def_val {impl_def_val*}
impl_def_val(def) ::= NULL(T). {
def = init_impl_def_val(T);
+ free(T);
}
impl_def_val(def) ::= NUMBER(T). {
def = init_impl_def_val(T);
+ free(T);
}
impl_def_val(def) ::= TRUE(T). {
def = init_impl_def_val(T);
+ free(T);
}
impl_def_val(def) ::= FALSE(T). {
def = init_impl_def_val(T);
+ free(T);
}
impl_def_val(def) ::= QUOTED_STRING(T). {
def = init_impl_def_val(T);
+ free(T);
}
%type impl_var {impl_var*}
}
%type impl_stmts {impl_stmts*}
+%destructor impl_stmts {free_impl_stmts($$);}
impl_stmts(stmts) ::= impl_stmt(stmt). {
stmts = init_impl_stmts(stmt);
}
}
%type impl_stmt {impl_stmt*}
+%destructor impl_stmt {free_impl_stmt($$);}
impl_stmt(stmt) ::= let_stmt(let). {
stmt = init_impl_stmt(PSI_T_LET, let);
}