shithub: xml-9atom

ref: 524f6890a72aa3629cc91ecf5c505ffa52f7eda4
dir: /libxpath/dat.h/

View raw version
typedef struct Name Name;
struct Name {
	char *name;
	int quoted;
	Name *next;
};

Name* addname(char *);


typedef struct Func Func;
typedef struct Node Node;

enum {
	Nroot = 0, 	/* ^/ */
	Nstring,   	/* 'bla' */
	Nnumber,   	/* 234 */
	Nchild,    	/* child:: */
	Nattribute,	/* attribute:: */
	Nfunction, 	/* name() */
	Ndescself, 	/* descendant-or-self:: */
	Nand,
	Nor,
	Nindex,
	Neq,
	Nneq,
	Nlt,
	Ngt,
	Nle,
	Nge,
	NEND,
};

char* type2str(int);

struct Node {
	Name *name; 	/* name of node */
	int type;   	/* type of node */
	int number;
	Node *cond; 	/* conditions */
	Func *func; 	/* function */
	Node *anode;	/* A node */
	Node *bnode;	/* B node */
	Node *chain;	/* next node in chain */
	
	Node *next;
};

struct Func {
	Name *name;
	void (*f)(XpResult*, Elem*);
	
	Func *next;
};

void debugprintnodes(Node*, int);
Node* parsexpath(char*);


Node* addcondcnode(int, Node*, Node*);
Node* addnode(Name*, int, Node*);
Node* addnoden(int, Node*);
Node* chainnode(Node*, Node*);

Func* findfunc(Name*);
Func* addfunc(Name*, void (*f)(XpResult*, Elem*));
void initfuncs(void);

void buildsinglestring(XpResult*, char*);
void buildsingleelem(XpResult*, Elem*);
void buildsinglenum(XpResult*, int);

typedef struct Mbuf Mbuf;
struct Mbuf {
	void *ptr;
	Mbuf *next;
};

void regmbuf(void*);

int position(Elem*);
int last(Elem*);