ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
semtrex.h
Go to the documentation of this file.
1 
14 #ifndef _CEPTR_SEMTREX_H
15 #define _CEPTR_SEMTREX_H
16 
17 #include "tree.h"
18 
19 enum StateType {StateSymbol,StateAny,StateValue,StateSplit,StateMatch,StateGroupOpen,StateGroupClose,StateDescend,StateWalk,StateNot};
20 typedef int StateType;
21 
30 enum {TransitionDown=1,TransitionNone=0x8000};
31 #define isTransitionPop(t) (t<0)
32 #define isTransitionNext(t) (t==0)
33 
34 typedef int TransitionType;
35 
36 typedef struct SState SState;
37 
41 typedef struct SgroupOpen {
43  int uid;
44 } SgroupOpen;
45 
49 typedef struct SgroupClose {
50  SState *openP;
51 } SgroupClose;
52 
53 #define LITERAL_NOT 0x01
54 #define LITERAL_SET 0x02
55 typedef struct Svalue {
56  int flags;
57  T *values;
58 } Svalue;
59 
60 typedef struct Sliteral {
61  int flags;
62  T *symbols;
63 } Sliteral;
64 
65 
70 typedef union STypeData
71 {
76 } STypeData;
77 
83 struct SState {
84  struct SState *out;
85  TransitionType transition;
86  StateType type;
87  struct SState *out1;
88  TransitionType transition1;
89  StateType type_;
90 
91  int _did;
93 };
94 SState *G_cur_stx_state; // global for highlighting the current state when doing an stx FSA dump
95 
96 SState * _stx_makeFA(T *s,int *statesP);
97 void _stx_freeFA(SState *s);
98 int _t_match(T *semtrex,T *t);
99 int _t_matchr(T *semtrex,T *t,T **r);
100 T *_stx_get_matched_node(Symbol s,T *match_results,T *match_tree,int *sibs);
101 void _stx_replace(T *semtrex,T *t,T *replace);
102 T *_t_get_match(T *result,Symbol group);
103 T *__t_embody_from_match(SemTable *sem,T *match,T *t);
104 T *_t_embody_from_match(SemTable *sem,T *match,Symbol group,T *t);
105 char * _dump_semtrex(SemTable *sem,T *s,char *buf);
106 T *makeASCIITree(char *c);
107 T *parseSemtrex(SemTable *sem,char *stx);
108 T *_stx_results2sem_map(SemTable *sem,T *match_results,T *match_tree);
109 
110 T *__stxcv(T *stxx,char c);
111 T *__stxcvm(T *stxx,int not,int count,...);
112 
113 T *asciiT_toi(T* asciiT,T* match,T *t,Symbol s);
114 T *asciiT_tol(T* asciiT,T* match,T *t,Symbol s);
115 T *asciiT_tof(T* asciiT,T* match,T *t,Symbol s);
116 T *asciiT_tos(T* asciiT,T* match,T *t,Symbol s);
117 T *asciiT_toc(T* asciiT,T* match,T *t,Symbol s);
118 
119 T *wrap(T *tokens,T *results, Symbol contents_s, Symbol open_s);
120 
122 #define _sl(t,s) __sl(t,false,1,s)
123 
125 #define _sln(t,s) __sl(t,true,1,s)
126 
127 T *__sl(T *p, bool not,int count, ...);
128 
130 #define DS(l,t) {char buf[1000];puts("\n" #l ":");_dump_semtrex(G_sem,t,buf);puts(buf);}
131 
132 #endif
133 
134 void __stx_dump(SState *s,char *buf);
135 char * _stx_dump(SState *s,char *buf);
136 void stx_dump(T *s);
137 char G_stx_dump_buf[100000];
int _did
used to hold a mark when freeing and printing out FSA to prevent looping.
Definition: semtrex.h:91
Definition: ceptr_types.h:114
union STypeData STypeData
SemanticID symbol
the symbol that describes the group semantically
Definition: semtrex.h:42
T * asciiT_toc(T *asciiT, T *match, T *t, Symbol s)
Definition: semtrex.c:1270
T * asciiT_tos(T *asciiT, T *match, T *t, Symbol s)
Definition: semtrex.c:1261
SgroupOpen groupo
Group data for matching for StateGroup type states.
Definition: semtrex.h:74
Svalue value
Value data to match on for StateValue type states.
Definition: semtrex.h:73
semantic trees header file
T * __sl(T *p, bool not, int count,...)
Definition: semtrex.c:1279
T * asciiT_tof(T *asciiT, T *match, T *t, Symbol s)
Definition: semtrex.c:1251
T * makeASCIITree(char *c)
Definition: semtrex.c:1206
StateType type_
copy of state type needed for patch to grab (far too tricky)
Definition: semtrex.h:89
TransitionType transition1
will be: TransitionNextChild=0,TransitionUp=-1,TransitionDown=1
Definition: semtrex.h:88
SState * _stx_makeFA(T *s, int *statesP)
Definition: semtrex.c:323
int _t_match(T *semtrex, T *t)
Definition: semtrex.c:809
T * _t_get_match(T *result, Symbol group)
Definition: semtrex.c:848
SgroupClose groupc
Group data for matching for StateGroup type states.
Definition: semtrex.h:75
T * _t_embody_from_match(SemTable *sem, T *match, Symbol group, T *t)
Definition: semtrex.c:873
int _t_matchr(T *semtrex, T *t, T **r)
Definition: semtrex.c:798
void _stx_freeFA(SState *s)
Definition: semtrex.c:367
struct SgroupOpen SgroupOpen
STypeData data
a union to hold the data for which ever type of SState this is
Definition: semtrex.h:92
T * asciiT_toi(T *asciiT, T *match, T *t, Symbol s)
Definition: semtrex.c:1233
struct SState * out
which state to go to next
Definition: semtrex.h:84
Definition: semtrex.h:55
TransitionType transition
will be: TransitionNextChild=0,TransitionDown=1, or a negative number which means pop up that many le...
Definition: semtrex.h:85
Definition: semtrex.h:83
Sliteral symbol
Symbol to match on for StateSymbol type states.
Definition: semtrex.h:72
T * parseSemtrex(SemTable *sem, char *stx)
Definition: semtrex.c:1298
T * asciiT_tol(T *asciiT, T *match, T *t, Symbol s)
Definition: semtrex.c:1242
struct SgroupClose SgroupClose
T * _stx_results2sem_map(SemTable *sem, T *match_results, T *match_tree)
Definition: semtrex.c:2029
char * _dump_semtrex(SemTable *sem, T *s, char *buf)
Definition: semtrex.c:1096
StateType type
what type of state this is
Definition: semtrex.h:86
int uid
unique id for the group
Definition: semtrex.h:43
struct SState * out1
which alternate state to go to next in the case this is a Split state
Definition: semtrex.h:87