;;;-*- Mode: Lisp; Package: XLE -*- ;;;; XLE-Web users are granted the rights to distribute and use this software ;;;; as governed by the terms of the Lisp Lesser GNU Public License ;;;; (http://opensource.franz.com/preamble.html), also known as the LLGPL. ;;;; Author: Paul Meurer (paul.meurer@aksis.uib.no) ;;;; Aksis, Unifob, University of Bergen, Norway ;;;; http://www.aksis.uib.no (in-package :XLE) #|| /* (c) 2002-2004 by the Palo Alto Research Center. All rights reserved */ /* (c) 1996-2001 by the Xerox Corporation. All rights reserved */ /* trees.h defines display tree data structures */ #ifndef TREES_H #define TREES_H /* a DTree is a Displayed Tree Node */ /* it has layout information as well as structural information */ enum DTreeProps {DTREE_NUMBERS = 1, /* show the node numbers */ DTREE_PARTIALS = 2, /* show partials */ DTREE_ATTRIBUTES = 4, /* show the attributes that */ /* contains each node */ DTREE_TOKENS = 8}; /* show tokens */ /* ------------------------------------------------------ */ /* When the user selects a solution to a particular tree, */ /* the pair is stored on the edge */ /* using the TreeSelection data structure. */ /* ------------------------------------------------------ */ struct TreeSelection { DTree *tree; RestrictedSolution *selection; TreeSelection *next; }; ||# ;; struct DTree { (ff:def-foreign-type DTree (:struct ;; Edge *edge; /* the edge in the chart that this is a tree for */ (edge :unsigned-long) ;; SubTree *subtree; /* the subtree chosen from that edge */ (subtree :unsigned-long) ;; DTree *mother; /* this makes navigation easier */ (mother :unsigned-long) ;; DTree *partial; /* all DTrees are binary branching, */ (partial :unsigned-long) ;; DTree *complete; /* though the display may be n-ary */ (complete :unsigned-long) ;; int xpos, ypos; /* layout information */ (xpos :int) (ypos :int) ;; char *label; /* the label displayed */ (label :unsigned-long) ;; RestrictedSolution *solutions; /* the packed solutions to this tree. */ (solutions :unsigned-long) ;; EdgeList *surface_corr; /* The surface correlations for this tree. */ (surface_corr :unsigned-long) ;; DTree *surface; /* The surface form for this tree */ (surface :unsigned-long) ;; unsigned int internal:1; /* this node is an internal partial (not ;; displayed) */ (internal (:bit 1)) ;; unsigned int show_internals:1; /* Show internal structure. */ (show_internals (:bit 1)) ;; unsigned int surface_checked:1; /* the tree has been checked to see if it ;; has a surface form. */ (surface_checked (:bit 1)) ;; unsigned int invalid:1; /* the tree has no solutions. */ (invalid (:bit 1)) ;; unsigned int dummy:1; /* the tree is a dummy tree used to display ;; solutions from a prolog term that has been ;; read in. */ (dummy (:bit 1)) ;; unsigned int all:1; /* All solutions have been computed. */ (all (:bit 1)) ;; unsigned int has_selection:1; /* the tree has a selection somewhere */ (has_selection (:bit 1)) )) ;;}; #|| struct DTreeList { DTree *item; SubTree *subtree; InternalSolution *solution; DTreeList *next; }; #define GOODTREES "GoodTrees" #define TREES "TREES" /* these procedures are exported to TCL */ void print_tree_as_sexp(FILE *file, DTree *tree, int depth); ||# ;; int count_trees(Edge*, int); (define-foreign-function "count_trees" ((edge :unsigned-long) (goodOnly :int) ) :int :lisp-name count_trees :module +xle-module-path+) ;; int tree_id(DTree *tree); (define-foreign-function "tree_id" ((tree :unsigned-long) ) :int :lisp-name tree_id :module +xle-module-path+) #|| DTreeList *get_good_trees(Edge *edge); RestrictedSolution *get_tree_solutions(DTree *tree, int all); int tree_has_solutions(DTree *tree); int box_tree_p(DTree *tree); ||# ;; DTree *get_next_tree(DTree *tree, Edge *edge, int prev, int goodOnly); (define-foreign-function "get_next_tree" ((tree :unsigned-long) (edge :unsigned-long) (prev :int) (goodOnly :int) ) :unsigned-long :lisp-name get_next_tree :module +xle-module-path+) ;; DTree* get_next_subtree(DTree* node, Edge *edge, int prev); (define-foreign-function "get_next_subtree" ((node :unsigned-long) (edge :unsigned-long) (prev :int) ) :unsigned-long :lisp-name get_next_subtree :module +xle-module-path+) #|| DTree *get_next_display_tree(DTree *tree, Edge *edge, int prev); Graph *get_next_fstructure(DTree *tree, Graph *fstructure, int prev); RestrictedSolution *first_dnf_tree_solution(RestrictedSolution *solutions, DTree *tree, int prev); RestrictedSolution *next_dnf_tree_solution(RestrictedSolution *solution, DTree *tree, int prev); RestrictedSolution *chosen_solution(RestrictedSolution *solutions); ||# ;; int count_tree_solutions(DTree *tree, int all); (define-foreign-function "count_tree_solutions" ((tree :unsigned-long) (all :int) ) :int :lisp-name count_tree_solutions :module +xle-module-path+) #|| void toggle_fs_selection(DTree *tree, Graph *fstructure); RestrictedSolution *get_tree_selection(DTree *tree); DTree* get_sample_tree(Edge*, RestrictedSolution*, DTree*); void mark_alternatives(DTree*); void check_tree(DTree *node); DTree *surface_form(DTree *node); DTree* new_tree(Edge *head); DTree* copy_tree(DTree *tree); void set_show_internals(DTree *tree, int); DTree *find_tree(DTree *pattern, Edge *edge, int surface); void mark_tree_validity(DTree *tree); void find_spanning_edges(DTree *leftnode, DTree *rightnode); int equal_trees(DTree *tree1, DTree *tree2); DTree *tree_root(DTree *tree); void clear_selections(DTree *tree); int tree_has_restricted_solution(DTree *tree, RestrictedSolution *rs); int tree_has_internal_solution(DTree *tree, InternalSolution *internal); void layout_tree(Tcl_Interp*, DTree*, DTreeProps, int, int, char*); void display_dtree_node(Tcl_Interp *interp, DTree *node, int mx, int my, int width, char *canvas, int showAlternatives); DTree *sample_subtree(Edge *edge, SubTree *subtree); void clear_tree_node_solutions(DTree *node); int pruned_tree(DTree *tree); #endif ||#