shithub: xml-9atom

ref: 4e09200f7e4bf8791c9c720922734e0759206b72
dir: /libxml/state-machine.h/

View raw version
enum {			/* Lexer Tokens */
	Twhite = 0,
	Topen,
	Tname,
	Tclose,
	Tequal,
	Tendblk,
	Tnulblk,
	Tcomment,
	NumToks
};

enum {			/* Parser states */
	Slost	= 0,
	Sopened	= 1,
	Snamed	= 2,
	Sattred	= 3,
	Sequed	= 4,
	Sendblk	= 5,
	Sclosed	= 6,
	NumStates

};

enum {			/* Parser Actions */
	Aerr	= 0,
	Anop	= 1,
	Aelem	= 2,
	Apcdata	= 3,
	Aattr	= 4,
	Avalue	= 5,
	Aup 	= 6,
	Adown	= 7,
	Acheck	= 8,
	Acomment = 9,
	NumActions
};

static char *
tokstr[] = {	/* lexer token names for debug */
	[Twhite]	"white",	[Topen]		"open",
	[Tname]		"name",		[Tclose]	"close",
	[Tequal]	"equal",	[Tendblk]	"endblk",
	[Tnulblk]	"nulblk",	[Tcomment]	"comment",
};

static char *
stastr[] = {	/* parser state names for debug */
	[Slost]		"lost",		[Sopened]	"opened",
	[Snamed]	"named",	[Sattred]	"attred",
	[Sequed]	"equed",	[Sendblk]	"endblk",
	[Sclosed]	"closed",
};

static char *
actstr[] = {	/* parser action names for debug */
	[Aerr]		"error",	[Anop]		"nop",
	[Apcdata]	"pcdata",	[Aattr]		"attr",
	[Avalue]	"value",	[Aelem]		"elem",
	[Aup]		"up",		[Adown]		"down",
	[Acheck]	"check",	[Acomment]	"comment",
};


static int statab[7][8] = {	/* Parser state transition table */
/*           Twhite	  Topen	   Tname    Tclose   Tequal  Tendblk Tnulblk Tcomment */ 
 [Slost]   { Slost,   Sopened, Slost,   Slost,   Slost,  Slost,  Slost,  Slost },
 [Sopened] { 0,       0,       Snamed,  0,       0,      0,      0,      0 },
 [Snamed]  { Snamed,  0,       Sattred, Sendblk, 0,      Slost,  Slost,  0 },
 [Sattred] { Sattred, 0,       0,       0,       Sequed, 0,      0,      0 },
 [Sequed]  { Sequed,  0,       Snamed,  0,       0,      0,      0,      0 },
 [Sendblk] { 0,       0,       Sclosed, 0,       0,      0,      0,      0 },
 [Sclosed] { 0,       0,       0,       Slost,   0,      0,      0,      0 },
};

static int acttab[7][8] = {	/* Parser action table */
/*           Twhite   Topen Tname    Tclose   Tequal   Tendblk Tnulblk  Tcomment */         
 [Slost]   { Apcdata, Anop, Apcdata, Apcdata, Apcdata, Aup,    Apcdata, Acomment },
 [Sopened] { 0,       0,    Aelem,   0,       0,       0,      0,       0 },
 [Snamed]  { Anop,    0,    Aattr,   Adown,   0,       Anop,   Anop,    0 },
 [Sattred] { Anop,    0,    0,       0,       Anop,    0,      0,       0 },
 [Sequed]  { Anop,    0,    Avalue,  0,       0,       0,      0,       0 },
 [Sendblk] { 0,       0,    Acheck,  0,       0,       0,      0,       0 },
 [Sclosed] { 0,       0,    0,       Anop,    0,       0,      0,       0 },
};