]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/cpp/DataBoardTest/libantlr3c-3.2/include/antlr3basetree.h
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / libantlr3c-3.2 / include / antlr3basetree.h
1 /// \file\r
2 /// Definition of the ANTLR3 base tree.\r
3 ///\r
4 \r
5 #ifndef _ANTLR3_BASE_TREE_H\r
6 #define _ANTLR3_BASE_TREE_H\r
7 \r
8 // [The "BSD licence"]\r
9 // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC\r
10 // http://www.temporal-wave.com\r
11 // http://www.linkedin.com/in/jimidle\r
12 //\r
13 // All rights reserved.\r
14 //\r
15 // Redistribution and use in source and binary forms, with or without\r
16 // modification, are permitted provided that the following conditions\r
17 // are met:\r
18 // 1. Redistributions of source code must retain the above copyright\r
19 //    notice, this list of conditions and the following disclaimer.\r
20 // 2. Redistributions in binary form must reproduce the above copyright\r
21 //    notice, this list of conditions and the following disclaimer in the\r
22 //    documentation and/or other materials provided with the distribution.\r
23 // 3. The name of the author may not be used to endorse or promote products\r
24 //    derived from this software without specific prior written permission.\r
25 //\r
26 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\r
27 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\r
28 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\r
29 // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\r
30 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
31 // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
32 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
33 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
34 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
35 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
36 \r
37 #include    <antlr3defs.h>\r
38 #include    <antlr3collections.h>\r
39 #include    <antlr3string.h>\r
40 \r
41 #ifdef __cplusplus\r
42 extern "C" {\r
43 #endif\r
44 \r
45 /// A generic tree implementation with no payload.  You must subclass to\r
46 /// actually have any user data.  ANTLR v3 uses a list of children approach\r
47 /// instead of the child-sibling approach in v2.  A flat tree (a list) is\r
48 /// an empty node whose children represent the list.  An empty (as in it does not\r
49 /// have payload itself), but non-null node is called "nil".\r
50 ///\r
51 typedef struct ANTLR3_BASE_TREE_struct\r
52 {\r
53 \r
54     /// Implementers of this interface sometimes require a pointer to their selves.\r
55     ///\r
56     void    *       super;\r
57 \r
58     /// Generic void pointer allows the grammar programmer to attach any structure they\r
59     /// like to a tree node, in many cases saving the need to create their own tree\r
60     /// and tree adaptors. ANTLR does not use this pointer, but will copy it for you and so on.\r
61     ///\r
62     void    *       u;\r
63 \r
64     /// The list of all the children that belong to this node. They are not part of the node\r
65     /// as they belong to the common tree node that implements this.\r
66     ///\r
67     pANTLR3_VECTOR  children;\r
68 \r
69     /// This is used to store the current child index position while descending\r
70     /// and ascending trees as the tree walk progresses.\r
71     ///\r
72     ANTLR3_MARKER   savedIndex;\r
73 \r
74     /// A string factory to produce strings for toString etc\r
75     ///\r
76     pANTLR3_STRING_FACTORY strFactory;\r
77 \r
78     /// A pointer to a function that returns the common token pointer\r
79     /// for the payload in the supplied tree.\r
80     ///\r
81     pANTLR3_COMMON_TOKEN                (*getToken)                     (struct ANTLR3_BASE_TREE_struct * tree);\r
82 \r
83     void                                (*addChild)                     (struct ANTLR3_BASE_TREE_struct * tree, void * child);\r
84 \r
85     void                                (*addChildren)                  (struct ANTLR3_BASE_TREE_struct * tree, pANTLR3_LIST kids);\r
86 \r
87     void                                (*createChildrenList)           (struct ANTLR3_BASE_TREE_struct * tree);\r
88 \r
89     void    *                           (*deleteChild)                  (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 i);\r
90 \r
91     void                                (*replaceChildren)              (struct ANTLR3_BASE_TREE_struct * parent, ANTLR3_INT32 startChildIndex, ANTLR3_INT32 stopChildIndex, struct ANTLR3_BASE_TREE_struct * t);\r
92 \r
93     void    *                           (*dupNode)                      (struct ANTLR3_BASE_TREE_struct * dupNode);\r
94 \r
95     void    *                           (*dupTree)                      (struct ANTLR3_BASE_TREE_struct * tree);\r
96 \r
97     ANTLR3_UINT32                       (*getCharPositionInLine)        (struct ANTLR3_BASE_TREE_struct * tree);\r
98 \r
99     void    *                           (*getChild)                     (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 i);\r
100 \r
101     void                                (*setChildIndex)                (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_INT32 );\r
102 \r
103     ANTLR3_INT32                        (*getChildIndex)                (struct ANTLR3_BASE_TREE_struct * tree );\r
104 \r
105     ANTLR3_UINT32                       (*getChildCount)                (struct ANTLR3_BASE_TREE_struct * tree);\r
106 \r
107     struct ANTLR3_BASE_TREE_struct *    (*getParent)                    (struct ANTLR3_BASE_TREE_struct * tree);\r
108 \r
109     void                                (*setParent)                    (struct ANTLR3_BASE_TREE_struct * tree, struct ANTLR3_BASE_TREE_struct * parent);\r
110 \r
111     ANTLR3_UINT32                       (*getType)                      (struct ANTLR3_BASE_TREE_struct * tree);\r
112 \r
113     void    *                           (*getFirstChildWithType)        (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 type);\r
114 \r
115     ANTLR3_UINT32                       (*getLine)                      (struct ANTLR3_BASE_TREE_struct * tree);\r
116 \r
117     pANTLR3_STRING                      (*getText)                      (struct ANTLR3_BASE_TREE_struct * tree);\r
118 \r
119     ANTLR3_BOOLEAN                      (*isNilNode)                    (struct ANTLR3_BASE_TREE_struct * tree);\r
120 \r
121     void                                (*setChild)                     (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 i, void * child);\r
122 \r
123     pANTLR3_STRING                      (*toStringTree)                 (struct ANTLR3_BASE_TREE_struct * tree);\r
124 \r
125     pANTLR3_STRING                      (*toString)                     (struct ANTLR3_BASE_TREE_struct * tree);\r
126 \r
127     void                                (*freshenPACIndexesAll)         (struct ANTLR3_BASE_TREE_struct * tree);\r
128 \r
129     void                                (*freshenPACIndexes)            (struct ANTLR3_BASE_TREE_struct * tree, ANTLR3_UINT32 offset);\r
130 \r
131     void                                (*reuse)                        (struct ANTLR3_BASE_TREE_struct * tree);\r
132 \r
133     void                                (*free)                         (struct ANTLR3_BASE_TREE_struct * tree);\r
134 \r
135 }\r
136     ANTLR3_BASE_TREE;\r
137 \r
138 #ifdef __cplusplus\r
139 }\r
140 #endif\r
141 \r
142 \r
143 #endif\r