private Statement GetStatementFromToken(Token identifier, StatementTail tail, Token previousToken = null) { var value = identifier != null ? identifier.Content : ""; if (identifier != null) { switch (identifier.Type) { case TokenType.StringLiteral: case TokenType.QuotedStringLiteral: return new StringLiteral(value, tail) { Index = identifier.Index }; case TokenType.StringLiteralPipe: return new StringLiteralPipe(value.Substring(1), tail) { Index = identifier.Index }; } } if (previousToken != null) { switch (previousToken.Type) { case TokenType.At: return new EncodedOutput(value) { Index = previousToken.Index }; case TokenType.Equal: return new RawOutput(value) { Index = previousToken.Index }; } } return new Statement(value, tail) { Index = identifier.Index }; }
private Token initToken(Token token, Func<string> contentFunc) { token.Index = _currentIndex; token.Content = contentFunc(); return token; }
public ParserException(Token token) : base(string.Format("Invalid token '{0}' at {1}", token.Type, token.Index)) { }
public UnexpectedToken(Token token) { Index = token.Index; Token = token.Content; Type = token.Type; }