Files
SWG-ScriptConverter/ScriptConverter/Parser/Parselets/Statements/BlockParselet.cs
Rohan Singh ad50a19057 Add code
2019-01-23 22:52:45 -05:00

25 lines
680 B
C#

using System.Collections.Generic;
using ScriptConverter.Ast.Statements;
namespace ScriptConverter.Parser.Parselets.Statements
{
class BlockParselet : IStatementParselet
{
public Statement Parse(ScriptParser parser, ScriptToken token, out bool trailingSemicolon)
{
trailingSemicolon = false;
var statements = new List<Statement>();
while (!parser.Match(ScriptTokenType.RightBrace))
{
statements.Add(parser.ParseStatement());
}
parser.Take(ScriptTokenType.RightBrace);
return new BlockStatement(token, parser.Previous, statements);
}
}
}