]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/include/antlr3bitset.h
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / libantlr3c-3.2 / include / antlr3bitset.h
diff --git a/bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/include/antlr3bitset.h b/bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/include/antlr3bitset.h
new file mode 100644 (file)
index 0000000..8d74286
--- /dev/null
@@ -0,0 +1,119 @@
+/**\r
+ * \file\r
+ * Defines the basic structures of an ANTLR3 bitset. this is a C version of the \r
+ * cut down Bitset class provided with the java version of antlr 3.\r
+ * \r
+ * \r
+ */\r
+#ifndef        _ANTLR3_BITSET_H\r
+#define        _ANTLR3_BITSET_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
+#include    <antlr3collections.h>\r
+\r
+/** How many bits in the elements\r
+ */\r
+#define        ANTLR3_BITSET_BITS      64\r
+\r
+/** How many bits in a nible of bits\r
+ */\r
+#define        ANTLR3_BITSET_NIBBLE    4\r
+\r
+/** log2 of ANTLR3_BITSET_BITS 2^ANTLR3_BITSET_LOG_BITS = ANTLR3_BITSET_BITS\r
+ */\r
+#define        ANTLR3_BITSET_LOG_BITS  6\r
+\r
+/** We will often need to do a mod operator (i mod nbits).\r
+ *  For powers of two, this mod operation is the\r
+ *  same as:\r
+ *   - (i & (nbits-1)).  \r
+ *\r
+ * Since mod is relatively slow, we use an easily\r
+ * precomputed mod mask to do the mod instead.\r
+ */\r
+#define        ANTLR3_BITSET_MOD_MASK  ANTLR3_BITSET_BITS - 1\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+typedef struct ANTLR3_BITSET_LIST_struct\r
+{\r
+       /// Pointer to the allocated array of bits for this bit set, which\r
+    /// is an array of 64 bit elements (of the architecture). If we find a \r
+    /// machine/C compiler that does not know anything about 64 bit values\r
+    ///        then it should be easy enough to produce a 32 bit (or less) version\r
+    /// of the bitset code. Note that the pointer here may be static if laid down\r
+       /// by the code generation, and it must be copied if it is to be manipulated\r
+       /// to perform followset calculations.\r
+    ///\r
+    pANTLR3_BITWORD   bits;\r
+\r
+    /// Length of the current bit set in ANTLR3_UINT64 units.\r
+    ///\r
+    ANTLR3_UINT32    length;\r
+}\r
+       ANTLR3_BITSET_LIST;\r
+\r
+typedef        struct ANTLR3_BITSET_struct\r
+{\r
+       /// The actual bits themselves\r
+       ///\r
+       ANTLR3_BITSET_LIST                              blist;\r
+\r
+    pANTLR3_BITSET                                     (*clone)            (struct ANTLR3_BITSET_struct  * inSet);\r
+    pANTLR3_BITSET                                     (*bor)                  (struct ANTLR3_BITSET_struct  * bitset1, struct ANTLR3_BITSET_struct * bitset2);\r
+    void                                                       (*borInPlace)   (struct ANTLR3_BITSET_struct  * bitset,  struct ANTLR3_BITSET_struct * bitset2);\r
+    ANTLR3_UINT32                                      (*size)                 (struct ANTLR3_BITSET_struct  * bitset);\r
+    void                                                       (*add)                  (struct ANTLR3_BITSET_struct  * bitset, ANTLR3_INT32 bit);\r
+    void                                                       (*grow)                 (struct ANTLR3_BITSET_struct  * bitset, ANTLR3_INT32 newSize);\r
+    ANTLR3_BOOLEAN                                     (*equals)           (struct ANTLR3_BITSET_struct  * bitset1, struct ANTLR3_BITSET_struct * bitset2);\r
+    ANTLR3_BOOLEAN                                     (*isMember)         (struct ANTLR3_BITSET_struct  * bitset, ANTLR3_UINT32 bit);\r
+    ANTLR3_UINT32                                      (*numBits)          (struct ANTLR3_BITSET_struct  * bitset);\r
+    void                                                       (*remove)           (struct ANTLR3_BITSET_struct  * bitset, ANTLR3_UINT32 bit);\r
+    ANTLR3_BOOLEAN                                     (*isNilNode)        (struct ANTLR3_BITSET_struct  * bitset);\r
+    pANTLR3_INT32                                      (*toIntList)    (struct ANTLR3_BITSET_struct  * bitset);\r
+\r
+    void                                                       (*free)                 (struct ANTLR3_BITSET_struct  * bitset);\r
+\r
+\r
+}\r
+    ANTLR3_BITSET;\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+\r
+\r
+#endif\r
+\r