<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd" [
  <!ENTITY event_handlers "after|before">
  <!ENTITY message_forwarding_handler "forward">
  <!ENTITY method_execution_context "context|parameter|this|se(lf|nder)">
  <!ENTITY reflection "current_predicate|predicate_property">
  <!ENTITY dcgs "expand_(goal|term)|(goal|term)_expansion|phrase">
  <!ENTITY entity1 "(abolish|c(reate|urrent))_(object|protocol|category)">
  <!ENTITY entity2 "(object|protocol|category)_property">
  <!ENTITY entity_relations "co(mplements_object|nforms_to_protocol)|extends_(object|protocol|category)|imp(lements_protocol|orts_category)|(instantiat|specializ)es_class">
  <!ENTITY events "current_event|(abolish|define)_events">
  <!ENTITY flags "(create|current|set)_logtalk_flag">
  <!ENTITY compiling_loading_and_library_paths "logtalk_(compile|l(ibrary_path|oad|oad_context)|make(_target_action)?)">
  <!ENTITY database "clause|retract(all)?|a(bolish|ssert(a|z))">
  <!ENTITY control "ca(ll|tch)|throw|(type|domain|existence|permission|representation|evaluation|resource|syntax)_error">
  <!ENTITY all_solutions "(bag|set)of|f(ind|or)all">
  <!ENTITY multi_threading_predicates "threaded(_(ca(ll|ncel)|once|ignore|exit|peek|wait|notify))?">
  <!ENTITY engine_predicates "threaded_engine(_(create|destroy|self|next|next_reified|yield|post|fetch))?">
  <!ENTITY term_unification "subsumes_term|unify_with_occurs_check">
  <!ENTITY term_creation_and_decomposition "functor|arg|copy_term|numbervars|term_variables">
  <!ENTITY evaluable_functors "div|rem|m(ax|in|od)|abs|sign|float(_(integer|fractional)_part)?|floor|truncate|round|ceiling">
  <!ENTITY other_arithmetic_functors "cos|a(cos|sin|tan|tan2)|exp|log|s(in|qrt)|tan|xor">
  <!ENTITY term_testing "var|atom(ic)?|integer|float|c(allable|ompound)|n(onvar|umber)|ground|acyclic_term">
  <!ENTITY term_comparison "compare">
  <!ENTITY stream_selection_and_control "(curren|se)t_(in|out)put|open|close|flush_output|stream_property|at_end_of_stream|set_stream_position">
  <!ENTITY character_and_byte_input_output "nl|(get|peek|put)_(byte|c(har|ode))">
  <!ENTITY term_input_output "read(_term)?|write(q|_(canonical|term))?|(current_)?op|(current_)?char_conversion">
  <!ENTITY atomic_term_processing "atom_(length|c(hars|o(ncat|des)))|char_code|sub_atom|number_c(har|ode)s">
  <!ENTITY implementation_defined_hooks_functions "(se|curren)t_prolog_flag|halt">
  <!ENTITY sorting "(key)?sort">
  <!ENTITY logic_and_control "ignore|once">
]>

<language name="Logtalk" version="8" kateversion="5.0" section="Sources" extensions="*.lgt;.logtalk" mimetype="text/x-logtalk" author="Paulo Moura (pmoura@logtalk.org)" license="Apache License 2.0">

	<highlighting>

		<contexts>

			<context name = "normal" attribute = "Normal" lineEndContext = "#stay" >
				<!-- Directives -->
				<RegExpr String = "^\s*:-" attribute = "Normal" context = "directive" column="0" />
				<RegExpr String = "\b(&event_handlers;|&message_forwarding_handler;|&method_execution_context;|&reflection;|&dcgs;|&entity1;|&entity2;|&entity_relations;|&events;|&flags;|&compiling_loading_and_library_paths;|&database;|&control;|&all_solutions;|&multi_threading_predicates;|&engine_predicates;|&term_unification;|&term_creation_and_decomposition;|&evaluable_functors;|&other_arithmetic_functors;|&term_testing;|&term_comparison;|&stream_selection_and_control;|&character_and_byte_input_output;|&term_input_output;|&atomic_term_processing;|&implementation_defined_hooks_functions;|&sorting;|&logic_and_control;)(?=[(])|\b(logtalk_make|fa(il|lse)|true|(instantiation|system)_error|at_end_of_stream|flush_output|nl|halt|repeat)\b" attribute = "Built-in" context = "#stay" />
				<!-- Variables -->
				<RegExpr String = "\b[A-Z_]\w*" attribute = "Variable" context = "#stay" />
				<!-- Comments -->
				<DetectChar char = "%" attribute = "Comment" context = "single line comment" />
				<Detect2Chars char = "/" char1 = "*" attribute = "Comment" context = "multiline comment" beginRegion = "Comment" />
				<!-- Strings and quoted atoms -->
				<DetectChar char = "&quot;" attribute = "String" context = "string" />
				<DetectChar char = "'" attribute = "String" context = "atom" />
				<!-- Numbers -->
				<RegExpr String = "0'\\?.|0b[0-1]+|0o[0-7]+|0x[0-9a-fA-F]+|\d+(\.\d+)?([eE]([-+])?\d+)?" attribute = "Number" context = "#stay" />
				<!-- Message sending operators -->
				<Detect2Chars char = ":" char1 = ":" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "^" char1 = "^" attribute = "Operator" context = "#stay" />
				<!-- External call -->
				<DetectChar char = "{" attribute = "Operator" context = "#stay" beginRegion="external" />
				<DetectChar char = "}" attribute = "Operator" context = "#stay" endRegion="external" />
				<!-- Bitwise functors -->
				<Detect2Chars char = "&gt;" char1 = "&gt;" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "&lt;" char1 = "&lt;" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "/" char1 = "\" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "\" char1 = "/" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "\" char1 = "\" attribute = "Operator" context = "#stay" />
				<!-- Predicate aliases -->
				<!-- Arithmetic evaluation -->
				<RegExpr String = "\b[ai]s\b" attribute = "Operator" context = "#stay" />
				<!-- Arithmetic comparison -->
				<StringDetect String = "=:=" attribute = "Operator" context = "#stay" />
				<StringDetect String = "=\=" attribute = "Operator" context = "#stay" />
				<DetectChar char = "&lt;" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "=" char1 = "&lt;" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "&gt;" char1 = "=" attribute = "Operator" context = "#stay" />
				<DetectChar char = "&gt;" attribute = "Operator" context = "#stay" />
				<!-- Term creation and decomposition -->
				<StringDetect String = "=.." attribute = "Operator" context = "#stay" />
				<!-- Term comparison -->
				<Detect2Chars char = "=" char1 = "=" attribute = "Operator" context = "#stay" />
				<StringDetect String = "\==" attribute = "Operator" context = "#stay" />
				<StringDetect String = "@=&lt;" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "@" char1 = "&lt;" attribute = "Operator" context = "#stay" />
				<StringDetect String = "@&gt;=" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "@" char1 = "&gt;" attribute = "Operator" context = "#stay" />
				<!-- Term unification -->
				<DetectChar char = "=" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "\" char1 = "=" attribute = "Operator" context = "#stay" />
				<!-- DCG rules -->
				<StringDetect String = "--&gt;" attribute = "Operator" context = "#stay" />
				<!-- Control constructs -->
				<AnyChar String = "!;" attribute = "Operator" context = "#stay" />
				<Detect2Chars char = "-" char1 = "&gt;" attribute = "Operator" context = "#stay" />
				<!-- Other arithemtic functors -->
				<Detect2Chars char = "*" char1 = "*" attribute = "Operator" context = "#stay" />
				<!-- Evaluable functors -->
				<Detect2Chars char = "/" char1 = "/" attribute = "Operator" context = "#stay" />
				<AnyChar String = "+-*/" attribute = "Operator" context = "#stay" />
				<RegExpr String = "\b(e|pi|div|mod|rem)\b" attribute = "Operator" context = "#stay" />
				<!-- Logic and control -->
				<Detect2Chars char = "\" char1 = "+" attribute = "Operator" context = "#stay" />
				<!-- Mode operators -->
				<!-- Category predicate direct call operator -->
				<!-- Existential quantifier -->
				<AnyChar String = "?@:^" attribute = "Operator" context = "#stay" />
				<!-- Atoms -->
				<RegExpr String = "\b[a-z]\w*" attribute = "Normal" context = "#stay" />
			</context>

			<context name = "directive" attribute = "Directive" lineEndContext = "#stay" >
				<!-- Conditional compilation directives -->
				<RegExpr String = "\bif(?=[(])" attribute = "Directive" context = "#pop" beginRegion = "CC" />
				<RegExpr String = "\bendif(?=[.])" attribute = "Directive" context = "#pop" endRegion = "CC" />
				<RegExpr String = "\belif(?=[(])|\belse(?=[.])" attribute = "Directive" context = "#pop" />
				<!-- Entity directives -->
				<RegExpr String = "\b(category|object|protocol)(?=[(])" attribute = "Directive" context = "entityrelations" beginRegion = "Entity" />
				<RegExpr String = "\bend_(category|object|protocol)(?=[.])" attribute = "Directive" context = "#pop" endRegion = "Entity" />
 				<!-- Predicate scope directives -->
				<!-- Other directives -->
				<RegExpr String = "\bmodule(?=[(])|\bp(ublic|r(otected|ivate))(?=[(])|\be(n(coding|sure_loaded)|xport)(?=[(])|\bin(clude|itialization|fo)(?=[(])|\b(built_in|dynamic|synchronized|threaded)(?=[.])|\b(alias|d(ynamic|iscontiguous)|m(eta_(non_terminal|predicate)|ode|ultifile)|s(et_(logtalk|prolog)_flag|ynchronized))(?=[(])|\bop(?=[(])|\b(c(alls|oinductive)|reexport|use(s|_module))(?=[(])" attribute = "Directive" context = "#pop" />
			</context>

			<context name = "entityrelations" attribute = "Normal" lineEndContext = "#stay" >
				<RegExpr String = "\b(complements|extends|i(nstantiates|mp(lements|orts))|specializes)(?=[(])" attribute = "Directive" context = "#stay" />
				<!-- Variables -->
				<RegExpr String = "\b[A-Z_]\w*" attribute = "Variable" context = "#stay" />
				<!-- Comments -->
				<DetectChar char = "%" attribute = "Comment" context = "single line comment" />
				<Detect2Chars char = "/" char1 = "*" attribute = "Comment" context = "multiline comment" beginRegion = "Comment" />
				<!-- Strings and quoted atoms -->
				<DetectChar char = "&quot;" attribute = "String" context = "string" />
				<DetectChar char = "'" attribute = "String" context = "atom" />
				<!-- Numbers -->
				<RegExpr String = "0'\\?.|0b[0-1]+|0o[0-7]+|0x[0-9a-fA-F]+|\d+(\.\d+)?([eE]([-+])?\d+)?" attribute = "Number" context = "#stay" />
				<!-- Scope operator -->
				<Detect2Chars char = ":" char1 = ":" attribute = "Operator" context = "#stay" />
				<!-- End of entity-opening directive -->
				<Detect2Chars attribute = "Normal" context = "normal" char = ")" char1 = "." />
			</context>

			<context name = "single line comment" attribute = "Comment" lineEndContext = "#pop">
				<DetectSpaces />
				<IncludeRules context="##Comments" />
			</context>

			<context name = "multiline comment" attribute = "Comment" lineEndContext = "#stay" >
				<Detect2Chars char = "*" char1 = "/" attribute = "Comment" context = "#pop" endRegion = "Comment" />
				<DetectSpaces />
				<IncludeRules context="##Comments" />
			</context>

			<context name = "string" attribute = "String" lineEndContext = "#stay" >
				<DetectChar char = "&quot;" attribute = "String" context = "#pop" />
			</context>

			<context name = "atom" attribute = "String" lineEndContext = "#stay" >
				<RegExpr attribute="String Char" context="#stay" String="\\x[a-fA-F0-9]+\\|\\[0-7]+\\"/>
				<HlCStringChar attribute="String Char" context="#stay"/>
				<DetectChar char = "'" attribute = "String" context = "#pop" />
			</context>

		</contexts>

		<itemDatas>
			<itemData name = "Normal" defStyleNum = "dsNormal" />
			<itemData name = "Directive" defStyleNum = "dsKeyword" />
			<itemData name = "Built-in" defStyleNum = "dsFunction" />
			<itemData name = "Operator" defStyleNum = "dsDataType" />
			<itemData name = "Comment" defStyleNum = "dsComment" />
			<itemData name = "Number" defStyleNum = "dsDecVal" />
			<itemData name = "String" defStyleNum = "dsString" />
			<itemData name="String Char" defStyleNum="dsSpecialChar" spellChecking="false"/>
			<itemData name = "Variable" defStyleNum = "dsOthers" />
		</itemDatas>

	</highlighting>

	<general>
		<comments>
			<comment name = "singleLine" start = "%" position = "afterwhitespace" />
			<comment name = "multiLine" start = "/*" end = "*/" region = "Comment" />
		</comments>
		<keywords casesensitive="true" />
	</general>

</language>
<!-- kate: replace-tabs off; -->
