/* Objective Modula-2 Compiler (objm2c) * * @file objm2_ast.h * * Abstract syntax tree interface * * Author: Benjamin Kowarsch * * Copyright (C) 2009 The Objective Modula-2 Project. All rights reserved. * * License: * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met * * 1) This file, or any part thereof, may NOT be hosted on websites which * contain advertising, unless specific prior written permission has been * obtained. The licensor will grant such permission upon request at its * sole discretion to websites the licensor does NOT consider abusive in * their use of advertising. Small notices in the footer of a website * naming corporate rights holders, infrastructure providers or sponsors * are not considered advertising in the context of this license. * * 2) Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 3) Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and other materials provided with the distribution. * * 4) Neither the author's name nor the names of any contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * 5) Where this list of conditions or the following disclaimer, in part or * as a whole is overruled or nullified by applicable law, no permission * is granted to use the software. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * Version history: * * 2.00 2009-05-30 BK new file */ #ifndef OBJM2_AST_H #define OBJM2_AST_H #include "common_types.h" // --------------------------------------------------------------------------- // Opaque AST node handle type // --------------------------------------------------------------------------- // // WARNING: Objects of this opaque type should only be accessed through this // public interface. DO NOT EVER attempt to bypass the public interface. // // The internal data structure of this opaque type is HIDDEN and MAY CHANGE // at any time WITHOUT NOTICE. Accessing the internal data structure directly // other than through the functions in this public interface is UNSAFE and // may result in an inconsistent program state or a crash. typedef opaque_t objm2_ast_node_t; // --------------------------------------------------------------------------- // Status codes // --------------------------------------------------------------------------- typedef /* objm2_ast_status_t */ enum { OBJM2_KVS_STATUS_UNDEFINED = -1, OBJM2_KVS_STATUS_SUCCESS = 1, OBJM2_KVS_STATUS_UNABLE_TO_ALLOCATE } objm2_ast_status_t; // --------------------------------------------------------------------------- // function: objm2_ast_new_node(token, lexeme, status) // --------------------------------------------------------------------------- // // Returns a new AST node for token with lexeme. // --------------------------------------------------------------------------- // function: objm2_ast_add_child(parent, child, status) // --------------------------------------------------------------------------- // // Adds node child to node parent. Returns void. // --------------------------------------------------------------------------- // function: objm2_ast_token(node, status) // --------------------------------------------------------------------------- // // Returns the token of node. // --------------------------------------------------------------------------- // function: objm2_ast_lexeme(node, status) // --------------------------------------------------------------------------- // // Returns the lexeme of node. // --------------------------------------------------------------------------- // function: objm2_ast_parent(node, status) // --------------------------------------------------------------------------- // // Returns the parent of node. // --------------------------------------------------------------------------- // function: objm2_ast_child(node, index, status) // --------------------------------------------------------------------------- // // Returns the child of node at index. // --------------------------------------------------------------------------- // function: objm2_ast_child_count(node, status) // --------------------------------------------------------------------------- // // Returns the number of children of node. // --------------------------------------------------------------------------- // function: objm2_ast_is_parent(node, child, status) // --------------------------------------------------------------------------- // // Returns true if node is the parent of child, false otherwise. #endif /* OBJM2_AST_H */ // END OF FILE