Fix various cppparser issues parsing the VRPN headers

This commit is contained in:
rdb 2015-11-19 18:35:29 +01:00
parent f01bd92f26
commit df4c4bc250
3 changed files with 1626 additions and 1676 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2134,48 +2134,32 @@ code_block:
element: element:
REAL REAL
{
}
| INTEGER | INTEGER
{
}
| STRING | STRING
{
}
| CHAR_TOK | CHAR_TOK
{
}
| IDENTIFIER | IDENTIFIER
{
}
| TYPENAME_IDENTIFIER | TYPENAME_IDENTIFIER
{
}
| SCOPING | SCOPING
{
}
| SIMPLE_IDENTIFIER | SIMPLE_IDENTIFIER
{
}
| ELLIPSIS | OROR | ANDAND | ELLIPSIS | OROR | ANDAND
| EQCOMPARE | NECOMPARE | LECOMPARE | GECOMPARE | EQCOMPARE | NECOMPARE | LECOMPARE | GECOMPARE
| LSHIFT | RSHIFT | POINTSAT_STAR | DOT_STAR | POINTSAT | LSHIFT | RSHIFT | POINTSAT_STAR | DOT_STAR | POINTSAT
| SCOPE | PLUSPLUS | MINUSMINUS | SCOPE | PLUSPLUS | MINUSMINUS
| TIMESEQUAL | DIVIDEEQUAL | MODEQUAL | PLUSEQUAL | MINUSEQUAL | TIMESEQUAL | DIVIDEEQUAL | MODEQUAL | PLUSEQUAL | MINUSEQUAL
| OREQUAL | ANDEQUAL | XOREQUAL | LSHIFTEQUAL | RSHIFTEQUAL | OREQUAL | ANDEQUAL | XOREQUAL | LSHIFTEQUAL | RSHIFTEQUAL
| KW_BOOL | KW_CATCH | KW_CHAR | KW_CHAR16_T | KW_CHAR32_T | KW_BOOL | KW_CATCH
| KW_WCHAR_T | KW_CLASS | KW_CONST | KW_CHAR | KW_CHAR16_T | KW_CHAR32_T
| KW_CLASS | KW_CONST
| KW_DELETE | KW_DOUBLE | KW_DYNAMIC_CAST | KW_ELSE | KW_ENUM | KW_DELETE | KW_DOUBLE | KW_DYNAMIC_CAST | KW_ELSE | KW_ENUM
| KW_EXTERN | KW_EXPLICIT | KW_FALSE | KW_EXTERN | KW_EXPLICIT | KW_FALSE
| KW_FLOAT | KW_FRIEND | KW_FOR | KW_GOTO | KW_FLOAT | KW_FRIEND | KW_FOR | KW_GOTO | KW_IF | KW_INLINE
| KW_IF | KW_INLINE | KW_INT | KW_INT | KW_LONG | KW_MUTABLE | KW_NAMESPACE
| KW_LONG | KW_MUTABLE | KW_NEW | KW_PRIVATE | KW_PROTECTED | KW_NEW | KW_OPERATOR | KW_PRIVATE | KW_PROTECTED
| KW_PUBLIC | KW_PUBLISHED | KW_REGISTER | KW_RETURN | KW_PUBLIC | KW_PUBLISHED | KW_REGISTER | KW_RETURN
| KW_SHORT | KW_SIGNED | KW_SIZEOF | KW_STATIC | KW_STATIC_CAST | KW_SHORT | KW_SIGNED | KW_SIZEOF | KW_STATIC
| KW_STRUCT | KW_THROW | KW_TRUE | KW_TRY | KW_TYPEDEF | KW_TYPENAME | KW_STATIC_CAST | KW_STRUCT | KW_THROW | KW_TRUE | KW_TRY
| KW_UNION | KW_UNSIGNED | KW_VIRTUAL | KW_VOID | KW_VOLATILE | KW_TYPEDEF | KW_TYPENAME | KW_UNION | KW_UNSIGNED | KW_USING
| KW_WHILE | KW_VIRTUAL | KW_VOID | KW_VOLATILE | KW_WCHAR_T | KW_WHILE
| KW_OPERATOR
{ {
} }
| '+' | '-' | '*' | '/' | '&' | '|' | '^' | '!' | '~' | '=' | '%' | '+' | '-' | '*' | '/' | '&' | '|' | '^' | '!' | '~' | '=' | '%'

View File

@ -252,6 +252,11 @@ define_extension_type(CPPExtensionType *type, CPPPreprocessor *error_sink) {
} }
if (type->is_template()) { if (type->is_template()) {
CPPTemplateScope *scope = type->get_template_scope();
if (scope->_parameters._parameters.size() == 0) {
return;
}
string simple_name = type->get_simple_name(); string simple_name = type->get_simple_name();
pair<Templates::iterator, bool> result = pair<Templates::iterator, bool> result =
@ -596,9 +601,14 @@ find_scope(const string &name, bool recurse) const {
ti = _types.find(name); ti = _types.find(name);
if (ti != _types.end()) { if (ti != _types.end()) {
type = (*ti).second; type = (*ti).second;
// Resolve if this is a typedef. // Resolve if this is a typedef or const.
while (type->as_typedef_type() != (CPPTypedefType *)NULL) { while (type->get_subtype() == CPPDeclaration::ST_const ||
type->get_subtype() == CPPDeclaration::ST_typedef) {
if (type->as_typedef_type() != (CPPType *)NULL) {
type = type->as_typedef_type()->_type; type = type->as_typedef_type()->_type;
} else {
type = type->as_const_type()->_wrapped_around;
}
} }
} else if (_struct_type != NULL) { } else if (_struct_type != NULL) {
@ -648,9 +658,14 @@ find_scope(const string &name, CPPDeclaration::SubstDecl &subst,
return NULL; return NULL;
} }
// Resolve this if it is a typedef. // Resolve if this is a typedef or const.
while (type->get_subtype() == CPPDeclaration::ST_typedef) { while (type->get_subtype() == CPPDeclaration::ST_const ||
type->get_subtype() == CPPDeclaration::ST_typedef) {
if (type->as_typedef_type() != (CPPType *)NULL) {
type = type->as_typedef_type()->_type; type = type->as_typedef_type()->_type;
} else {
type = type->as_const_type()->_wrapped_around;
}
} }
CPPStructType *st = type->as_struct_type(); CPPStructType *st = type->as_struct_type();