From 529751111884a0d878c4198b87355cc1bdf0b9ff Mon Sep 17 00:00:00 2001 From: Doyle Date: Sat, 23 Feb 2019 14:38:41 +1100 Subject: [PATCH] Partial support for fixed sized arrays --- Code/DqnInspect.h | 15 ++++++++++++++- Data/DqnInspect_TestData.h | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Code/DqnInspect.h b/Code/DqnInspect.h index 89ea59b..2bda642 100644 --- a/Code/DqnInspect.h +++ b/Code/DqnInspect.h @@ -347,6 +347,8 @@ b32 StrCmp(StringLiteral a, StringLiteral b) X(EndOfStream, "End Of Stream") \ X(LeftBrace, "{") \ X(RightBrace, "}") \ + X(LeftSqBracket, "[") \ + X(RightSqBracket, "]") \ X(OpenParen, "(") \ X(CloseParen, ")") \ X(Comma, ",") \ @@ -857,7 +859,16 @@ void ParseCPPStruct(CPPTokeniser *tokeniser) link->value.array_dimensions = total_asterisks_count; CPPTokeniser_NextToken(tokeniser); - peek_token = CPPTokeniser_PeekToken(tokeniser); + for (peek_token = CPPTokeniser_PeekToken(tokeniser); + peek_token.type == CPPTokenType::LeftSqBracket && peek_token.type != CPPTokenType::EndOfStream; + peek_token = CPPTokeniser_NextToken(tokeniser)) + { + // TODO(doyle): Parsing array size is difficult if it's an expression, so maybe don't do it at all + ++link->value.array_dimensions; + while (token.type != CPPTokenType::RightSqBracket && token.type != CPPTokenType::EndOfStream) + token = CPPTokeniser_NextToken(tokeniser); + } + if (IsIdentifierToken(peek_token, STR_LITERAL("DQN_INSPECT_META"))) { link->metadata_array = ParseCPPInspectMeta(tokeniser); @@ -1099,6 +1110,8 @@ int main(int argc, char *argv[]) { case '{': { token->type = CPPTokenType::LeftBrace; started_lexing_scope = true; indent_level++; } break; case '}': { token->type = CPPTokenType::RightBrace; indent_level--; } break; + case '[': { token->type = CPPTokenType::LeftSqBracket; } break; + case ']': { token->type = CPPTokenType::RightSqBracket; } break; case '(': { token->type = CPPTokenType::OpenParen; } break; case ')': { token->type = CPPTokenType::CloseParen; } break; case ',': { token->type = CPPTokenType::Comma; } break; diff --git a/Data/DqnInspect_TestData.h b/Data/DqnInspect_TestData.h index a95a1a3..dd5833c 100644 --- a/Data/DqnInspect_TestData.h +++ b/Data/DqnInspect_TestData.h @@ -28,9 +28,9 @@ DQN_INSPECT struct OpenGLState { // #if 0 // #endif + u32 shaders[(int)OpenGLShader::Count]; void *win32_handle; int ebo DQN_INSPECT_META(DisplayName = "Element Buffer Object"), vbo, vao DQN_INSPECT_META(DisplayName = "Vertex Array Object", OpenGLVersion = "330"); - // u32 shaders[(int)OpenGLShader::Count]; V4 draw_color DQN_INSPECT_META(DisplayName = "HelloWorld"); V3 lighting_ambient_coeff; char **bitmaps;