]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/include/antlr3exception.h
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / libantlr3c-3.2 / include / antlr3exception.h
diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/include/antlr3exception.h b/bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/include/antlr3exception.h
new file mode 100644 (file)
index 0000000..d420ac1
--- /dev/null
@@ -0,0 +1,218 @@
+/** \file\r
+ *  Contains the definition of a basic ANTLR3 exception structure created\r
+ *  by a recognizer when errors are found/predicted.\r
+ */\r
+#ifndef        _ANTLR3_EXCEPTION_H\r
+#define        _ANTLR3_EXCEPTION_H\r
+\r
+// [The "BSD licence"]\r
+// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC\r
+// http://www.temporal-wave.com\r
+// http://www.linkedin.com/in/jimidle\r
+//\r
+// All rights reserved.\r
+//\r
+// Redistribution and use in source and binary forms, with or without\r
+// modification, are permitted provided that the following conditions\r
+// are met:\r
+// 1. Redistributions of source code must retain the above copyright\r
+//    notice, this list of conditions and the following disclaimer.\r
+// 2. Redistributions in binary form must reproduce the above copyright\r
+//    notice, this list of conditions and the following disclaimer in the\r
+//    documentation and/or other materials provided with the distribution.\r
+// 3. The name of the author may not be used to endorse or promote products\r
+//    derived from this software without specific prior written permission.\r
+//\r
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
+// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
+// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
+\r
+#include    <antlr3defs.h>\r
+\r
+/** Indicates that the recognizer received a token\r
+ *  in the input that was not predicted.\r
+ */\r
+#define        ANTLR3_RECOGNITION_EXCEPTION        1\r
+\r
+/** Name of exception #ANTLR3_RECOGNITION_EXCEPTION\r
+ */\r
+#define        ANTLR3_RECOGNITION_EX_NAME  "Recognition Exception"\r
+\r
+/** Indicates that the recognizer was expecting one token and found a\r
+ *  a different one.\r
+ */\r
+#define        ANTLR3_MISMATCHED_TOKEN_EXCEPTION   2\r
+\r
+/** Name of #ANTLR3_MISMATCHED_TOKEN_EXCEPTION\r
+ */\r
+#define        ANTLR3_MISMATCHED_EX_NAME   "Mismatched Token Exception"\r
+\r
+/** Recognizer could not find a valid alternative from the input\r
+ */\r
+#define        ANTLR3_NO_VIABLE_ALT_EXCEPTION      3\r
+\r
+/** Name of #ANTLR3_NO_VIABLE_ALT_EXCEPTION\r
+ */\r
+#define        ANTLR3_NO_VIABLE_ALT_NAME   "No Viable Alt"\r
+\r
+/* Character in a set was not found\r
+ */\r
+#define        ANTLR3_MISMATCHED_SET_EXCEPTION     4\r
+\r
+/* Name of #ANTLR3_MISMATCHED_SET_EXCEPTION\r
+ */\r
+#define        ANTLR3_MISMATCHED_SET_NAME  "Mismatched set"\r
+\r
+/* A rule predicting at least n elements found less than that,\r
+ * such as: WS: " "+;\r
+ */\r
+#define        ANTLR3_EARLY_EXIT_EXCEPTION         5\r
+\r
+/* Name of #ANTLR3_EARLY_EXIT_EXCEPTION\r
+ */\r
+#define        ANTLR3_EARLY_EXIT_NAME       "Early exit"\r
+\r
+#define        ANTLR3_FAILED_PREDICATE_EXCEPTION   6\r
+#define        ANTLR3_FAILED_PREDICATE_NAME        "Predicate failed!"\r
+\r
+#define        ANTLR3_MISMATCHED_TREE_NODE_EXCEPTION   7\r
+#define        ANTLR3_MISMATCHED_TREE_NODE_NAME    "Mismatched tree node!"\r
+\r
+#define        ANTLR3_REWRITE_EARLY_EXCEPTION  8\r
+#define        ANTLR3_REWRITE_EARLY_EXCEPTION_NAME    "Mismatched tree node!"\r
+\r
+#define        ANTLR3_UNWANTED_TOKEN_EXCEPTION 9\r
+#define        ANTLR3_UNWANTED_TOKEN_EXCEPTION_NAME    "Extraneous token"\r
+\r
+#define        ANTLR3_MISSING_TOKEN_EXCEPTION  10\r
+#define        ANTLR3_MISSING_TOKEN_EXCEPTION_NAME    "Missing token"\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/** Base structure for an ANTLR3 exception tracker\r
+ */\r
+typedef        struct ANTLR3_EXCEPTION_struct\r
+{\r
+       /// Set to one of the exception type defines:\r
+       ///\r
+       ///  - #ANTLR3_RECOGNITION_EXCEPTION\r
+       ///  - #ANTLR3_MISMATCHED_TOKEN_EXCEPTION\r
+       ///  - #ANTLR3_NO_VIABLE_ALT_EXCEPTION\r
+       ///  - #ANTLR3_MISMATCHED_SET_EXCEPTION\r
+       ///  - #ANTLR3_EARLY_EXIT_EXCEPTION\r
+       ///  - #ANTLR3_FAILED_PREDICATE_EXCEPTION\r
+       ///  - #ANTLR3_EARLY_EXIT_EXCEPTION\r
+    ///\r
+    ANTLR3_UINT32   type;\r
+\r
+    /** The string name of the exception\r
+     */\r
+    void    *      name;\r
+\r
+    /** The printable message that goes with this exception, in your preferred\r
+     *  encoding format. ANTLR just uses ASCII by default but you can ignore these\r
+     *  messages or convert them to another format or whatever of course. They are\r
+     *  really internal messages that you then decide how to print out in a form that\r
+     *  the users of your product will understand, as they are unlikely to know what\r
+     *  to do with "Recognition exception at: [[TOK_GERUND..... " ;-)\r
+     */\r
+    void    *      message;\r
+\r
+    /** Name of the file/input source for reporting. Note that this may be NULL!!\r
+     */\r
+    pANTLR3_STRING streamName;\r
+\r
+    /** If set to ANTLR3_TRUE, this indicates that the message element of this structure\r
+     *  should be freed by calling ANTLR3_FREE() when the exception is destroyed.\r
+     */\r
+    ANTLR3_BOOLEAN  freeMessage;\r
+\r
+    /** Indicates the index of the 'token' we were looking at when the\r
+     *  exception occurred.\r
+     */\r
+    ANTLR3_MARKER  index;\r
+\r
+    /** Indicates what the current token/tree was when the error occurred. Since not\r
+     *  all input streams will be able to retrieve the nth token, we track it here\r
+     *  instead. This is for parsers, and even tree parsers may set this.\r
+     */\r
+    void       * token;\r
+\r
+    /** Indicates the token we were expecting to see next when the error occurred\r
+     */\r
+    ANTLR3_UINT32   expecting;\r
+\r
+    /** Indicates a set of tokens that we were expecting to see one of when the\r
+     *  error occurred. It is a following bitset list, so you can use load it and use ->toIntList() on it\r
+     *  to generate an array of integer tokens that it represents.\r
+     */\r
+    pANTLR3_BITSET_LIST  expectingSet;\r
+\r
+    /** If this is a tree parser exception then the node is set to point to the node\r
+     * that caused the issue.\r
+     */\r
+    void       * node;\r
+\r
+    /** The current character when an error occurred - for lexers.\r
+     */\r
+    ANTLR3_UCHAR   c;\r
+\r
+    /** Track the line at which the error occurred in case this is\r
+     *  generated from a lexer.  We need to track this since the\r
+     *  unexpected char doesn't carry the line info.\r
+     */\r
+    ANTLR3_UINT32   line;\r
+\r
+    /** Character position in the line where the error occurred.\r
+     */\r
+    ANTLR3_INT32   charPositionInLine;\r
+\r
+    /** decision number for NVE\r
+     */\r
+    ANTLR3_UINT32   decisionNum;\r
+\r
+    /** State for NVE\r
+     */\r
+    ANTLR3_UINT32   state;\r
+\r
+    /** Rule name for failed predicate exception\r
+     */\r
+    void           * ruleName;\r
+\r
+    /** Pointer to the next exception in the chain (if any)\r
+     */\r
+    struct ANTLR3_EXCEPTION_struct * nextException;\r
+\r
+    /** Pointer to the input stream that this exception occurred in.\r
+     */\r
+    pANTLR3_INT_STREAM    input;\r
+\r
+    /** Pointer for you, the programmer to add anything you like to an exception.\r
+     */\r
+    void    *      custom;\r
+\r
+    /** Pointer to a routine that is called to free the custom exception structure\r
+     *  when the exception is destroyed. Set to NULL if nothing should be done.\r
+     */\r
+    void           (*freeCustom)   (void * custom);\r
+    void           (*print)        (struct ANTLR3_EXCEPTION_struct * ex);\r
+    void           (*freeEx)       (struct ANTLR3_EXCEPTION_struct * ex);\r
+\r
+}\r
+    ANTLR3_EXCEPTION;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+\r
+#endif\r