public ImmutableRootSyntaxNode ParseTokens(ReadOnlySpan <IToken> tokens) { var rootNode = new RootSyntaxNode(); while (!tokens.IsEmpty) { var curToken = tokens[0]; tokens = tokens.Slice(1); switch (curToken) { case ClassToken _: rootNode.Classes.Add(ParseClass(ref tokens, rootNode)); break; case DelegateToken _: rootNode.Delegates.Add(ParseDelegate(ref tokens, rootNode)); break; default: throw new InvalidTokenException("Only expecting a delegate or a class"); } } return(rootNode.ToImmutableNode()); }
private BoundRoot BindRoot(RootSyntaxNode node) { var boundFile = BindFile(node.File); return(Root(node, boundFile)); }