diff options
Diffstat (limited to 'maildrop/token.C')
| -rw-r--r-- | maildrop/token.C | 118 | 
1 files changed, 118 insertions, 0 deletions
| diff --git a/maildrop/token.C b/maildrop/token.C new file mode 100644 index 0000000..c6ab42d --- /dev/null +++ b/maildrop/token.C @@ -0,0 +1,118 @@ +#include "config.h" +#include	"token.h" + + +static const char *names[]={ +		"error", +		"eof", +		"\"...\"", +		"'...'", +		"`...`", +		"=", +		"{", +		"}", +		";", +		"/.../", +                "+", +		"-", +		"*", +		"/", +		"<", +		"<=", +		">", +		">=", +		"==", +		"!=", +		"||", +		"&&", +		"|", +		"&", +		"(", +		")", +		"!", +		"~", +		"lt", +		"le", +		"gt", +		"ge", +		"eq", +		"ne", +		"length", +		"substr", +		",", +		"=~", +		"if", +		"else", +		"elsif", +		"while", +		"to", +		"cc", +		"exception", +		"echo", +		"xfilter", +		"dotlock", +		"flock", +		"logfile", +		"log", +		"include", +		"exit", +		"foreach", +		"getaddr", +		"lookup", +		"escape", +		"tolower", +		"toupper", +		"hasaddr", +		"gdbmopen", +		"gdbmclose", +		"gdbmfetch", +		"gdbmstore", +		"time", +		"import", +		"unset" +		} ; + +static Buffer namebuf; + +const char *Token::Name() +{ +	if (type == qstring) +	{ +		namebuf="string: \""; +		namebuf += buf; +		namebuf += "\""; +		namebuf.push(0); +		return (namebuf); +	} + +	if (type == sqstring) +	{ +		namebuf="string: '"; +		namebuf += buf; +		namebuf += "'"; +		namebuf.push(0); +		return (namebuf); +	} + +	if (type == btstring) +	{ +		namebuf="string: `"; +		namebuf += buf; +		namebuf += "`"; +		namebuf.push(0); +		return (namebuf); +	} + +	if (type == regexpr) +	{ +		namebuf="regexp: "; +		namebuf += buf; +		namebuf.push(0); +		return (namebuf); +	} + +unsigned	t=(unsigned)type; + +	if (t >= sizeof(names)/sizeof(names[0]))	t=0; +	return (names[t]); +} | 
