def BlockParser(input): return Parser.loop( Parser.terminal(TokenType.OPEN_CURLY), Parser.doAssert(StatementParser, f"statement or '{TokenType.CLOSE_CURLY.key}'"), Parser.terminal(TokenType.CLOSE_CURLY), createNode=lambda open, statements, close: Block.withChildren( statements, open.pos))(input)
def MethodsDeclarationParser(input): return Parser.loop( Parser.terminal(TokenType.OPEN_CURLY), Parser.doAssert(FunctionDefinitionParser, f"method definition or '{TokenType.CLOSE_CURLY.key}'"), Parser.terminal(TokenType.CLOSE_CURLY), createNode=lambda open, methods, close: Block.withChildren( methods, open.pos), name="methods block")(input)