Exemplo n.º 1
0
        public Value Parse(TokenStream stream)
        {
            // Consume the value string.
            var value = stream.Next().Value;

            // Attempt to identify value string type.
            var type = TokenIdentifier.IdentifyComplex(value);

            // Ensure type has successfully been identified.
            if (!type.HasValue)
            {
                throw new Exception("Unable to identify literal token type");
            }

            // Create and return the value.
            return(new Value(Resolvers.TypeFromTokenType(type.Value), type.Value, value));
        }
Exemplo n.º 2
0
        public Value Parse(ParserContext context)
        {
            // Consume the value string.
            string value = context.Stream.Current.Value;

            // Attempt to identify value string type.
            TokenType?type = TokenIdentifier.IdentifyComplex(value);

            // Ensure type has successfully been identified.
            if (!type.HasValue)
            {
                throw new Exception("Unable to identify literal token type");
            }

            // Create and return the value.
            return(new Value(Resolvers.PrimitiveType(type.Value), type.Value, value));
        }