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