diff options
author | antonovvk <antonovvk@yandex-team.ru> | 2022-02-10 16:47:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:52 +0300 |
commit | 37de222addabbef336dcaaea5f7c7645a629fc6d (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /contrib/libs/antlr3_cpp_runtime/include/antlr3exception.hpp | |
parent | 37a63debdc21e372d99e1808cdd31aecf75018c3 (diff) | |
download | ydb-37de222addabbef336dcaaea5f7c7645a629fc6d.tar.gz |
Restoring authorship annotation for <antonovvk@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/antlr3_cpp_runtime/include/antlr3exception.hpp')
-rw-r--r-- | contrib/libs/antlr3_cpp_runtime/include/antlr3exception.hpp | 266 |
1 files changed, 133 insertions, 133 deletions
diff --git a/contrib/libs/antlr3_cpp_runtime/include/antlr3exception.hpp b/contrib/libs/antlr3_cpp_runtime/include/antlr3exception.hpp index 096e649e54..9bc18a0432 100644 --- a/contrib/libs/antlr3_cpp_runtime/include/antlr3exception.hpp +++ b/contrib/libs/antlr3_cpp_runtime/include/antlr3exception.hpp @@ -1,57 +1,57 @@ -/** \file - * Contains the definition of a basic ANTLR3 exception structure created - * by a recognizer when errors are found/predicted. - - * Two things to be noted for C++ Target: - a) This is not the C++ Exception. Consider this just as yet another class. This - has to be like this because there is a inbuilt recovery and hence there is a try..catch - block for every new token. This is not how C++ Exceptions work.Still there is exception support, as we are handling things like OutofMemory by - throwing exceptions - - b) There is no use in implementing templates here, as all the exceptions are grouped in - one container and hence needs virtual functions. But this would occur only when there is - a exception/ while deleting base recognizer. So shouldn't incur the overhead in normal operation - */ +/** \file + * Contains the definition of a basic ANTLR3 exception structure created + * by a recognizer when errors are found/predicted. + + * Two things to be noted for C++ Target: + a) This is not the C++ Exception. Consider this just as yet another class. This + has to be like this because there is a inbuilt recovery and hence there is a try..catch + block for every new token. This is not how C++ Exceptions work.Still there is exception support, as we are handling things like OutofMemory by + throwing exceptions + + b) There is no use in implementing templates here, as all the exceptions are grouped in + one container and hence needs virtual functions. But this would occur only when there is + a exception/ while deleting base recognizer. So shouldn't incur the overhead in normal operation + */ #ifndef _ANTLR3_EXCEPTION_HPP #define _ANTLR3_EXCEPTION_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 { - -/** Base structure for an ANTLR3 exception tracker - */ - -template<class ImplTraits, class StreamType> -class ANTLR_ExceptionBase -{ -public: + +/** Base structure for an ANTLR3 exception tracker + */ + +template<class ImplTraits, class StreamType> +class ANTLR_ExceptionBase +{ +public: typedef typename StreamType::UnitType TokenType; typedef typename StreamType::IntStreamType IntStreamType; typedef typename ImplTraits::AllocPolicyType AllocPolicyType; @@ -60,82 +60,82 @@ public: typedef typename ImplTraits::BitsetType BitsetType; typedef typename ImplTraits::BitsetListType BitsetListType; typedef typename ImplTraits::template ExceptionBaseType<StreamType> ExceptionBaseType; - -protected: - /** The printable message that goes with this exception, in your preferred - * encoding format. ANTLR just uses ASCII by default but you can ignore these - * messages or convert them to another format or whatever of course. They are - * really internal messages that you then decide how to print out in a form that - * the users of your product will understand, as they are unlikely to know what - * to do with "Recognition exception at: [[TOK_GERUND..... " ;-) - */ + +protected: + /** The printable message that goes with this exception, in your preferred + * encoding format. ANTLR just uses ASCII by default but you can ignore these + * messages or convert them to another format or whatever of course. They are + * really internal messages that you then decide how to print out in a form that + * the users of your product will understand, as they are unlikely to know what + * to do with "Recognition exception at: [[TOK_GERUND..... " ;-) + */ StringType m_message; - - /** Name of the file/input source for reporting. Note that this may be empty!! - */ + + /** Name of the file/input source for reporting. Note that this may be empty!! + */ StringType m_streamName; - - /** Indicates the index of the 'token' we were looking at when the - * exception occurred. - */ + + /** Indicates the index of the 'token' we were looking at when the + * exception occurred. + */ ANTLR_MARKER m_index; - - /** Indicates what the current token/tree was when the error occurred. Since not - * all input streams will be able to retrieve the nth token, we track it here - * instead. This is for parsers, and even tree parsers may set this. - */ + + /** Indicates what the current token/tree was when the error occurred. Since not + * all input streams will be able to retrieve the nth token, we track it here + * instead. This is for parsers, and even tree parsers may set this. + */ const TokenType* m_token; - - /** Pointer to the next exception in the chain (if any) - */ - ExceptionBaseType* m_nextException; - - /** Indicates the token we were expecting to see next when the error occurred - */ + + /** Pointer to the next exception in the chain (if any) + */ + ExceptionBaseType* m_nextException; + + /** Indicates the token we were expecting to see next when the error occurred + */ ANTLR_UINT32 m_expecting; - - /** Indicates a set of tokens that we were expecting to see one of when the - * error occurred. It is a following bitset list, so you can use load it and use ->toIntList() on it - * to generate an array of integer tokens that it represents. - */ + + /** Indicates a set of tokens that we were expecting to see one of when the + * error occurred. It is a following bitset list, so you can use load it and use ->toIntList() on it + * to generate an array of integer tokens that it represents. + */ BitsetListType* m_expectingSet; - - /** If this is a tree parser exception then the node is set to point to the node - * that caused the issue. - */ + + /** If this is a tree parser exception then the node is set to point to the node + * that caused the issue. + */ TokenType* m_node; - - /** The current character when an error occurred - for lexers. - */ + + /** The current character when an error occurred - for lexers. + */ ANTLR_UCHAR m_c; - - /** Track the line at which the error occurred in case this is - * generated from a lexer. We need to track this since the - * unexpected char doesn't carry the line info. - */ + + /** Track the line at which the error occurred in case this is + * generated from a lexer. We need to track this since the + * unexpected char doesn't carry the line info. + */ ANTLR_UINT32 m_line; - - /** Character position in the line where the error occurred. - */ + + /** Character position in the line where the error occurred. + */ ANTLR_INT32 m_charPositionInLine; - - /** decision number for NVE - */ + + /** decision number for NVE + */ ANTLR_UINT32 m_decisionNum; - - /** State for NVE - */ + + /** State for NVE + */ ANTLR_UINT32 m_state; - - /** Rule name for failed predicate exception - */ + + /** Rule name for failed predicate exception + */ StringType m_ruleName; - - /** Pointer to the input stream that this exception occurred in. - */ + + /** Pointer to the input stream that this exception occurred in. + */ IntStreamType* m_input; - -public: + +public: StringType& get_message(); StringType& get_streamName(); ANTLR_MARKER get_index() const; @@ -172,36 +172,36 @@ public: virtual ANTLR_UINT32 getType() const = 0; virtual void print() const = 0; virtual void displayRecognitionError( ANTLR_UINT8** tokenNames, StringStreamType& str ) const = 0; - - virtual ~ANTLR_ExceptionBase(); - -protected: + + virtual ~ANTLR_ExceptionBase(); + +protected: ANTLR_ExceptionBase(const StringType& message); -}; - - -template<class ImplTraits, ExceptionType Ex, class StreamType> -class ANTLR_Exception : public ImplTraits::template ExceptionBaseType<StreamType> -{ -public: +}; + + +template<class ImplTraits, ExceptionType Ex, class StreamType> +class ANTLR_Exception : public ImplTraits::template ExceptionBaseType<StreamType> +{ +public: typedef typename ImplTraits::StringType StringType; typedef typename ImplTraits::StringStreamType StringStreamType; typedef typename ImplTraits::BitsetType BitsetType; typedef typename ImplTraits::template ExceptionBaseType<StreamType> BaseType; - -public: + +public: template<typename BaseRecognizerType> ANTLR_Exception(BaseRecognizerType* recognizer, const StringType& message); - + const StringType& get_name() const; virtual StringType getName() const; virtual ANTLR_UINT32 getType() const; virtual void print() const; virtual void displayRecognitionError( ANTLR_UINT8** tokenNames, StringStreamType& str_stream) const; -}; - +}; + } - -#include "antlr3exception.inl" - -#endif + +#include "antlr3exception.inl" + +#endif |