Exemplo n.º 1
0
        /// <summary>
        ///     Reads Any token or none if the token stream reached the end
        /// </summary>
        /// <param name="tokens">Token Stream</param>
        /// <param name="start">Start Index</param>
        /// <param name="result">Specified Tokens</param>
        /// <returns></returns>
        public static bool ReadAnyOrNone(List <IHlToken> tokens, int start, out IHlToken result)
        {
            if (start >= 0 && tokens.Count > start)
            {
                result = tokens[start];

                return(true);
            }

            result = new EofToken();

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        ///     reads one or none token of the accepted type
        /// </summary>
        /// <param name="tokens">Token Stream</param>
        /// <param name="start">Start index</param>
        /// <param name="type">Token FunctionType</param>
        /// <param name="result">Read Token</param>
        /// <returns>True if token was read.</returns>
        public static bool ReadOneOrNone(List <IHlToken> tokens, int start, HlTokenType type, out IHlToken result)
        {
            if (start >= 0 && tokens.Count > start)
            {
                result = tokens[start];

                if (tokens[start].Type == type)
                {
                    return(true);
                }

                return(false);
            }

            result = new EofToken();

            return(false);
        }