Fix trailing comma handling in ParseFieldlist
This is pretty ugly since it checks for every token type that could follow to make it a valid field but the previous check was flat out wrong
This commit is contained in:
parent
83b0416c03
commit
04f5804dff
11
Parser.cs
11
Parser.cs
@ -1186,11 +1186,12 @@ class Parser
|
||||
while(index < tokens.Length && IsFieldsep(tokens[index]))
|
||||
{
|
||||
index += 1;
|
||||
fields.Add(ParseField(tokens));
|
||||
}
|
||||
if(index < tokens.Length && IsFieldsep(tokens[index]))
|
||||
{
|
||||
index += 1;
|
||||
if(index < tokens.Length && tokens[index].type is TokenType.SquareOpen or
|
||||
TokenType.Name or TokenType.Nil or TokenType.True or TokenType.False or TokenType.Numeral or TokenType.StringLiteral or
|
||||
TokenType.DotDotDot or TokenType.CurlyOpen or TokenType.Function or TokenType.Minus or TokenType.Hash or TokenType.Not or TokenType.Nil or TokenType.RoundOpen)
|
||||
{
|
||||
fields.Add(ParseField(tokens));
|
||||
}
|
||||
}
|
||||
// NOTE: Since at least 1 field is parsed the list accesses are safe
|
||||
return new FieldlistNode(exps: fields, startRegion: fields[0].startRegion, endRegion: fields[^1].endRegion);
|
||||
|
Loading…
x
Reference in New Issue
Block a user