Last active
July 12, 2024 09:02
-
-
Save igorolhovskiy/1c1cbf9eb36ff8fd126c78497f3c52c7 to your computer and use it in GitHub Desktop.
Simple Kamailio Sublime Text Syntax (based on miconda.kamailio-syntax)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %YAML 1.2 | |
| --- | |
| # See http://www.sublimetext.com/docs/syntax.html | |
| first_line_match: "\\b(KAMAILIO|kamailio|SER|ser|SIP-ROUTER|sip-router|OPENSER|openser)\\b" | |
| scope: source.kamailio | |
| contexts: | |
| main: | |
| # character | |
| - match: '"' | |
| scope: punctuation.definition.string.begin.kamailio | |
| push: double_quoted_string | |
| - match: '\b(if|else|while|for|drop|exit)\b' | |
| scope: keyword.control.kamailio | |
| # - match: "(\\#[!]|[!]{2})(KAMAILIO|kamailio|SER|ser|SIP-ROUTER|sip-router|ALL|all)\\b" | |
| # scope: support.class.kamailio | |
| # Preprocessor directives with ID | |
| - match: "(\\#[!]|[!]{2})(define|ifdef|ifndef|ifexp|trydefine|trydef|redefine|redef|defenv|defenvs|trydefenv|trydefenvs|defexp|defexps)\\s*(\\w*)\\b" | |
| captures: | |
| 2: storage.type.primitive.kamailio | |
| 3: constant.other.kamailio | |
| # Preprocessor directives without ID | |
| - match: "(\\#[!]|[!]{2})(else|endif|subst|substdef|substdefs)\\b" | |
| scope: storage.type.primitive.kamailio | |
| # Line comment | |
| - match: "#.*\\n$" | |
| scope: comment.line.number-sign.kamailio | |
| pop: true | |
| # Numeric | |
| - match: "\\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\\.?[0-9]*)|(\\.[0-9]+))((e|E)(\\+|-)?[0-9]+)?)\\b" | |
| scope: constant.numeric.kamailio | |
| # Main routing blocks without name | |
| - match: "\\b(request_route|reply_route|onsend_route)\\b" | |
| scope: support.function.kamailio | |
| # Main routing blocks with name | |
| - match: "\\b(route|branch_route|failure_route|onreply_route|event_route)\\s*\\[([^\\]]+)\\]" | |
| captures: | |
| 1: entity.name.class.kamailio | |
| 2: constant.other.kamailio | |
| scope: support.function.kamailio | |
| # Executing routing blocks with name | |
| - match: "\\b(route)\\s*\\(([^)]+)\\)" | |
| captures: | |
| 1: entity.name.function.kamailio | |
| 2: constant.other.kamailio | |
| scope: support.function.kamailio | |
| - match: "\\b(include_file|import_file)\\b" | |
| scope: storage.type.primitive.kamailio | |
| - match: "(\\$)null\\b" | |
| scope: constant.language.null.kamailio | |
| # variables with inner name, root parenthesis, index and transformation | |
| # - match: "(\\$)\\([a-zA-Z0-9_]+\\(([a-zA-Z0-9_]+)\\).*\\)" | |
| # scope: support.variable.kamailio | |
| # Function names | |
| - match: '([a-z_]+)\(' | |
| captures: | |
| 1: entity.name.function.kamailio | |
| # Core variables | |
| - match: "(\\$)[a-zA-Z]+" | |
| scope: support.variable.kamailio | |
| # variables with inner name | |
| - match: "(\\$)[a-zA-Z0-9_]+\\(([a-zA-Z0-9_]+)\\)" | |
| scope: support.variable.kamailio | |
| - match: "\\b(true|yes|on|enabled)\\b" | |
| scope: constant.language.boolean.true.kamailio | |
| - match: "\\b(false|no|off|disabled)\\b" | |
| scope: constant.language.boolean.false.kamailio | |
| - match: "\\b(loadmodule|loadmodulex|modparam|modparamx|loadpath|mpath|cfgengine)\\b" | |
| scope: keyword.source.kamailio | |
| #: Core keyword variables | |
| - match: "\\b(af|dst_ip|dst_port|from_uri|method|msg:len|proto|status|snd_af|snd_ip|snd_port|snd_proto|src_ip|src_port|to_af|to_ip|to_port|to_proto|to_uri|uri|uri:host|uri:port)\\b" | |
| scope: support.variable.kamailio | |
| #: Core keyword values | |
| - match: "\\b(max_len|myself|udp|UDP|tcp|TCP|tls|TLS|sctp|SCTP|ws|WS|wss|WSS|inet|INET|inet6|INET6|sslv23|SSLv23|SSLV23|sslv2|SSLv2|SSLV2|sslv3|SSLv3|SSLV3|tlsv1|TLSv1|TLSV1)\\b" | |
| scope: constant.language.kamailio | |
| #: Syslog facility values | |
| - match: "\\b(LOG_LOCAL[0-9]+)\\b" | |
| scope: constant.language.kamailio | |
| - match: "\\b(?i:(mod|and|not|or|xor|defined|eq|ieq|ne|ine))\\b" | |
| scope: keyword.operator.kamailio | |
| - match: "\\b(INVITE|ACK|BYE|CANCEL|PRACK|UPDATE|REGISTER|MESSAGE|INFO|OPTIONS|SUBSCRIBE|NOTIFY|PUBLISH|REFER|KDMQ|GET|POST|PUT|DELETE)\\b" | |
| scope: constant.language.kamailio | |
| double_quoted_string: | |
| - meta_scope: string.quoted.double.kamailio | |
| - match: '\\.' | |
| scope: constant.character.escape.kamailio | |
| - match: '"' | |
| scope: punctuation.definition.string.end.kamailio | |
| pop: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment