flush
[m6w6/ext-psi] / src / parser_proc.y
index 5713c85d2481b41f4db1b5590afeb6dc3c62ca36..d82a90f6f9d2986a03d4e161d1e962544f34f234 100644 (file)
@@ -2,6 +2,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include "parser.h"
 
@@ -27,7 +28,7 @@ void psi_error(int, const char *, int, const char *, ...);
 %nonassoc NAME.
 %left PLUS MINUS.
 %left SLASH ASTERISK.
-%fallback NAME TEMP FREE SET LET RETURN LIB INT UNSIGNED.
+%fallback NAME TEMP FREE SET LET RETURN LIB INT LONG SIGNED UNSIGNED.
 
 file ::= blocks.
 
@@ -244,20 +245,31 @@ decl_type(type_) ::= decl_type_token(T). {
        type_->token = T;
 }
 /* unsigned, urgh */
-decl_type(type_) ::= UNSIGNED NAME(T). {
+decl_type(type_) ::= UNSIGNED(U) NAME(N). {
+       PSI_Token *T = PSI_TokenCat(2, U, N);
        type_ = init_decl_type(T->type, T->text);
        type_->token = T;
-       type_->name = realloc(type_->name, T->size + sizeof("unsigned"));
-       memmove(type_->name + sizeof("unsigned"), type_->name, T->size);
-       memcpy(type_->name, "unsigned", sizeof("unsigned")-1);
-       type_->name[sizeof("unsigned")] = ' ';
-       type_->name[T->size + sizeof("unsigned")] = 0;
+       free(U);
+       free(N);
+}
+decl_type(type_) ::= SIGNED NAME(T). {
+       type_ = init_decl_type(T->type, T->text);
+       type_->token = T;
+       type_->name = realloc(type_->name, T->size + sizeof("signed"));
+       memmove(type_->name + sizeof("signed"), type_->name, T->size);
+       memcpy(type_->name, "signed", sizeof("signed")-1);
+       type_->name[sizeof("signed")] = ' ';
+       type_->name[T->size + sizeof("signed")] = 0;
 }
-/* we have to support plain int here because we have it in our lexer rules */
+/* we have to support plain int, long here because we have it in our lexer rules */
 decl_type(type_) ::= INT(T). {
        type_ = init_decl_type(PSI_T_NAME, T->text);
        type_->token = T;
 }
+decl_type(type_) ::= LONG INT(T). {
+       type_ = init_decl_type(PSI_T_NAME, T->text);
+       type_->token = T;
+}
 /* structs ! */
 decl_type(type_) ::= STRUCT(S) NAME(T). {
        type_ = init_decl_type(S->type, T->text);