1/** \file 2 * Abstraction of Common tree to provide payload and string representation of node. 3 * 4 * \todo May not need this in the end 5 */ 6 7#ifndef ANTLR3_PARSETREE_H 8#define ANTLR3_PARSETREE_H 9 10// [The "BSD licence"] 11// Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC 12// http://www.temporal-wave.com 13// http://www.linkedin.com/in/jimidle 14// 15// All rights reserved. 16// 17// Redistribution and use in source and binary forms, with or without 18// modification, are permitted provided that the following conditions 19// are met: 20// 1. Redistributions of source code must retain the above copyright 21// notice, this list of conditions and the following disclaimer. 22// 2. Redistributions in binary form must reproduce the above copyright 23// notice, this list of conditions and the following disclaimer in the 24// documentation and/or other materials provided with the distribution. 25// 3. The name of the author may not be used to endorse or promote products 26// derived from this software without specific prior written permission. 27// 28// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 29// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 30// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 31// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 32// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 33// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 37// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 39#include <antlr3basetree.h> 40 41#ifdef __cplusplus 42extern "C" { 43#endif 44 45typedef struct ANTLR3_PARSE_TREE_struct 46{ 47 /** Any interface that implements methods in this interface 48 * may need to point back to itself using this pointer to its 49 * super structure. 50 */ 51 void * super; 52 53 /** The payload that the parse tree node passes around 54 */ 55 void * payload; 56 57 /** An encapsulated BASE TREE strcuture (NOT a pointer) 58 * that perfoms a lot of the dirty work of node management 59 */ 60 ANTLR3_BASE_TREE baseTree; 61 62 /** How to dup this node 63 */ 64 pANTLR3_BASE_TREE (*dupNode) (struct ANTLR3_PARSE_TREE_struct * tree); 65 66 /** Return the type of this node 67 */ 68 ANTLR3_UINT32 (*getType) (struct ANTLR3_PARSE_TREE_struct * tree); 69 70 /** Return the string representation of the payload (must be installed 71 * when the payload is added and point to a function that knwos how to 72 * manifest a pANTLR3_STRING from a node. 73 */ 74 pANTLR3_STRING (*toString) (struct ANTLR3_PARSE_TREE_struct * payload); 75 76 void (*free) (struct ANTLR3_PARSE_TREE_struct * tree); 77 78} 79 ANTLR3_PARSE_TREE; 80 81#ifdef __cplusplus 82} 83#endif 84 85#endif 86