tokenize()); $root = $parser->parse(); $this->assertInstanceOf(RootNode::class, $root); $this->assertCount(1, $root->children); $this->assertInstanceOf(TextNode::class, $root->children[0]); $this->assertEquals('Hello World', $root->children[0]->content); } public function testParseExpression(): void { $lexer = new Lexer('<< name >>'); $parser = new Parser($lexer->tokenize()); $root = $parser->parse(); $this->assertCount(1, $root->children); $this->assertInstanceOf(ExpressionNode::class, $root->children[0]); $this->assertEquals('name', $root->children[0]->expression); } public function testParseMixed(): void { $lexer = new Lexer('Hello << name >>!'); $parser = new Parser($lexer->tokenize()); $root = $parser->parse(); $this->assertCount(3, $root->children); $this->assertInstanceOf(TextNode::class, $root->children[0]); $this->assertInstanceOf(ExpressionNode::class, $root->children[1]); $this->assertInstanceOf(TextNode::class, $root->children[2]); } }