/*
 * java.ft -- experimental Pretzel token file for Java
 */

ALPH		[a-zA-Z_$]
ALPHNUM		[a-zA-Z0-9_$]
DIGIT		[0-9]
DECDIGIT	[0-9]
OCTDIGIT	[0-7]
HEXDIGIT	[0-9A-Fa-f]
EXP			([eE][+-]?[0-9]+)

%%

	//
	// symbols

"{"		LBRACE	{"\\{"}
"}"		RBRACE	{"\\}"}
"("		LPAR
")"		RPAR
"["		LBRACK
"]"		RBRACK
";"		SEMI	{"\\mathout; "}
":"		COLON	{":"}
","		COMMA	{"\\mathout, "}
"."		DOT		{"{.}"}

"+"		|
"-"		UNORBINOP
"="		BINOP	{"\\gets"}
"<"		|
">"		BINOP
"!"		UNOP	{"\\lnot"}
"~"		UNOP	{"\\mathord{\\sim}"}
"?"		QUESTION	{"\\mathrel?"}
"=="	BINOP	{"\\equiv"}
"<="	BINOP	{"\\leq"}
">="	BINOP	{"\\geq"}
"!="	BINOP	{"\\neq"}
"||"	BINOP	{"\\lor"}
"&&"	BINOP	{"\\land"}
"++"	|
"--"	INCROP	{"\\mbox{\\tt" + ** + "}"}
"*"		BINOP	{"\\times"}
"/"		BINOP	{"\\div"}
"&"		BINOP	{"\\mathrel{\\&}"}
"|"		BINOP	{"\\mid"}
"^"		BINOP	{"\\oplus"}
"%"		BINOP	{"\\mathbin{\\%}"}
"<<"	BINOP	{"\\ll"}
">>"	BINOP	{"\\gg"}
">>>"	BINOP	{"\\ggg"}				// needs amssymb package
"+="	BINOP	{"\\javaassign{+}"}
"-="	BINOP	{"\\javaassign{-}"}
"*="	BINOP	{"\\javaassign{\\times}"}
"/="	BINOP	{"\\javaassign{\\div}"}
"&="	BINOP	{"\\javaassign{\\&}"}
"|="	BINOP	{"\\javaassign{\\mid}"}
"^="	BINOP	{"\\javaassign{\\oplus}"}
"%="	BINOP	{"\\javaassign{\\%}"}
"<<="	BINOP	{"\\javaassign{\\ll}"}
">>="	BINOP	{"\\javaassign{\\gg}"}
">>>="	BINOP	{"\\javaassign{\\ggg}"}	// needs amssymb package

"//".*	COMMENT	{"\\javacomment" + ** + "\\javacomment"}

	//
	// keywords


"new"		UNOP		{"\\javakey{" + ** + "}\\ "}
"instanceof" BINOP		{"\\in"}
		// alternate:	{"\\mathrel{\\javakey{" + ** + "}}"}

"null"		ID_LIKE		{"\\mathin\\Lambda"}

"class"		|
"interface"	|

"void"		|
"boolean"	|
"byte"		|
"char"		|
"double"	|
"float"		|
"int"		|
"long"		|
"short"		|

"abstract"	|
"final"		|
"native"	|
"protected"	|
"private"	|
"public"	|
"static"	|
"transient"	|
"volatile"	|

"true"		|
"false"		|
"super"		|
"this"		ID_LIKE			{"\\javakey{" + ** + "}"}

"case"		CASE_LIKE		{"\\javakey{" + ** + "}"}
"default"	DEFAULT_LIKE	{"\\javakey{" + ** + "}"}

"synchronized"	SYNC_LIKE	{"\\javakey{" + ** + "}"}


"try"		TRY_LIKE		{"\\javakey{" + ** + "}"}
"catch"		CATCH_LIKE		{"\\javakey{" + ** + "}"}
"finally"	FINALLY_LIKE	{"\\javakey{" + ** + "}"}

"if"		|
"switch"	|
"while"		IF_LIKE			{"\\javakey{" + ** + "}"}

"else"		ELSE_LIKE		{"\\javakey{" + ** + "}"}

"for"		FOR_LIKE		{"\\javakey{" + ** + "}"}
"do"		DO_LIKE			{"\\javakey{" + ** + "}"}

"break"		|
"continue"	|
"return"	|
"throw"		BREAK_LIKE		{"\\javakey{" + ** + "}"}

"throws"	|
"extends"	|
"implements" EXTENDS_LIKE	{"\\javakey{" + ** + "}"}

"package"	|
"import"	IMPORT_LIKE		{"\\javakey{" + ** + "}"}
".*"		DOT_STAR		{"\\mathin.\\mathord{\\ast}"}

	//
	// misc

^"@use\ ".*	CHUNK	{ "\n" + ** + "\n" }
^"@".*		IGNORE	{ "\n" + ** + "\n" }

0[lL]?									|
[1-9]{DECDIGIT}*[lL]?					NUM		{"\\javaint{" + ** + "}"}
0{OCTDIGIT}+[lL]?						NUM		{"\\javaoct{" + ** + "}"}
0[xX]{HEXDIGIT}{HEXDIGIT}*[lL]?			NUM		{"\\javahex{" + ** + "}"}
{DECDIGIT}+"."{DECDIGIT}*{EXP}?[fdFD]?	|
"."{DECDIGIT}+{EXP}?[fdFD]?				|
{DECDIGIT}+{EXP}[fdFD]?					NUM		{"\\javadec{" + ** + "}"}

[a-zA-Z]	ID_LIKE	{"\\mathin{" + ** + "}"}	// math italic for one-char ids
{ALPH}{ALPHNUM}*	ID_LIKE
			{"%\n@index use " + ** + "\n\\javaid{" + ** + "}"}

'([^']|\\')*'		|
\"([^\"]|\\\")*\"	STRING	{"\\verb*\013" + ** + "\013"}

[\ \t\n]				// gobble up whitespace

.						// ignore all non-standard chars
						// (bug in Pretzel?)
%%
