]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/CharStream.h
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / CharStream.h
1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2  * Use of this file is governed by the BSD 3-clause license that
3  * can be found in the LICENSE.txt file in the project root.
4  */
5
6 #pragma once
7
8 #include "IntStream.h"
9 #include "misc/Interval.h"
10
11 namespace antlr4 {
12
13   /// A source of characters for an ANTLR lexer.
14   class ANTLR4CPP_PUBLIC CharStream : public IntStream {
15   public:
16     virtual ~CharStream();
17
18     /// This method returns the text for a range of characters within this input
19     /// stream. This method is guaranteed to not throw an exception if the
20     /// specified interval lies entirely within a marked range. For more
21     /// information about marked ranges, see IntStream::mark.
22     ///
23     /// <param name="interval"> an interval within the stream </param>
24     /// <returns> the text of the specified interval
25     /// </returns>
26     /// <exception cref="NullPointerException"> if {@code interval} is {@code null} </exception>
27     /// <exception cref="IllegalArgumentException"> if {@code interval.a < 0}, or if
28     /// {@code interval.b < interval.a - 1}, or if {@code interval.b} lies at or
29     /// past the end of the stream </exception>
30     /// <exception cref="UnsupportedOperationException"> if the stream does not support
31     /// getting the text of the specified interval </exception>
32     virtual std::string getText(const misc::Interval &interval) = 0;
33
34     virtual std::string toString() const = 0;
35   };
36
37 } // namespace antlr4