# highlighting for Logtalk source files (https://logtalk.org/)
#
#	written by Paulo Moura (pmoura@logtalk.org)
#	last revised on July 31, 2020

comment start "%"
comment delim "/*" "*/" multiline nested

string delim "\"" "\"" escape "\\"

environment string delim "'" "'" begin
	specialchar = '\\([\\abfnrtv"\']|(x[a-fA-F0-9]+|[0-7]+)\\)'
end

keyword =	'\<(abolish|c(urrent|reate))_(object|protocol|category)(?=\()',
			'\<(object|protocol|category)_property(?=\()',
			'\<co(mplements_object|nforms_to_protocol)(?=\()',
			'\<extends_(object|protocol|category)(?=\()',
			'\<imp(lements_protocol|orts_category)(?=\()',
			'\<(instantiat|specializ)es_class(?=\()',
			'\<(current_event|(abolish|define)_events)(?=\()',
			'\<(create|current|set)_logtalk_flag(?=\()',
			'\<logtalk_(compile|l(oad|oad_context|ibrary_path)|make(_target_action)?)(?=\()',
			'\<(logtalk_make)\>'

keyword =	'\<(after|before)(?=\()',
			'\<forward(?=\()',
			'\<(context|parameter|this|se(lf|nder))(?=\()',
			'\<(current_predicate|predicate_property)(?=\()',
			'\<(expand_(goal|term)|(goal|term)_expansion|phrase)(?=\()',
			'\<(clause|retract(all)?)(?=\()',
			'\<a(bolish|ssert(a|z))(?=\()',
			'\<(ca(ll|tch)|throw)(?=\()',
			'\<(uninstantiation|type|domain|existence|permission|representation|evaluation|resource|syntax)_error(?=\()',
			'\<((bag|set)of|f(ind|or)all)(?=\()',
			'\<threaded(_(ca(ll|ncel)|once|ignore|exit|peek|wait|notify))?(?=\()',
			'\<threaded_engine(_(create|destroy|self|next|next_reified|yield|post|fetch))?(?=\()',
			'\<(subsumes_term|unify_with_occurs_check)(?=\()',
			'\<(functor|arg|copy_term|numbervars|term_variables)(?=\()',
			'\<(rem|m(ax|in|od)|abs|div|sign)(?=\()',
			'\<(float_(integer|fractional)_part|float)(?=\()',
			'\<(floor|t(an|runcate)|round|ceiling)(?=\()',
			'\<(cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|xor)(?=\()',
			'\<(var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|ground|acyclic_term)(?=\()',
			'\<compare(?=\()',
			'\<(curren|se)t_(in|out)put(?=\()',
			'\<(open|close)(?=\()',
			'\<flush_output(?=\()',
			'\<(flush_output|at_end_of_stream)\>',
			'\<(stream_property|at_end_of_stream|set_stream_position)(?=\()',
			'\<(get|p(eek|ut))_(byte|c(har|ode))(?=\()',
			'\<nl(?=\()', '\<(nl)\>',
			'\<(read(_term)?)(?=\()',
			'\<(write(q|_(canonical|term))?)(?=\()',
			'\<(op|current_op)(?=\()',
			'\<((current_)?char_conversion)(?=\()',
			'\<atom_(length|c(hars|o(ncat|des)))(?=\()',
			'\<(char_code|sub_atom)(?=\()',
			'\<number_(c(har|ode)s)(?=\()',
			'\<(set|current)_prolog_flag(?=\()',
			'\<halt(?=\()', '\<(halt)\>',
			'\<(ignore|once)(?=\()',
			'\<((key)?sort)(?=\()',
			'\<(true|fa(il|lse)|repeat|(instantiation|system)_error)\>',
			'\<(e|pi|as|is|rem|mod|div)\>'


variable =	'\<[A-Z_][A-Za-z0-9_]*'

cbracket =	"{|}"

preproc =	'^[[:blank:]]*:-[[:blank:]](c(a(lls|tegory)|oinductive)|p(ublic|r(ot(ocol|ected)|ivate))|e(l(if|se)|n(coding|sure_loaded)|xport)|i(f|n(clude|itialization|fo))|alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|od(e|ule)|ultifile)|reexport|s(et_(logtalk|prolog)_flag|ynchronized)|o(bject|p)|use(s|_module))(?=\()',
			'^[[:blank:]]*:-[[:blank:]](e(lse|nd(if|_(category|object|protocol)))|built_in|dynamic|synchronized|threaded)\.'

preproc =	'\<(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=\()'

normal =	'\<[a-z][A-Za-z0-9_]*'

number =	'0\'\\.|0\'.|0b[0-1]+|0o[0-7]+|0x[0-9a-fA-F]+|[0-9]+(\.[0-9]+)?([eE]([-+])?[0-9]+)?'

symbol =	"^",
			"::", "^^", ":",
			">>", "<<", "/\\", "\\/", "\\",
			"=:=", "=\\=", "<", "=<", ">", ">=",
			"=..",
			"\\==", "==", "@=<", "@<", "@>=", "@>",
			"=", "\\=",
			"+", "-", "**", "*", "//", "/",
			"-->",
			"!", "->", ";", "\\+",
			"?", "@",
			":-"
