X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fparser_proc.y;h=2fb309ea0c983cce74587517bf28eef72d28e7a8;hp=efffcf79fdc0061da00aa89c609190d9d8cb0cc1;hb=469fe3395cb9696e32bcd64639f22113d8fb2ec6;hpb=d60f4bbdd315ddf42dbafeff0fd3d87d2e7a51f7 diff --git a/src/parser_proc.y b/src/parser_proc.y index efffcf7..2fb309e 100644 --- a/src/parser_proc.y +++ b/src/parser_proc.y @@ -17,6 +17,9 @@ %syntax_error { PSI_ParserSyntaxError(P, P->fn, P->line, "Unexpected token '%s'", TOKEN->text); } + +%nonassoc NAME. + file ::= blocks. blocks ::= block. @@ -176,22 +179,6 @@ decl_type(type_) ::= VOID(T). { type_ = init_decl_type(T->type, T->text); free(T); } -decl_type(type_) ::= CHAR(T). { - type_ = init_decl_type(T->type, T->text); - free(T); -} -decl_type(type_) ::= SHORT(T). { - type_ = init_decl_type(T->type, T->text); - free(T); -} -decl_type(type_) ::= INT(T). { - type_ = init_decl_type(T->type, T->text); - free(T); -} -decl_type(type_) ::= LONG(T). { - type_ = init_decl_type(T->type, T->text); - free(T); -} decl_type(type_) ::= FLOAT(T). { type_ = init_decl_type(T->type, T->text); free(T); @@ -200,11 +187,12 @@ decl_type(type_) ::= DOUBLE(T). { type_ = init_decl_type(T->type, T->text); free(T); } -decl_type(type_) ::= SIZE_T(T). { - type_ = init_decl_type(T->type, T->text); +/* we have to support plain int here because we have it in our lexer rules */ +decl_type(type_) ::= INT(T). { + type_ = init_decl_type(PSI_T_NAME, T->text); free(T); } -decl_type(type_) ::= SINT8(T). { +decl_type(type_) ::= INT8(T). { type_ = init_decl_type(T->type, T->text); free(T); } @@ -212,7 +200,7 @@ decl_type(type_) ::= UINT8(T). { type_ = init_decl_type(T->type, T->text); free(T); } -decl_type(type_) ::= SINT16(T). { +decl_type(type_) ::= INT16(T). { type_ = init_decl_type(T->type, T->text); free(T); } @@ -220,7 +208,7 @@ decl_type(type_) ::= UINT16(T). { type_ = init_decl_type(T->type, T->text); free(T); } -decl_type(type_) ::= SINT32(T). { +decl_type(type_) ::= INT32(T). { type_ = init_decl_type(T->type, T->text); free(T); } @@ -228,7 +216,7 @@ decl_type(type_) ::= UINT32(T). { type_ = init_decl_type(T->type, T->text); free(T); } -decl_type(type_) ::= SINT64(T). { +decl_type(type_) ::= INT64(T). { type_ = init_decl_type(T->type, T->text); free(T); } @@ -240,6 +228,11 @@ decl_type(type_) ::= NAME(T). { type_ = init_decl_type(T->type, T->text); free(T); } +decl_type(type_) ::= STRUCT(S) NAME(T). { + type_ = init_decl_type(S->type, T->text); + free(S); + free(T); +} %type impl {impl*} %destructor impl {free_impl($$);} @@ -261,23 +254,23 @@ impl_func(func) ::= FUNCTION REFERENCE NSNAME(NAME) impl_args(args) COLON impl_t %type impl_def_val {impl_def_val*} %destructor impl_def_val {free_impl_def_val($$);} impl_def_val(def) ::= NULL(T). { - def = init_impl_def_val(T); + def = init_impl_def_val(T->type, T->text); free(T); } impl_def_val(def) ::= NUMBER(T). { - def = init_impl_def_val(T); + def = init_impl_def_val(T->type, T->text); free(T); } impl_def_val(def) ::= TRUE(T). { - def = init_impl_def_val(T); + def = init_impl_def_val(T->type, T->text); free(T); } impl_def_val(def) ::= FALSE(T). { - def = init_impl_def_val(T); + def = init_impl_def_val(T->type, T->text); free(T); } impl_def_val(def) ::= QUOTED_STRING(T). { - def = init_impl_def_val(T); + def = init_impl_def_val(T->type, T->text); free(T); }