Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

abstract_grammar.h

00001 #ifndef _dev_w3_org__2001_blindfold_abstract_grammar
00002 #define _dev_w3_org__2001_blindfold_abstract_grammar
00003 
00004 /****************************************************************/  /*@{*/
00041 
00042 #include "dltree.h"
00043 
00044 typedef struct action {
00045   union {
00046     struct {
00047       struct value *set;
00048       struct value *object;
00049     } addto;
00050     struct {
00051       struct value *outer;
00052       struct value *inner;
00053     } includein;
00054     struct {
00055       struct value *text;
00056     } appendtotext;
00057 #if 0
00058     struct {
00059       char *portname;
00060       char *object;
00061     } sendto;
00062     struct {
00063       struct condition* condition;
00064       struct action* actions;
00065     } infer;
00066     struct {
00067       char *postname;
00068       struct rule *rule;
00069     } spawn;
00070 #endif
00071   } as;
00072   enum { unused1=0, addto, includein, appendtotext, cleartext, nop, onechar
00073 #if 0    
00074      ,sendto, infer, spawn 
00075 #endif
00076   } type;
00077   struct action* next;   
00078 } Action;
00079 
00080 typedef struct value {
00081   enum { unused2=0, local_name, rdfid, text_buffer, literal_string, tuple, subst, current_content } type;
00082   union {
00083     struct {
00084       char *name;
00085     } local_name;
00086     struct {
00087       char *string;
00088     } literal_string;
00089     struct {
00090       char *id;
00091     } rdfid;
00092     struct {
00093       struct value* first;
00094     } tuple;
00095     struct {
00096       int position;       /*  3 for $3, etc,   0 for $$   */
00097       enum part { value_part, content_part, text_part } part;
00098     } subst;
00099   } as;
00100   struct value *next;
00101 } Value;
00102 
00103 typedef struct condition {
00104   enum type7 { unused3=0, contains } type;
00105   union {
00106     struct {
00107       char *container;
00108       struct value *object;
00109     } contains;
00110   } as;
00111   struct condition *next;
00112 }  Condition;
00113 
00114 typedef struct term {
00115   DLTreeNode tree;
00116 
00117   enum term_enum_type { unused=0, literal, rule_pointer, rule_name } type;
00118   union {
00119     char literal;   /* should be some sort of wchar_t, probably;
00120                if so, we need to change length calculation,
00121                see /WIDE?/   */
00122     /* why both?  sometimes we only know the name.  but if we have the
00123        pointer, it'd be dumb not to use it.  We could use a pointer to
00124        some sort of place-holder rule which gets used when the
00125        definition comes along. */
00126     struct rule *rule_pointer;
00127     char *rule_name;
00128     /* charset ?    no, that's a rule_pointer */
00129   } data;
00130   char* name;     /* used for referring to this term in an action */
00131   Action *actions;
00132 
00133 } Term;
00134 
00135 typedef struct branch {
00136   DLTreeNode tree;
00137 }  Branch;
00138 
00139 typedef struct rule{
00140   DLTreeNode tree;
00141   char* name;
00142 }  Rule;
00143 
00144 struct charset_list_node {
00145     struct charset_list_node *next;
00146     struct charset *charset;
00147 };
00148 
00149 typedef struct charset {
00150     struct charset *next_in_grammar;
00151     struct charset_list_node *inclusions;
00152     char present[256];      
00153     char present_only_here[256];      
00154     Rule *rule;
00155     short bits;
00156 } Charset;
00157 
00158 typedef struct {
00159   DLTreeNode tree;
00160 
00161   int anons;
00162   /* could do hash table of rule names... */
00163 
00164   Action *actions;
00165   Action *last_action;        /* I'm not sure if we need this */
00166   char *output_name;    
00167   Charset *first_charset;
00168 
00169 }  Grammar;
00170 
00171 
00177 Rule* add_charset(Grammar *g, char present[256]);
00178 
00179 void combine_charsets(Grammar *g);
00180 
00182 Rule* add_anonymous_rule(Grammar *grammar);
00184 Rule* add_rule(Grammar *grammar, char *name);
00186 Branch* add_branch(Rule *rule);
00188 Rule *obtain_rule(Grammar *grammar, char *name);
00190 Grammar *new_grammar();
00192 void print_grammar(FILE *out, Grammar *);
00194 Term *add_term(Branch *b);
00196 void grammar_copy_term(Term *from, Term *to);
00197 
00198 /* we'll want some
00199    kind of namespace
00200    thing for imported
00201    grammars.    in rule-name stuff. */
00202 
00205 #endif
00206  

Home to blindfold. This page generated via doxygen 1.2.11.1 Wed Oct 10 16:40:33 2001.