private TexlParser(Token[] tokens, Flags flags) { Contracts.AssertValue(tokens); _depth = 0; _curs = new TokenCursor(tokens); _flags = flags; }
public TokenCursor Split() { var split = new TokenCursor(_tokens); split._currentTokenIndex = _currentTokenIndex; split._currentToken = _currentToken; split._currentTokenId = _currentTokenId; return(split); }
private ITexlSource ParseTrivia(TokenCursor cursor = null) { cursor = cursor ?? _curs; var sources = new List <ITexlSource>(); if (_extraTrivia != null) { sources.Add(_extraTrivia); _extraTrivia = null; } bool triviaFound; do { triviaFound = false; var tokens = cursor.SkipWhitespace(); if (tokens.Any()) { sources.Add(new WhitespaceSource(tokens)); triviaFound = true; } if (cursor.TidCur == TokKind.Comment) { var comment = cursor.TokMove().As <CommentToken>(); sources.Add(new TokenSource(comment)); if (comment.IsOpenBlock) { PostError(comment, TexlStrings.ErrMissingEndOfBlockComment); } _comments.Add(comment); triviaFound = true; } } while (triviaFound); if (sources.Count() == 1) { return(sources.Single()); } else { return(new SpreadSource(sources)); } }