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;
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;
00120
00121
00122
00123
00124
00125
00126 struct rule *rule_pointer;
00127 char *rule_name;
00128
00129 } data;
00130 char* name;
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
00163
00164 Action *actions;
00165 Action *last_action;
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
00199
00200
00201
00202
00205 #endif
00206