# Erlang lang definition file
# by Caolan McMahon
# from: http://caolanmcmahon.com/erlang_syntax_highlighting
# patched by Miklos Vajna
# further modifications by Lorenzo Bettini
# and even further by Erik Søe Sørensen

#==================== Keywords and other known names: ====================

# Actual keywords:
keyword = "after|and|andalso|band|begin|bnot|bor|bsl|bsr|bxor|case|catch|cond|div|end|fun|if|let|not|of|or|orelse|query|receive|rem|try|when|xor"

# Built-in functions - type tests:
predef_func = "is_atom|is_binary|is_bitstring|is_boolean|is_float|is_function|is_function|is_integer|is_list|is_number|is_pid|is_port|is_record|is_record|is_reference|is_tuple"

# Built-in functions - other guard functions:
predef_func = "abs|bit_size|byte_size|element|float|hd|length|node|node|round|self|size|tl|trunc|tuple_size"

# Built-in functions - others:
predef_func = '(?<!_)\b(alive|apply|atom_to_list|binary_to_list|binary_to_term|concat_binary|date|disconnect_node|erase|exit|float_to_list|get|get_keys|group_leader|halt|integer_to_list|is_alive|link|list_to_atom|list_to_binary|list_to_float|list_to_integer|list_to_pid|list_to_tuple|load_module|make_ref|monitor_node|nodes|now|open_port|pid_to_list|process_flag|process_info|process|put|register|registered|setelement|spawn|spawn_link|split_binary|statistics|term_to_binary|throw|time|tuple_to_list|unlink|unregister|whereis|atom|binary|constant|function|integer|list|number|pid|ports|port_close|port_info|reference|record|check_process_code|delete_module|get_cookie|hash|math|module_loaded|preloaded|processes|purge_module|set_cookie|set_node|acos|asin|atan|atan2|cos|cosh|exp|log|log10|pi|pow|power|sin|sinh|sqrt|tan|tanh|call|module_info|parse_transform|undefined_function|error_handler|creation|current_function|dictionary|group_leader|heap_size|high|initial_call|linked|low|memory_in_use|message_queue|net_kernel|normal|priority|reductions|registered_name|runnable|running|stack_trace|status|timer|trap_exit|waiting|command|count_in|count_out|creation|in|in_format|linked|out|owner|packeting|atom_tables|communicating|creation|current_gc|current_reductions|current_runtime|current_wall_clock|distribution_port|entry_points|error_handler|friends|garbage_collection|magic_cookie|magic_cookies|module_table|monitored_nodes|name|next_ref|ports|preloaded|processes|reductions|ref_state|registry|runtime|wall_clock|apply_lambda|module_info|module_lambdas|record|record_index|record_info|badarg|nocookie|fun|badsig|kill|exit)\b(?![[:blank:]]*:)'

# Other key atoms:
predef_var = "false|true|undefined|normal|killed|shutdown|'EXIT'"

#==================== Comments: ====================

environment comment start "%" begin
  include "url.lang"
  include "html_simple.lang"
  type = '@[[:alpha:]]+'
  include "todo.lang"
end

#==================== Variables and other names: ====================

# Wildcard symbol
# (Placed before variables because of common prefix '_'.)
symbol = "_"

# Variables
# (Placed before 'normal' because of common prefix '_'.)
variable = '\b[A-Z_][A-Za-z0-9_]*\b'

# Number in non-decimal base
# (Placed before other numbers because of common prefix '[0-9]'.)
number = '[0-9]+#[0-9A-Za-z]+'

function = '\w+(\s+)?[:@]?(\s+)?\w+(?=[[:blank:]]*[\(/])'

# Record names
usertype = '#[A-Za-z0-9_]+'

# Field names
# (Placed before atoms because of common prefix '[a-z]'.)
property = '\b[a-z][A-Za-z0-9_]*\b(?=[[:blank:]]*=)'
property = '\'[^\']\'(?=[[:blank:]]*=)'

atom = '\b[a-z][A-Za-z0-9_]*\b'
atom delim "'" "'" escape "\\" multiline

#==================== Literals: ====================

# Other numbers (too broad, really)
include "number.lang"

# Character literal
string = '\$\\?.'

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

#==================== Preprocessor stuff: ====================

# Macros
preproc  = '\?[A-Za-z0-9_]+'

state preproc start "-author" begin
	include "url.lang"
	normal = ")" exit
end

preproc = '-[[:alpha:]_]+'

#==================== Misc. symbols: ====================

# Groupers & separators
normal = "(|)|{|}|[|]|;|,"
normal = "\|"
normal = "\|\|"

# Operators
symbol = "+|-|*|/|==|=|=:=|=/=|<|=<|>|>=|++|--|=|!|<-|->"
symbol = ':|@|\\|\"|\.'

