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

View File

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