All Downloads are FREE. Search and download functionalities are using the official Maven repository.

CSharp.runtime.CSharp.Antlr4.Runtime.ITokenStream.cs Maven / Gradle / Ivy

There is a newer version: 4.13.2
Show newest version
/*
 * [The "BSD license"]
 *  Copyright (c) 2013 Terence Parr
 *  Copyright (c) 2013 Sam Harwell
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. The name of the author may not be used to endorse or promote products
 *     derived from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 *  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 *  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
using Antlr4.Runtime;
using Antlr4.Runtime.Misc;
using Antlr4.Runtime.Sharpen;

namespace Antlr4.Runtime
{
    /// 
    /// An
    /// 
    /// whose symbols are
    /// 
    /// instances.
    /// 
    public interface ITokenStream : IIntStream
    {
        /// 
        /// Get the
        /// 
        /// instance associated with the value returned by
        /// LA(k)
        /// . This method has the same pre- and post-conditions as
        /// 
        /// . In addition, when the preconditions of this method
        /// are met, the return value is non-null and the value of
        /// LT(k).getType()==LA(k)
        /// .
        /// 
        /// 
        [return: NotNull]
        IToken Lt(int k);

        /// 
        /// Gets the
        /// 
        /// at the specified
        /// index
        /// in the stream. When
        /// the preconditions of this method are met, the return value is non-null.
        /// 

The preconditions for this method are the same as the preconditions of /// /// . If the behavior of /// seek(index) /// is /// unspecified for the current state and given /// index /// , then the /// behavior of this method is also unspecified.

///

The symbol referred to by /// index /// differs from /// seek() /// only /// in the case of filtering streams where /// index /// lies before the end /// of the stream. Unlike /// seek() /// , this method does not adjust /// index /// to point to a non-ignored symbol.

///
/// if {code index} is less than 0 /// /// if the stream does not support /// retrieving the token at the specified index /// [return: NotNull] IToken Get(int i); /// /// Gets the underlying /// /// which provides tokens for this /// stream. /// ITokenSource TokenSource { get; } /// /// Return the text of all tokens within the specified /// /// . This /// method behaves like the following code (including potential exceptions /// for violating preconditions of /// /// , but may be optimized by the /// specific implementation. ///
        /// TokenStream stream = ...;
        /// String text = "";
        /// for (int i = interval.a; i <= interval.b; i++) {
        /// text += stream.get(i).getText();
        /// }
        /// 
///
/// /// The interval of tokens within this stream to get text /// for. /// /// /// The text of all tokens within the specified interval in this /// stream. /// /// /// if /// /// is /// /// [return: NotNull] string GetText(Interval interval); /// Return the text of all tokens in the stream. /// /// Return the text of all tokens in the stream. This method behaves like the /// following code, including potential exceptions from the calls to /// /// and /// /// , but may be /// optimized by the specific implementation. ///
        /// TokenStream stream = ...;
        /// String text = stream.getText(new Interval(0, stream.size()));
        /// 
///
/// The text of all tokens in the stream. [return: NotNull] string GetText(); /// /// Return the text of all tokens in the source interval of the specified /// context. /// /// /// Return the text of all tokens in the source interval of the specified /// context. This method behaves like the following code, including potential /// exceptions from the call to /// /// , but may be /// optimized by the specific implementation. ///

If /// ctx.getSourceInterval() /// does not return a valid interval of /// tokens provided by this stream, the behavior is unspecified.

///
        /// TokenStream stream = ...;
        /// String text = stream.getText(ctx.getSourceInterval());
        /// 
///
/// /// The context providing the source interval of tokens to get /// text for. /// /// /// The text of all tokens within the source interval of /// /// . /// [return: NotNull] string GetText(RuleContext ctx); /// /// Return the text of all tokens in this stream between /// /// and /// /// (inclusive). ///

If the specified /// /// or /// /// token was not provided by /// this stream, or if the /// /// occurred before the /// /// token, the behavior is unspecified.

///

For streams which ensure that the /// /// method is /// accurate for all of its provided tokens, this method behaves like the /// following code. Other streams may implement this method in other ways /// provided the behavior is consistent with this at a high level.

///
        /// TokenStream stream = ...;
        /// String text = "";
        /// for (int i = start.getTokenIndex(); i <= stop.getTokenIndex(); i++) {
        /// text += stream.get(i).getText();
        /// }
        /// 
///
/// The first token in the interval to get text for. /// The last token in the interval to get text for (inclusive). /// /// The text of all tokens lying between the specified /// /// and /// /// tokens. /// /// /// if this stream does not support /// this method for the specified tokens /// [return: NotNull] string GetText(IToken start, IToken stop); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy