Example #1
0
        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 };
        }
Example #2
0
 private Token initToken(Token token, Func<string> contentFunc)
 {
     token.Index = _currentIndex;
     token.Content = contentFunc();
     return token;
 }
Example #3
0
 public ParserException(Token token)
     : base(string.Format("Invalid token '{0}' at {1}", token.Type, token.Index))
 {
 }
Example #4
0
 public UnexpectedToken(Token token)
 {
     Index = token.Index;
     Token = token.Content;
     Type = token.Type;
 }