mirror of
https://github.com/Cekis/SWG-ScriptConverter.git
synced 2026-09-25 11:12:49 -04:00
Add code
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System.Linq;
|
||||
using ScriptConverter.Ast.Expressions;
|
||||
|
||||
namespace ScriptConverter.Parser.Parselets.Expressions
|
||||
{
|
||||
class ArrayInitializerParselet : IPrefixParselet
|
||||
{
|
||||
public Expression Parse(ScriptParser parser, ScriptToken token)
|
||||
{
|
||||
var values = parser.ParseSeparatedBy(ScriptTokenType.Comma, (_, first) =>
|
||||
{
|
||||
if (parser.Match(ScriptTokenType.RightBrace))
|
||||
return null;
|
||||
|
||||
return parser.ParseExpression();
|
||||
}).ToList();
|
||||
|
||||
parser.Take(ScriptTokenType.RightBrace);
|
||||
return new ArrayInitializerExpression(token, parser.Previous, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user