# JOE syntax highlight file for SQL

# See c.jsf for more documentation

=Idle
=Ident
=Bad
=Comment
=Constant
=String		+Constant
=Number		+Constant
=Character	+String
=Boolean	+Constant
=Escape
=StringEscape	+Escape +String
=CharacterEscape +StringEscape
=Type
=Keyword
=Statement	+Keyword
=Brace
=Control

:idle Idle
	*		idle
	"\n"		idle
	"#"		line_comment	recolor=-1
	"/"		slash
	"-"		dash
	"0"		first_digit	recolor=-1
	"1-9"		decimal		recolor=-1
	"."		maybe_float
	"\""		string		recolor=-1
	"'"		char		recolor=-1
	"\i@"		ident		buffer
	"{}"		brace		recolor=-1
	",:;=()><[]*&|!~+%^" control	recolor=-1

:brace Brace
	*	idle	noeat

:control Control
	*	idle	noeat

:slash Idle
	*		idle		noeat recolor=-2	# Not sure about this
	"*"		comment		recolor=-2
	"/"		line_comment	recolor=-2

:dash Idle
	*		idle		noeat recolor=-2	# Not sure about this
	"-"		line_comment	recolor=-2

:comment Comment comment
	*		comment
	"*"		maybe_end_comment
	"BFHNTX"	comment		noeat call=comment_todo.comment_todo()

:maybe_end_comment Comment comment
	*		comment		noeat
	"/"		idle
	"*"		maybe_end_comment

:line_comment Comment comment
	*		line_comment
	"BFHNTX"	line_comment	noeat call=comment_todo.comment_todo()
	"\n"		idle

:first_digit Number
	*		idle	noeat
	"xX"		hex
	"."		float
	"eE"		epart
	"0-7"		octal
	"89"		bad_number	recolor=-1

:bad_number Bad
	*		idle	noeat
	"0-9"		bad_number

:octal Number
	*		idle	noeat
	"0-7"		octal
	"89"		bad_number	recolor=-1

:hex Number
	*		idle	noeat
	"0-9A-Fa-f"	hex

:decimal Number
	*		idle	noeat
	"0-9"		decimal
	"eE"		epart
	"."		float

:maybe_float Number
	*		idle	recolor=-2	noeat
	"0-9"		float		recolor=-2

:float Number
	*		idle	noeat
	"eE"		epart
	"0-9"		float

:epart Number
	*		idle	noeat
	"0-9+\-"	enum

:enum Number
	*		idle	noeat
	"0-9"		enum

:string	String string
	*		string
	"\""		idle
	"\\"		string_escape	recolor=-1
	"%"		string_control	recolor=-1

:string_escape StringEscape string
	*		string
	"x"		string_hex1
	"0-7"		string_octal2
	"\n"		string		recolor=-2

:string_hex1 StringEscape string
	*		string		noeat
	"0-9a-fA-F"	string_hex2

:string_hex2 StringEscape string
	*		string		noeat
	"0-9a-fA-F"	string

:string_octal2 StringEscape string
	*		string		noeat
	"0-7"		string_octal3

:string_octal3 StringEscape string
	*		string		noeat
	"0-7"		string

:string_control StringEscape string
	*		string
	"\""		string noeat
	"\n"		idle
	"0-9.\-+ #hjILtz$"	string_control

:char Character string
	*		char
	"\n"		idle
	"'"		idle
	"\\"		char_escape	recolor=-1

:char_escape CharacterEscape string
	*		char
	"x"		char_hex1
	"0-7"		char_octal2
	"\n"		char		recolor=-2

:char_hex1 CharacterEscape string
	*		char		noeat
	"0-9a-fA-F"	char_hex2

:char_hex2 CharacterEscape string
	*		char		noeat
	"0-9a-fA-F"	char

:char_octal2 CharacterEscape string
	*		char		noeat
	"0-7"		char_octal3

:char_octal3 CharacterEscape string
	*		char		noeat
	"0-7"		char

:ident Ident
	*			idle	noeat istrings
	"absolute"		kw
	"add"			kw
	"admindb"		kw
	"all"			kw
	"alphanumeric"		kw
	"alter"			stmt
	"and"			kw
	"any"			kw
	"are"			kw
	"as"			kw
	"asc"			kw
	"assertion"		kw
	"authorization"		kw
	"autoincrement"		kw
	"avg"			kw
	"begin"			kw
	"between"		kw
	"binary"		type
	"bit"			type
	"bit_length"		kw
	"boolean"		type
	"both"			kw
	"by"			kw
	"byte"			kw
	"cascade"		kw
	"catalog"		kw
	"char,"			type
	"character"		type
	"character_length"	kw
	"char_length"		kw
	"check"			kw
	"clause"		kw
	"close"			kw
	"clustered"		kw
	"coalesce"		kw
	"collate"		kw
	"collation"		kw
	"column"		kw
	"commit"		kw
	"comp,"			kw
	"compression"		kw
	"connect"		kw
	"connection"		kw
	"constraint,"		kw
	"constraints"		kw
	"container"		kw
	"contains"		kw
	"convert"		kw
	"count"			kw
	"counter"		kw
	"create"		stmt
	"currency"		kw
	"current_date"		kw
	"current_time"		kw
	"current_timestamp"	kw
	"current_user"		kw
	"cursor"		kw
	"d"			kw
	"database"		kw
	"date"			type
	"datetime"		type
	"day"			type
	"dec,"			type
	"decimal"		type
	"declare"		kw
	"delete"		stmt
	"desc"			kw
	"disallow"		kw
	"disconnect"		kw
	"distinct"		kw
	"distinctrow"		kw
	"domain"		kw
	"double"		kw
	"drop"			stmt
	"eqv"			kw
	"exclusiveconnect"	kw
	"exec,"			kw
	"execute"		kw
	"exists"		kw
	"extract"		kw
	"false"			bool
	"fetch"			kw
	"first"			kw
	"float,"		type
	"float4"		type
	"float8"		type
	"foreign"		kw
	"from"			kw
	"general"		kw
	"grant"			kw
	"group"			kw
	"guid"			kw
	"having"		kw
	"hour"			kw
	"i"			kw
	"identity"		kw
	"ieeedouble"		kw
	"ieeesingle"		kw
	"ignore"		kw
	"image"			kw
	"imp"			kw
	"in"			kw
	"in"			kw
	"index"			kw
	"indexcreatedb"		kw
	"inner"			kw
	"input"			kw
	"insensitive"		kw
	"insert"		stmt
	"int,"			type
	"integer,"		type
	"integer1"		type
	"integer2"		type
	"integer4"		type
	"interval"		kw
	"into"			stmt
	"is"			kw
	"isolation"		kw
	"join"			kw
	"key"			kw
	"language"		kw
	"last"			kw
	"left"			kw
	"level"			kw
	"like"			kw
	"logical,"		kw
	"logical1"		kw
	"long"			type
	"longbinary"		type
	"longchar"		type
	"longtext"		type
	"lower"			kw
	"match"			kw
	"max"			kw
	"memo"			kw
	"min"			kw
	"minute"		kw
	"mod"			kw
	"money"			type
	"month"			type
	"national"		kw
	"nchar"			type
	"nonclustered"		kw
	"not"			kw
	"ntext"			kw
	"null"			kw
	"number"		kw
	"numeric"		kw
	"nvarchar"		type
	"octet_length"		kw
	"oleobject"		kw
	"on"			kw
	"open"			kw
	"option"		kw
	"or"			kw
	"order"			kw
	"outer"			kw
	"output"		kw
	"owneraccess"		kw
	"pad"			kw
	"parameters"		kw
	"partial"		kw
	"password"		kw
	"percent"		kw
	"pivot"			kw
	"position"		kw
	"precision"		kw
	"prepare"		kw
	"primary"		kw
	"privileges"		kw
	"proc,"			kw
	"procedure"		kw
	"public"		kw
	"real"			type
	"references"		kw
	"restrict"		kw
	"revoke"		kw
	"right"			kw
	"rollback"		kw
	"schema"		kw
	"second"		kw
	"select"		stmt
	"selectschema"		kw
	"selectsecurity"	kw
	"set"			stmt
	"short"			kw
	"single"		kw
	"size"			kw
	"smalldatetime"		type
	"smallint"		type
	"smallmoney"		type
	"some"			kw
	"space"			kw
	"sql"			kw
	"sqlcode,"		kw
	"sqlerror,"		kw
	"sqlstate"		kw
	"stdev"			kw
	"stdevp"		kw
	"string"		kw
	"substring"		kw
	"sum"			kw
	"sysname"		kw
	"system_user"		kw
	"table"			kw
	"tableid"		kw
	"temporary"		kw
	"text"			kw
	"time"			type
	"timestamp"		type
	"timezone_hour"		kw
	"timezone_minute"	kw
	"tinyint"		type
	"to"			kw
	"top"			kw
	"trailing"		kw
	"transaction"		kw
	"transform"		kw
	"translate"		kw
	"translation"		kw
	"trim"			kw
	"true"			bool
	"union"			kw
	"unique"		kw
	"uniqueidentifier"	kw
	"unknown"		kw
	"update"		stmt
	"updateidentity"	kw
	"updateowner"		kw
	"updatesecurity"	kw
	"upper"			kw
	"usage"			kw
	"user"			kw
	"using"			kw
	"value"			kw
	"values"		kw
	"var"			kw
	"varbinary"		kw
	"varchar"		type
	"varp"			kw
	"varying"		kw
	"view"			kw
	"when"			kw
	"whenever"		kw
	"where"			kw
	"with"			kw
	"work"			kw
	"xor"			kw
	"year"			type
	"yesno"			kw
	"zone"			kw
	"begin"			kw
	"end"			kw
# T-SQl
	"if"			kw
	"then"			kw
	"else"			kw
	"print"			kw
	"case"			kw
	"go"			kw
	"cross"			kw
	"exec"			kw
	"use"			kw
# mysql
	"int"			type
	"char"			type
	"default"		kw
	"type"			kw
	"float"			type
	"begint"		type
	"mediumint"		type
	"longint"		type
	"blob"			type
	"tinyblob"		type
	"mediumblob"		type
	"longblob"		type
	"tinytext"		type
	"mediumtext"		type
	"longtext"		type
	"show"			kw
	"explain"		kw
	"enum"			type
done
	"\c"		ident

:type Type
	*	idle	noeat

:kw Keyword
	*	idle	noeat

:bool Boolean
	*	idle	noeat

:stmt Statement
	*	idle	noeat
