From f7df90519f230cb865f49c21af90444f45a0e648 Mon Sep 17 00:00:00 2001 From: Kyler <59854022+KylerOlsen@users.noreply.github.com> Date: Wed, 28 Feb 2024 00:54:55 -0700 Subject: [PATCH] Fixed incorrect indices --- pytd12dk/compiler/syntactical_analyzer.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pytd12dk/compiler/syntactical_analyzer.py b/pytd12dk/compiler/syntactical_analyzer.py index cbcc96c..0d2b62a 100644 --- a/pytd12dk/compiler/syntactical_analyzer.py +++ b/pytd12dk/compiler/syntactical_analyzer.py @@ -708,24 +708,24 @@ def struct_syntactical_analyzer( tokens: list[lexer.Token], public: bool, ) -> StructBlock: - identifier = tokens.pop() + identifier = tokens.pop(0) _assert_token(ExpectedIdentifier, identifier) - temp = tokens.pop() + temp = tokens.pop(0) _assert_token(ExpectedPunctuation, temp, '(') members: list[StructureMember] = [] - temp = tokens.pop() + temp = tokens.pop(0) while temp.value != ')': if isinstance(temp, lexer.Keyword): _assert_token(ExpectedKeyword, temp, 'static') - temp = tokens.pop() + temp = tokens.pop(0) static = True else: static = False if isinstance(temp, lexer.Identifier): member_id = Identifier(temp.value) - temp = tokens.pop() + temp = tokens.pop(0) _assert_token(ExpectedPunctuation, temp, ':') - temp = tokens.pop() + temp = tokens.pop(0) _assert_token_mult(temp, ( lexer.Keyword, lexer.Identifier, @@ -734,7 +734,7 @@ def struct_syntactical_analyzer( if isinstance(temp, lexer.Punctuation): _assert_token(ExpectedPunctuation, temp, '*') pointer = True - temp = tokens.pop() + temp = tokens.pop(0) _assert_token_mult(temp, (lexer.Keyword, lexer.Identifier)) else: pointer = False @@ -747,15 +747,15 @@ def struct_syntactical_analyzer( data_type = DefaultDataType(temp.value) else: data_type = Identifier(temp.value) - temp = tokens.pop() + temp = tokens.pop(0) _assert_token(ExpectedPunctuation, temp) if temp.value not in [',', '=']: raise UnexpectedPunctuation(temp, [',', '=']) elif temp.value == '=': - temp = tokens.pop() + temp = tokens.pop(0) _assert_token_literal(temp) literal = _literal_map(temp) # type: ignore - temp = tokens.pop() + temp = tokens.pop(0) else: literal = None members.append( StructureMember(member_id, data_type, pointer, static, literal))