Skip to content

Instantly share code, notes, and snippets.

@zundr
Created June 18, 2015 09:53
Show Gist options
  • Save zundr/1bccd75b53ae5990e356 to your computer and use it in GitHub Desktop.
Save zundr/1bccd75b53ae5990e356 to your computer and use it in GitHub Desktop.
Erlang syntax highlighting rules for Fisheye/Crucible
syntaxdef erlang {
# whitespace
/\s+/m : ;
# single line comment
/%+\s*(.*)$/m : {
in_comment(${1});
region {
type=comment;
findlinks=true;
}
region ${1} {
index=prose;
}
}
# string (list)
/"/ : {
context {
/~[cfegswpWPBX#bx+ni]/: { region { type=css_attrib_val; } }
"\"" : exit;
}
region ${ALL} {
type=string;
}
}
# string (binary)
/<<"/ : {
context {
"\">>" : exit;
}
region ${ALL} {
type=string;
}
}
# some signs
/\{|\}|->|=>|:=|\||::|\.|;|<<|>>/ : {
region {
type=keyword;
}
}
# quoted atom
/'/ : {
context {
"'" : exit;
}
region ${ALL} {
type=symbol;
}
}
# macro
/\?\w+/ : {
region {
type=escape;
}
}
# record/map
/#\w+/ : {
region {
type=slashy;
}
}
# char literal
/\$./ : {
region {
type=char_literal;
}
}
# preprocessor
/^(-\w+)/m : {
region ${1} {
type=annotation;
}
}
# function
/^([a-z][A-Za-z_0-9]*)\s*\(/m : {
region ${1} {
type=class_id;
index=word;
}
}
# keywords
/\b(band|bor|bnot|bsl|bsr|bxor|div|rem|xor|try|catch|begin|receive|after|cond|fun|let)\b/ : {
region {
type=keyword;
}
}
# guards
/\b(is_list|is_alive|is_atom|is_binary|is_bitstring|is_boolean|is_tuple|is_number|is_integer|is_float|is_function|is_constant|is_pid|is_port|is_reference|is_record|is_process_alive)\b/ : {
region {
type=keyword;
}
}
# conditionals
/\b(case|if|of|end|not|and|or|andalso|orelse|when)\b/ : {
region {
type=keyword;
}
}
# erlang BIFs
/\berlang:(abs|apply|atom_to_binary|atom_to_list|binary_part|binary_to_atom|binary_to_existing_atom|binary_to_float|binary_to_integer|binary_to_list|binary_to_term|bit_size|bitstring_to_list|byte_size|check_process_code|date|delete_module|demonitor|disconnect_node|element|erase|error|exit|float|float_to_binary|float_to_list|garbage_collect|get|get_keys|group_leader|halt|hd|integer_to_binary|integer_to_list|iolist_size|iolist_to_binary|is_alive|is_atom|is_binary|is_bitstring|is_boolean|is_float|is_function|is_integer|is_list|is_number|is_pid|is_port|is_process_alive|is_record|is_reference|is_tuple|length|link|list_to_atom|list_to_binary|list_to_bitstring|list_to_existing_atom|list_to_float|list_to_integer|list_to_pid|list_to_tuple|load_module|make_ref|max|min|module_loaded|monitor|monitor_node|node|nodes|now|open_port|pid_to_list|port_close|port_command|port_connect|port_control|pre_loaded|processes|process_flag|process_info|purge_module|put|register|registered|round|self|setelement|size|spawn|spawn_link|spawn_monitor|spawn_opt|split_binary|statistics|term_to_binary|throw|time|tl|trunc|tuple_size|tuple_to_list|unlink|unregister|whereis|append_element|bump_reductions|cancel_timer|decode_packet|display|function_exported|fun_info|fun_to_list|get_cookie|get_stacktrace|hash|is_builtin|loaded|load_nif|localtime|localtime_to_universaltime|make_tuple|memory|monitor_node|phash|port_call|port_info|ports|port_to_list|process_display|read_timer|ref_to_list|resume_process|send|send_after|send_nosuspend|set_cookie|start_timer|suspend_process|system_flag|system_info|system_monitor|system_profile|trace|trace_delivered|trace_info|trace_pattern|universaltime|universaltime_to_localtime|yield)\b/ : {
region {
type=keyword;
}
}
/\b(abs|apply|atom_to_binary|atom_to_list|binary_part|binary_to_atom|binary_to_existing_atom|binary_to_float|binary_to_integer|binary_to_list|binary_to_term|bit_size|bitstring_to_list|byte_size|check_process_code|date|delete_module|demonitor|disconnect_node|element|erase|exit|float|float_to_binary|float_to_list|garbage_collect|get|get_keys|group_leader|halt|hd|integer_to_binary|integer_to_list|iolist_size|iolist_to_binary|is_alive|is_atom|is_binary|is_bitstring|is_boolean|is_float|is_function|is_integer|is_list|is_number|is_pid|is_port|is_process_alive|is_record|is_reference|is_tuple|length|link|list_to_atom|list_to_binary|list_to_bitstring|list_to_existing_atom|list_to_float|list_to_integer|list_to_pid|list_to_tuple|load_module|make_ref|max|min|module_loaded|monitor|monitor_node|node|nodes|now|open_port|pid_to_list|port_close|port_command|port_connect|port_control|pre_loaded|processes|process_flag|process_info|purge_module|put|register|registered|round|self|setelement|size|spawn|spawn_link|spawn_monitor|spawn_opt|split_binary|statistics|term_to_binary|throw|time|tl|trunc|tuple_size|tuple_to_list|unlink|unregister|whereis|append_element|bump_reductions|cancel_timer|decode_packet|display|function_exported|fun_info|fun_to_list|get_cookie|get_stacktrace|hash|is_builtin|loaded|load_nif|localtime|localtime_to_universaltime|make_tuple|memory|monitor_node|phash|port_call|port_info|ports|port_to_list|process_display|read_timer|ref_to_list|resume_process|send|send_after|send_nosuspend|set_cookie|start_timer|suspend_process|system_flag|system_info|system_monitor|system_profile|trace|trace_delivered|trace_info|trace_pattern|universaltime|universaltime_to_localtime|yield)\b/ : {
region {
type=keyword;
}
}
# atoms
/[a-z][A-Za-z_0-9]*/ : {
region {
type=identifier;
index=word;
}
}
# variables
/[A-Z][A-Za-z_0-9]*/ : {
region {
type=symbol;
index=word;
}
}
# ignored variable
/_[A-Za-z_0-9]*/ : {
region {
type=comment;
index=word;
}
}
# integer
/([0-9]+#[0-9a-fA-F]+|[0-9]+)/ : {
region {
type=numeric;
}
}
# float
/[0-9]+\.[0-9]+(e-?[0-9]+)?/ : {
region{
type=numeric;
}
}
context in_comment {
/(?i)(todo|fixme|xxx)\s.*/ : {
region {
type=todo;
}
}
/@[\p{L}_\$][\p{L}\p{N}_\$]*/ : {
region {
type=annotation;
index=word;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment