summaryrefslogtreecommitdiffstats
path: root/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp
diff options
context:
space:
mode:
authorantonovvk <[email protected]>2022-02-10 16:47:52 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:47:52 +0300
commit37de222addabbef336dcaaea5f7c7645a629fc6d (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp
parent37a63debdc21e372d99e1808cdd31aecf75018c3 (diff)
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp')
-rw-r--r--contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp404
1 files changed, 202 insertions, 202 deletions
diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp
index b523af34992..d167f5b392a 100644
--- a/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp
+++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3input.hpp
@@ -1,53 +1,53 @@
-/** \file
- * Defines the basic structures used to manipulate character
- * streams from any input source. Any character size and encoding
- * can in theory be used, so long as a set of functinos is provided that
- * can return a 32 bit Integer representation of their characters amd efficiently mark and revert
- * to specific offsets into their input streams.
- */
+/** \file
+ * Defines the basic structures used to manipulate character
+ * streams from any input source. Any character size and encoding
+ * can in theory be used, so long as a set of functinos is provided that
+ * can return a 32 bit Integer representation of their characters amd efficiently mark and revert
+ * to specific offsets into their input streams.
+ */
#ifndef _ANTLR_INPUT_HPP
#define _ANTLR_INPUT_HPP
-
-// [The "BSD licence"]
-// Copyright (c) 2005-2009 Gokulakannan Somasundaram, ElectronDB
-
-//
-// 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.
-
+
+// [The "BSD licence"]
+// Copyright (c) 2005-2009 Gokulakannan Somasundaram, ElectronDB
+
+//
+// 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.
+
namespace antlr3 {
-
-/// Master context structure for an ANTLR3 C runtime based input stream.
+
+/// Master context structure for an ANTLR3 C runtime based input stream.
/// \ingroup apistructures. Calling LT on this doesn't seem right. You would
/// call it only with parser / TreeParser, and their respective input streams
-/// has that function. calling it from lexer will throw a compile time error
-///
-
-template<class ImplTraits>
+/// has that function. calling it from lexer will throw a compile time error
+///
+
+template<class ImplTraits>
class InputStream : public ImplTraits::template IntStreamType< typename ImplTraits::InputStreamType >
-{
-public:
+{
+public:
typedef typename ImplTraits::AllocPolicyType AllocPolicyType;
typedef typename ImplTraits::LexStateType LexStateType;
typedef typename ImplTraits::template IntStreamType< typename ImplTraits::InputStreamType > IntStreamType;
@@ -57,82 +57,82 @@ public:
typedef UnitType TokenType;
typedef typename AllocPolicyType::template VectorType<LexStateType> MarkersType;
typedef typename ImplTraits::StringType StringType;
-
-private:
- /** Pointer the start of the input string, characters may be
- * taken as offsets from here and in original input format encoding.
- */
+
+private:
+ /** Pointer the start of the input string, characters may be
+ * taken as offsets from here and in original input format encoding.
+ */
const DataType* m_data;
-
- /** Pointer to the next character to be consumed from the input data
- * This is cast to point at the encoding of the original file that
- * was read by the functions installed as pointer in this input stream
- * context instance at file/string/whatever load time.
- */
+
+ /** Pointer to the next character to be consumed from the input data
+ * This is cast to point at the encoding of the original file that
+ * was read by the functions installed as pointer in this input stream
+ * context instance at file/string/whatever load time.
+ */
const DataType* m_nextChar;
-
- /** Number of characters that can be consumed at this point in time.
- * Mostly this is just what is left in the pre-read buffer, but if the
- * input source is a stream such as a socket or something then we may
- * call special read code to wait for more input.
- */
+
+ /** Number of characters that can be consumed at this point in time.
+ * Mostly this is just what is left in the pre-read buffer, but if the
+ * input source is a stream such as a socket or something then we may
+ * call special read code to wait for more input.
+ */
ANTLR_UINT32 m_sizeBuf;
-
- /** The line number we are traversing in the input file. This gets incremented
- * by a newline() call in the lexer grammar actions.
- */
+
+ /** The line number we are traversing in the input file. This gets incremented
+ * by a newline() call in the lexer grammar actions.
+ */
ANTLR_UINT32 m_line;
-
- /** Pointer into the input buffer where the current line
- * started.
- */
+
+ /** Pointer into the input buffer where the current line
+ * started.
+ */
const DataType* m_currentLine;
-
- /** The offset within the current line of the current character
- */
+
+ /** The offset within the current line of the current character
+ */
ANTLR_INT32 m_charPositionInLine;
-
- /** Tracks how deep mark() calls are nested
- */
+
+ /** Tracks how deep mark() calls are nested
+ */
ANTLR_UINT32 m_markDepth;
-
- /** List of mark() points in the input stream
- */
+
+ /** List of mark() points in the input stream
+ */
MarkersType m_markers;
-
- /** File name string, set to pointer to memory if
- * you set it manually as it will be free()d
- */
+
+ /** File name string, set to pointer to memory if
+ * you set it manually as it will be free()d
+ */
StringType m_fileName;
-
- /** File number, needs to be set manually to some file index of your devising.
- */
+
+ /** File number, needs to be set manually to some file index of your devising.
+ */
ANTLR_UINT32 m_fileNo;
-
+
/// Character that automatically causes an internal line count
- /// increment.
- ///
+ /// increment.
+ ///
ANTLR_UCHAR m_newlineChar;
-
- /// Indicates the size, in 8 bit units, of a single character. Note that
- /// the C runtime does not deal with surrogates as this would be
- /// slow and complicated. If this is a UTF-8 stream then this field
- /// will be set to 0. Generally you are best working internally with 32 bit characters
- /// as this is the most efficient.
- ///
+
+ /// Indicates the size, in 8 bit units, of a single character. Note that
+ /// the C runtime does not deal with surrogates as this would be
+ /// slow and complicated. If this is a UTF-8 stream then this field
+ /// will be set to 0. Generally you are best working internally with 32 bit characters
+ /// as this is the most efficient.
+ ///
ANTLR_UINT8 m_charByteSize;
-
- /** Indicates if the data pointer was allocated by us, and so should be freed
- * when the stream dies.
- */
+
+ /** Indicates if the data pointer was allocated by us, and so should be freed
+ * when the stream dies.
+ */
bool m_isAllocated;
-
- /// Indicates the encoding scheme used in this input stream
- ///
- ANTLR_UINT32 m_encoding;
-
- /* API */
-public:
+
+ /// Indicates the encoding scheme used in this input stream
+ ///
+ ANTLR_UINT32 m_encoding;
+
+ /* API */
+public:
InputStream(const ANTLR_UINT8* fileName, ANTLR_UINT32 encoding);
InputStream(const ANTLR_UINT8* data, ANTLR_UINT32 encoding, ANTLR_UINT32 size, ANTLR_UINT8* name);
~InputStream();
@@ -150,7 +150,7 @@ public:
ANTLR_UCHAR get_newlineChar() const;
ANTLR_UINT8 get_charByteSize() const;
ANTLR_UINT32 get_encoding() const;
-
+
void set_data( DataType* data );
void set_isAllocated( bool isAllocated );
void set_nextChar( const DataType* nextChar );
@@ -165,81 +165,81 @@ public:
void set_newlineChar( ANTLR_UCHAR newlineChar );
void set_charByteSize( ANTLR_UINT8 charByteSize );
void set_encoding( ANTLR_UINT32 encoding );
-
+
void inc_charPositionInLine();
void inc_line();
void inc_markDepth();
-
+
IntStreamType* get_istream();
-
- /** Function that resets the input stream
- */
+
+ /** Function that resets the input stream
+ */
void reset();
-
- /** Pointer to a function that reuses and resets an input stream by
- * supplying a new 'source'
- */
- void reuse(ANTLR_UINT8* inString, ANTLR_UINT32 size, ANTLR_UINT8* name);
-
+
+ /** Pointer to a function that reuses and resets an input stream by
+ * supplying a new 'source'
+ */
+ void reuse(ANTLR_UINT8* inString, ANTLR_UINT32 size, ANTLR_UINT8* name);
+
- /** Function to return the total size of the input buffer. For streams
- * this may be just the total we have available so far. This means of course that
- * the input stream must be careful to accumulate enough input so that any backtracking
- * can be satisfied.
- */
+ /** Function to return the total size of the input buffer. For streams
+ * this may be just the total we have available so far. This means of course that
+ * the input stream must be careful to accumulate enough input so that any backtracking
+ * can be satisfied.
+ */
ANTLR_UINT32 size();
-
- /** Function to return a substring of the input stream. String is returned in allocated
- * memory and is in same encoding as the input stream itself, NOT internal ANTLR_UCHAR form.
- */
+
+ /** Function to return a substring of the input stream. String is returned in allocated
+ * memory and is in same encoding as the input stream itself, NOT internal ANTLR_UCHAR form.
+ */
StringType substr(ANTLR_MARKER start, ANTLR_MARKER stop);
-
- /** Function to return the current line number in the input stream
- */
+
+ /** Function to return the current line number in the input stream
+ */
ANTLR_UINT32 get_line();
-
- /** Function to return the current line buffer in the input stream
- * The pointer returned is directly into the input stream so you must copy
- * it if you wish to manipulate it without damaging the input stream. Encoding
- * is obviously in the same form as the input stream.
- * \remark
- * - Note taht this function wil lbe inaccurate if setLine is called as there
+
+ /** Function to return the current line buffer in the input stream
+ * The pointer returned is directly into the input stream so you must copy
+ * it if you wish to manipulate it without damaging the input stream. Encoding
+ * is obviously in the same form as the input stream.
+ * \remark
+ * - Note taht this function wil lbe inaccurate if setLine is called as there
* is no way at the moment to position the input stream at a particular line
* number offset.
- */
+ */
const DataType* getLineBuf();
-
- /** Function to return the current offset in the current input stream line
- */
+
+ /** Function to return the current offset in the current input stream line
+ */
ANTLR_UINT32 get_charPositionInLine();
-
- /** Function to set the current position in the current line.
- */
+
+ /** Function to set the current position in the current line.
+ */
void set_charPositionInLine(ANTLR_UINT32 position);
-
- /** Function to override the default newline character that the input stream
- * looks for to trigger the line/offset and line buffer recording information.
- * \remark
- * - By default the chracter '\n' will be installed as the newline trigger character. When this
- * character is seen by the consume() function then the current line number is incremented and the
- * current line offset is reset to 0. The Pointer for the line of input we are consuming
- * is updated to point to the next character after this one in the input stream (which means it
- * may become invalid if the last newline character in the file is seen (so watch out).
+
+ /** Function to override the default newline character that the input stream
+ * looks for to trigger the line/offset and line buffer recording information.
+ * \remark
+ * - By default the chracter '\n' will be installed as the newline trigger character. When this
+ * character is seen by the consume() function then the current line number is incremented and the
+ * current line offset is reset to 0. The Pointer for the line of input we are consuming
+ * is updated to point to the next character after this one in the input stream (which means it
+ * may become invalid if the last newline character in the file is seen (so watch out).
* - If for some reason you do not want the counters and pointers to be restee, you can set the
- * chracter to some impossible character such as '\0' or whatever.
- * - This is a single character only, so choose the last character in a sequence of two or more.
- * - This is only a simple aid to error reporting - if you have a complicated binary input structure
- * it may not be adequate, but you can always override every function in the input stream with your
- * own of course, and can even write your own complete input stream set if you like.
+ * chracter to some impossible character such as '\0' or whatever.
+ * - This is a single character only, so choose the last character in a sequence of two or more.
+ * - This is only a simple aid to error reporting - if you have a complicated binary input structure
+ * it may not be adequate, but you can always override every function in the input stream with your
+ * own of course, and can even write your own complete input stream set if you like.
* - It is your responsiblity to set a valid character for the input stream type. There is no point
- * setting this to 0xFFFFFFFF if the input stream is 8 bit ASCII, as this will just be truncated and never
+ * setting this to 0xFFFFFFFF if the input stream is 8 bit ASCII, as this will just be truncated and never
* trigger as the comparison will be (INT32)0xFF == (INT32)0xFFFFFFFF
- */
+ */
void set_newLineChar(ANTLR_UINT32 newlineChar);
ANTLR_MARKER index_impl();
-
-private:
+
+private:
/** \brief Use the contents of an operating system file as the input
* for an input stream.
*
@@ -249,7 +249,7 @@ private:
* - One of the ANTLR3_ERR_ defines on error.
*/
void createFileStream(const ANTLR_UINT8* fileName);
-
+
/** \brief Use the supplied 'string' as input to the stream
*
* \param data Pointer to the input data
@@ -259,46 +259,46 @@ private:
*/
void createStringStream(const ANTLR_UINT8* data);
void genericSetupStream();
-
+
/// Determine endianess of the input stream and install the
/// API required for the encoding in that format.
///
void setupInputStream();
-
-};
-
-/** \brief Structure for track lex input states as part of mark()
- * and rewind() of lexer.
- */
-template<class ImplTraits>
+
+};
+
+/** \brief Structure for track lex input states as part of mark()
+ * and rewind() of lexer.
+ */
+template<class ImplTraits>
class LexState : public ImplTraits::AllocPolicyType
-{
-public:
+{
+public:
typedef typename ImplTraits::StreamDataType DataType;
-
-private:
- /** Pointer to the next character to be consumed from the input data
- * This is cast to point at the encoding of the original file that
- * was read by the functions installed as pointer in this input stream
- * context instance at file/string/whatever load time.
- */
+
+private:
+ /** Pointer to the next character to be consumed from the input data
+ * This is cast to point at the encoding of the original file that
+ * was read by the functions installed as pointer in this input stream
+ * context instance at file/string/whatever load time.
+ */
const DataType* m_nextChar;
-
- /** The line number we are traversing in the input file. This gets incremented
- * by a newline() call in the lexer grammer actions.
- */
+
+ /** The line number we are traversing in the input file. This gets incremented
+ * by a newline() call in the lexer grammer actions.
+ */
ANTLR_UINT32 m_line;
-
- /** Pointer into the input buffer where the current line
- * started.
- */
+
+ /** Pointer into the input buffer where the current line
+ * started.
+ */
const DataType* m_currentLine;
-
- /** The offset within the current line of the current character
- */
+
+ /** The offset within the current line of the current character
+ */
ANTLR_INT32 m_charPositionInLine;
-
-public:
+
+public:
LexState();
const DataType* get_nextChar() const;
ANTLR_UINT32 get_line() const;
@@ -308,18 +308,18 @@ public:
void set_line( ANTLR_UINT32 line );
void set_currentLine( const DataType* currentLine );
void set_charPositionInLine( ANTLR_INT32 charPositionInLine );
-};
-
-class ParseNullStringException : public std::exception
-{
+};
+
+class ParseNullStringException : public std::exception
+{
virtual const char* what() const noexcept
{
return "Null String";
}
-};
-
+};
+
}
-
-#include "antlr3input.inl"
-
+
+#include "antlr3input.inl"
+
#endif /* _ANTLR_INPUT_H */