Fixed incorrect indices
This commit is contained in:
parent
07a5fef918
commit
f7df90519f
|
@ -708,24 +708,24 @@ def struct_syntactical_analyzer(
|
||||||
tokens: list[lexer.Token],
|
tokens: list[lexer.Token],
|
||||||
public: bool,
|
public: bool,
|
||||||
) -> StructBlock:
|
) -> StructBlock:
|
||||||
identifier = tokens.pop()
|
identifier = tokens.pop(0)
|
||||||
_assert_token(ExpectedIdentifier, identifier)
|
_assert_token(ExpectedIdentifier, identifier)
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
_assert_token(ExpectedPunctuation, temp, '(')
|
_assert_token(ExpectedPunctuation, temp, '(')
|
||||||
members: list[StructureMember] = []
|
members: list[StructureMember] = []
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
while temp.value != ')':
|
while temp.value != ')':
|
||||||
if isinstance(temp, lexer.Keyword):
|
if isinstance(temp, lexer.Keyword):
|
||||||
_assert_token(ExpectedKeyword, temp, 'static')
|
_assert_token(ExpectedKeyword, temp, 'static')
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
static = True
|
static = True
|
||||||
else:
|
else:
|
||||||
static = False
|
static = False
|
||||||
if isinstance(temp, lexer.Identifier):
|
if isinstance(temp, lexer.Identifier):
|
||||||
member_id = Identifier(temp.value)
|
member_id = Identifier(temp.value)
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
_assert_token(ExpectedPunctuation, temp, ':')
|
_assert_token(ExpectedPunctuation, temp, ':')
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
_assert_token_mult(temp, (
|
_assert_token_mult(temp, (
|
||||||
lexer.Keyword,
|
lexer.Keyword,
|
||||||
lexer.Identifier,
|
lexer.Identifier,
|
||||||
|
@ -734,7 +734,7 @@ def struct_syntactical_analyzer(
|
||||||
if isinstance(temp, lexer.Punctuation):
|
if isinstance(temp, lexer.Punctuation):
|
||||||
_assert_token(ExpectedPunctuation, temp, '*')
|
_assert_token(ExpectedPunctuation, temp, '*')
|
||||||
pointer = True
|
pointer = True
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
_assert_token_mult(temp, (lexer.Keyword, lexer.Identifier))
|
_assert_token_mult(temp, (lexer.Keyword, lexer.Identifier))
|
||||||
else:
|
else:
|
||||||
pointer = False
|
pointer = False
|
||||||
|
@ -747,15 +747,15 @@ def struct_syntactical_analyzer(
|
||||||
data_type = DefaultDataType(temp.value)
|
data_type = DefaultDataType(temp.value)
|
||||||
else:
|
else:
|
||||||
data_type = Identifier(temp.value)
|
data_type = Identifier(temp.value)
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
_assert_token(ExpectedPunctuation, temp)
|
_assert_token(ExpectedPunctuation, temp)
|
||||||
if temp.value not in [',', '=']:
|
if temp.value not in [',', '=']:
|
||||||
raise UnexpectedPunctuation(temp, [',', '='])
|
raise UnexpectedPunctuation(temp, [',', '='])
|
||||||
elif temp.value == '=':
|
elif temp.value == '=':
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
_assert_token_literal(temp)
|
_assert_token_literal(temp)
|
||||||
literal = _literal_map(temp) # type: ignore
|
literal = _literal_map(temp) # type: ignore
|
||||||
temp = tokens.pop()
|
temp = tokens.pop(0)
|
||||||
else: literal = None
|
else: literal = None
|
||||||
members.append(
|
members.append(
|
||||||
StructureMember(member_id, data_type, pointer, static, literal))
|
StructureMember(member_id, data_type, pointer, static, literal))
|
||||||
|
|
Loading…
Reference in New Issue