mirror of
https://github.com/sigmasternchen/libargo
synced 2025-03-15 05:08:54 +00:00
added support for dynamic arrays in the parser
This commit is contained in:
parent
df3c1b7240
commit
02804efa4c
3 changed files with 20 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
struct typeinfo {
|
||||
char* type;
|
||||
bool isPointer;
|
||||
bool isArray;
|
||||
};
|
||||
|
||||
struct memberinfo {
|
||||
|
|
|
@ -6,5 +6,6 @@ void _panic(const char* f, const char* s);
|
|||
|
||||
#define WARN(msg) ("\033[33mwarning:\033[0m " msg)
|
||||
#define ERROR(msg) ("\033[31mwerror:\033[0m " msg)
|
||||
#define INFO(msg) ("\033[36minfo:\033[0m " msg)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -117,6 +117,16 @@ structmember: type ID
|
|||
{
|
||||
$$ = newMemberInfo($1, $2);
|
||||
}
|
||||
| type ID OPEN_BRACKETS NUM CLOSE_BRACKETS
|
||||
{
|
||||
yyerror(filename, ERROR("static array members not yet supported"));
|
||||
YYERROR;
|
||||
}
|
||||
| type ID OPEN_BRACKETS CLOSE_BRACKETS
|
||||
{
|
||||
yyerror(filename, ERROR("flexible array members not supported; use double pointers for dynamic array instead"));
|
||||
YYERROR;
|
||||
}
|
||||
;
|
||||
|
||||
type: STDINT { yyerror(filename, ERROR("stdint types are not yet supported")); YYERROR; }
|
||||
|
@ -134,8 +144,14 @@ type: STDINT { yyerror(filename, ERROR("stdint types are not yet supported"));
|
|||
| type POINTER
|
||||
{
|
||||
if ($1->isPointer || strcmp($1->type, "string") == 0) {
|
||||
yyerror(filename, ERROR("multiple pointer types are not supported"));
|
||||
YYERROR;
|
||||
if ($1->isArray) {
|
||||
yyerror(filename, ERROR("multi pointer types are not supported"));
|
||||
YYERROR;
|
||||
} else {
|
||||
yyerror(filename, INFO("double pointer type; assuming dynamic array"));
|
||||
$$ = $1;
|
||||
$$->isArray = true;
|
||||
}
|
||||
} else {
|
||||
$$ = newTypeInfo(true, $1->type);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue