public ASTNodeName ParseName(bool needsExplicitParameterSeparator, bool canBeRooted) { var nameNode = new ASTNodeName(); nameNode.SetSpan(this.Current().span); var pathNode = new ASTNodePath(); pathNode.SetSpan(this.Current().span); if (canBeRooted && this.CurrentIs(TokenKind.Placeholder)) { this.Advance(); pathNode.SetRooted(true); this.Match(TokenKind.DoubleColon, "expected '::'"); } pathNode.AddIdentifierNode(this.ParseIdentifier()); while (this.CurrentIs(TokenKind.DoubleColon) && this.NextIs(TokenKind.Identifier)) { this.Advance(); pathNode.AddIdentifierNode(this.ParseIdentifier()); } nameNode.SetPathNode(pathNode); return(nameNode); }
public ASTNodeUse ParseUseDirective() { var useSpan = this.Current().span; this.Match(TokenKind.KeywordUse, "expected 'use'"); var pathNode = new ASTNodePath(); pathNode.SetSpan(this.Current().span); pathNode.AddIdentifierNode(this.ParseIdentifier()); while (this.CurrentIs(TokenKind.DoubleColon) && this.NextIs(TokenKind.Identifier)) { this.Advance(); pathNode.AddIdentifierNode(this.ParseIdentifier()); } if (this.CurrentIs(TokenKind.DoubleColon) && this.NextIs(TokenKind.Placeholder)) { this.Advance(); this.Advance(); var useNode = new ASTNodeUseAll(); useNode.SetSpan(useSpan); useNode.SetPathNode(pathNode); return(useNode); } else { throw new NotImplementedException(); } }