# JOE syntax highlight file for Haskell

=Idle
=Comment
=Keyword
=Statement	+Keyword
=Conditional	+Statement +Keyword
=Structure	+Type +Keyword
=Bad
=Constant
=Number		+Constant
=FloatNumber	+Number
=DecNumber	+Number
=HexNumber	+Number
=OctNumber	+Number
=String		+Constant
=StringEscape	+Escape +String
=Character	+String
=CharacterEscape +StringEscape

=StringGap
=Special	+Escape
=ModId		+Type
=VarId		+Ident
=ConId		+Ident
=VarSym		+Operator
=Pragma 	+Preproc

:reset Idle
	*		reset		
	"a-z_"		varid		buffer recolor=-1
	"A-Z"		conormodid	mark recolor=-1
	":"		consym		buffer recolor=-1
	"!#$%&*+./<=>?@\\^|~" varsym	buffer recolor=-1
	"-"		dashorvarsym	mark buffer recolor=-1
	"(),;[]`}"	special		recolor=-1
	"{"		specialorncomment recolor=-1
	"0-9"		integerstart	mark noeat
	"\'"		charlit		recolor=-1
	"\""		strlit		recolor=-1
	
:special Special
	*		reset		noeat
	
:specialorncomment Special
	*		reset		noeat
	"-"		ncommentstart	recolor=-2
	
:ncommentstart Comment comment
	*		reset		noeat call=.comment()
	"#"		pragma		recolor=-3

.subr comment

:ncomment Comment comment
	*		ncomment
	"BFHNTX"	ncomment	noeat call=comment_todo.comment_todo()
	"-"		ncommentmaybeend
	"{"		ncommentmaybenest

:ncommentmaybeend Comment comment
	*		ncomment	noeat
	"}"		ncomment	return

:ncommentmaybenest Comment comment
	*		ncomment	noeat
	"-"		ncomment	call=.comment()

.end

:pragma Pragma
	*		pragma
	"#"		pragmamaybeend1
	"-"		pragmamaybebadend

:pragmamaybeend1 Pragma
	*		pragma		noeat
	"-"		pragmamaybeend2
	
:pragmamaybeend2 Pragma
	*		pragma		noeat
	"}"		reset
	
:pragmamaybebadend Bad
	*		pragma		noeat
	"}"		errorstate	recolor=-2
	
:errorstate Bad
	*		reset

:conormodid ConId
	*		reset		noeat
	"."		probablymodid	recolor=-1
	"a-zA-Z0-9'_"	conormodid
	
# give it color varid to color the dot in case it is *not* a modid in the
# right color
:probablymodid VarSym
	*		ismodid		noeat recolormark recolor=-1
	" \t\r\n\v\f"	reset
	
:ismodid ModId
	*		reset		noeat

:varid VarId
	*		reset		noeat strings
	"case"		stmt
	"class"		struct
	"data"		struct
	"default"	struct
	"deriving"	struct
	"do"		stmt
	"else"		cond
	"if"		cond
	"import"	kw
	"infix"		struct
	"infixl"	struct
	"infixr"	struct
	"instance"	struct
	"let"		stmt
	"module"	struct
	"newtype"	kw
	"of"		stmt
	"then"		cond
	"type"		kw
	"where"		struct
	"_"		kw
done
	"a-zA-Z0-9_'"	varid

:kw Keyword
	*		reset		noeat

:cond Conditional
	*		reset		noeat

:struct Structure
	*		reset		noeat

:stmt Statement
	*		reset		noeat

:consym ConId
	*		reset		noeat strings
	":"		kw
	"::"		kw
done
	"-!#$%&*+./<=>?@\\^|~:" consym

:varsym VarSym
	*		reset		noeat strings
	".."		kw
	"="		kw
	"\\"		kw
	"|"		kw
	"<-"		kw
	"->"		kw
	"@"		kw
	"~"		kw
done
	"-!#$%&*+./<=>?@\\^|~:" varsym

:dashorvarsym VarSym
	*		varsym		noeat
	"-"		dashdash	hold
	
:dashdash VarSym
	*		linecomment	recolormark noeat
	"!#$%&*+./<=>?@\\^|~:" varsym
	"-" 		dashdash
	
:linecomment Comment comment
	*		linecomment
	"BFHNTX"	linecomment	noeat call=comment_todo.comment_todo()
	"\n"		reset

:integerstart DecNumber
	*		decnum
	"0"		intdispatch

:decnum DecNumber
	*		reset		noeat
	"."		floatmaybemant
	"e"		floatexponentstart
	"0-9"		decnum
	
:intdispatch DecNumber
	*		decnum		noeat
	"oO"		octstart
	"xX"		hexstart

# Catch "0o " which is "integer 0" "symbol o" "whitespace"
# and "0oo" which is "integer 0" "symbol oo"
:octstart OctNumber
	*		varid		noeat recolor=-2
	"0-7"		octint		recolor=-3

# Catch "0o08" which is "(octal) integer 0" "integer 8"
:octint OctNumber
	*		reset		noeat
	"0-7"		octint

:hexstart HexNumber
	*		varid		noeat recolor=-2
	"0-9a-fA-F"	hexint		recolor=-3

:hexint HexNumber
	*		reset		noeat
	"0-9a-fA-F"	hexint

# default jumps to varsym because the dot that sent us here is the first
# char of a symbol.
:floatmaybemant FloatNumber
	*		varsym		noeat recolor=-2
	"0-9"		floatmantissa	recolormark

:floatmantissa FloatNumber
	*		reset		noeat
	"0-9"		floatmantissa
	"eE"		floatexponentstart

# after an 'e'
# default jump is for identifiers starting with e directly pasted to a
# number
# recolormark is needed in the case we got here from decnum
:floatexponentstart FloatNumber
	*		varid		noeat recolor=-2
	"+-"		floatexponentstart2
	"0-9"		floatexponent	recolormark

# in case of non-digit:
# the e is a one-char-identifier, the + or - is the start of a symbol
:floatexponentstart2 FloatNumber
	*		unrollfloat	noeat recolor=-3
	"0-9"		floatexponent	recolormark

:floatexponent FloatNumber
	*		reset		noeat
	"0-9"		floatexponent

# the error is just for testing...
:unrollfloat VarId
	*		varsym		noeat recolor=-2

:charlit Character string
	*		charlitend
	"\n"		errorstate	noeat recolor=-2
	"\'"		errorstate	noeat recolor=-2
	"\\"		escape_charlit	mark recolor=-1

:charlitend Character string
	*		charliterror	noeat
	"\'"		reset

:escape_charlit CharacterEscape string
	*		charliterror	recolor=-2
	"0-9"		escdecchar
	"o"		escoctcharstart
	"x"		eschexcharstart
	"abfnrtv\\\"\'"	charlitend
	"A-Z"		escasciichar	buffer
	"^"		escasciictrlchar

:escoctcharstart CharacterEscape string
	*		charliterror	recolor=-3 noeat
	"0-7"		escoctchar

:escoctchar CharacterEscape string
	*		charlitend	noeat
	"0-7"		escoctchar

:escdecchar CharacterEscape string
	*		charlitend	noeat
	"0-9"		escdecchar

:eschexcharstart CharacterEscape string
	*		charliterror	recolor=-3 noeat
	"0-9a-fA-F"	eschexchar

:eschexchar CharacterEscape string
	*		charlitend	noeat
	"0-9a-fA-F"	eschexchar

:escascnotfoundchar CharacterEscape string
	*		charliterror	recolormark noeat
	"A-Z"		escasciichar

:escasciichar CharacterEscape string
	*		charliterror	recolormark
	"A-Z'"		escascnotfoundchar noeat	strings
	"NUL"		asciidonechar
	"STX"		asciidonechar
	"ETX"		asciidonechar
	"EOT"		asciidonechar
	"ENQ"		asciidonechar
	"ACK"		asciidonechar
	"BEL"		asciidonechar
	"BS"		asciidonechar
	"HT"		asciidonechar
	"LF"		asciidonechar
	"VT"		asciidonechar
	"FF"		asciidonechar
	"CR"		asciidonechar
	"SO"		asciiSOchar
	"SI"		asciidonechar
	"DLE"		asciidonechar
	"DC1"		asciidonechar
	"DC2"		asciidonechar
	"DC3"		asciidonechar
	"DC4"		asciidonechar
	"NAK"		asciidonechar
	"SYN"		asciidonechar
	"ETB"		asciidonechar
	"CAN"		asciidonechar
	"EM"		asciidonechar
	"SUB"		asciidonechar
	"ESC"		asciidonechar
	"FS"		asciidonechar
	"GS"		asciidonechar
	"RS"		asciidonechar
	"US"		asciidonechar
	"SP"		asciidonechar
	"DEL"		asciidonechar
done

:asciiSOchar CharacterEscape string
	*		charliterror	recolormark
	"'"		charlitend	noeat
	"H"		charlitend

:escasciictrlchar CharacterEscape string
	*		charliterror	noeat recolor=-3
	"A-Z@[\\]^_"	charlitend

:asciidonechar CharacterEscape string
	*		charlitend noeat

:charliterror Bad
	*		charliterror
	"\'"		charlitend	noeat

# now for string literals

:strlit String string
	*		strlit
	"\""		reset
	"\n"		errorstate	noeat recolor=-2
	"\\"		escape_strlit	mark recolor=-1

:escape_strlit StringEscape string
	*		strliterror	recolor=-2
	"0-9"		escdecstr
	"o"		escoctstrstart
	"x"		eschexstrstart
	"abfnrtv\\\"\'&"	strlit
	"A-Z"		escasciistr	buffer
	"^"		escasciictrlstr
	" \t\n\r\v"	stringgap	recolor=-2

:escoctstrstart StringEscape string
	*		strliterror	recolor=-3 noeat
	"0-7"		escoctstr

:escoctstr StringEscape string
	*		strlit	noeat
	"0-7"		escoctstr

:escdecstr StringEscape string
	*		strlit	noeat
	"0-9"		escdecstr

:eschexstrstart StringEscape string
	*		strliterror	recolor=-3 noeat
	"0-9a-fA-F"	eschexstr

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

:escascnotfoundstr StringEscape string
	*		strliterror	recolormark noeat
	"A-Z"		escasciistr

:escasciistr StringEscape string
	*		strliterror	noeat recolormark
	"A-Z\""		escascnotfoundstr noeat	strings
	"NUL"		asciidonestr
	"STX"		asciidonestr
	"ETX"		asciidonestr
	"EOT"		asciidonestr
	"ENQ"		asciidonestr
	"ACK"		asciidonestr
	"BEL"		asciidonestr
	"BS"		asciidonestr
	"HT"		asciidonestr
	"LF"		asciidonestr
	"VT"		asciidonestr
	"FF"		asciidonestr
	"CR"		asciidonestr
	"SO"		asciiSOstr
	"SI"		asciidonestr
	"DLE"		asciidonestr
	"DC1"		asciidonestr
	"DC2"		asciidonestr
	"DC3"		asciidonestr
	"DC4"		asciidonestr
	"NAK"		asciidonestr
	"SYN"		asciidonestr
	"ETB"		asciidonestr
	"CAN"		asciidonestr
	"EM"		asciidonestr
	"SUB"		asciidonestr
	"ESC"		asciidonestr
	"FS"		asciidonestr
	"GS"		asciidonestr
	"RS"		asciidonestr
	"US"		asciidonestr
	"SP"		asciidonestr
	"DEL"		asciidonestr
done

:asciiSOstr StringEscape string
	*		strlit		noeat
	"H"		strlit

:escasciictrlstr StringEscape string
	*		strliterror	noeat recolor=-3
	"A-Z@[\\]^_"	strlit

:asciidonestr StringEscape string
	*		strlit		noeat

:stringgap StringGap string
	*		strgaperror	recolor=-1
	"\\"		strlit
	" \n\r\t\v"	stringgap

:strgaperror Bad
	*		strgaperror
	"\\"		strlit		
	"\""		reset

:strliterror Bad
	*		strlit		noeat

