Archived
1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
iro-mzn/minizinc.iro

476 lines
14 KiB
Plaintext

#################################################################
## MiniZinc
################################################################
##
## TODO: Add description
##
################################################################
name = MiniZinc
file_extensions [] = mzn, fzn, dzn;
################################################################
## Constants
################################################################
__id \= (\b[A-Za-z][A-Za-z0-9_]*|'[^']*')
################################################################
## Styles
################################################################
# TODO: Better colors for debugging purposes
styles [] {
.builtin : style {
color = light_green
ace_scope = support.function
textmate_scope = support.function
pygments_scope = Name.Builtin
}
.comment : style {
color = yellow
italic = true
ace_scope = comment
textmate_scope = comment
pygments_scope = Comment
}
.constant : style {
color = white
ace_scope = constant.language
textmate_scope = constant.language
pygments_scope = Literal
}
.escape_char : style {
color = red
ace_scope = constant.character.escape
textmate_scope = constant.character.escape
pygments_scope = String.Escape
}
.escaped : style {
color = brown
ace_scope = text
textmate_scope = text
pygments_scope = Generic.Inserted
}
.function : style {
color = green
ace_scope = entity.name.function
textmate_scope = entity.name.function
pygments_scope = Name.Function
}
.global : style {
color = light_green
ace_scope = support.function
textmate_scope = support.function
pygments_scope = Name.Builtin.Pseudo
}
.illegal : style {
color = white
background_color = red
ace_scope = invalid.illegal
textmate_scope = invalid.illegal
pygments_scope = Generic.Error
}
.keyword : style {
color = cyan
ace_scope = keyword.control
textmate_scope = keyword.control
pygments_scope = Keyword
}
.numeric : style {
color = gold
ace_scope = constant.numeric
textmate_scope = constant.numeric
pygments_scope = Number
}
.operator : style {
color = orange
ace_scope = keyword.operator
textmate_scope = keyword.operator
pygments_scope = Operator
}
.punctuation : style {
color = light_yellow
ace_scope = punctuation
textmate_scope = punctuation
pygments_scope = Punctuation
}
.string : style {
color = white
ace_scope = string
textmate_scope = string
pygments_scope = String
}
.type : style {
color = blue
ace_scope = storage.type
textmate_scope = storage.type
pygments_scope = Keyword.Type
}
.variable : style {
color = violet
ace_scope = variable
textmate_scope = variable
pygments_scope = Name.Variable
}
}
#################################################
## Parse contexts
#################################################
contexts [] {
##############################################
## Main Context - Entry point context
##############################################
main : context {
#######################################
## Comment Patterns
#######################################
: include "multi_line_comment";
: pattern {
description = line comment
regex \= (%.*)
styles [] = .comment;
}
# Escape to non-MiniZinc code or comments
: inline_push {
regex \= (@)
styles [] = .escaped;
default_style = .escaped
: pop {
regex \= (@)
styles [] = .escaped;
}
}
#######################################
## Literal Patterns
#######################################
: include "numeric";
: include "string";
: pattern {
description = Boolean literal
regex \= (\b(?:true|false)\b)
styles [] = .constant;
}
#######################################
## Operator Patterns
#######################################
: pattern {
description = logical operator
regex \= (\bnot\b|<->|->|<-|\\/|\bxor\b|/\\)
styles [] = .operator;
}
: pattern {
description = equality operator
regex \= (<|>|<=|>=|==|=|!=)
styles [] = .operator;
}
: pattern {
description = linear operator
regex \= (\+|-|\*|/|\bdiv\b|\bmod\b)
styles [] = .operator;
}
: pattern {
description = set operator
regex \= (\b(?:in|subset|superset|union|diff|symdiff|intersect|\.\.)\b)
styles [] = .operator;
}
#######################################
## Punctuation Patterns
#######################################
: pattern {
description = terminator
regex \= (;)
styles [] = .punctuation;
}
: pattern {
regex \= (:)
styles [] = .punctuation;
}
: pattern {
regex \= (,)
styles [] = .punctuation;
}
: inline_push {
regex \= (\{)
styles [] = .punctuation;
: pop {
regex \= (\})
styles [] = .punctuation;
}
: pattern {
regex \= (\|)
styles [] = .punctuation;
}
: include "main";
}
: inline_push {
regex \= (\[)
styles [] = .punctuation;
: pop {
regex \= (\])
styles [] = .punctuation;
}
: pattern {
regex \= (\|)
styles [] = .punctuation;
}
: include "main";
}
: inline_push {
regex \= (\()
styles [] = .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "main";
}
: pattern {
description = unmatched bracket
regex \= (\}|\]|\))
styles[] = .illegal;
}
: pattern {
description = illegal pipe character
regex \= (\|)
styles[] = .illegal;
}
#######################################
## Keyword Patterns
#######################################
: pattern {
description = item keyword
regex \= (\b(?:annotation|constraint|function|include|op|output|minimize|maximize|predicate|satisfy|solve|test|type)\b)
styles [] = .keyword;
}
: pattern {
description = type keyword
regex \= (\b(?:ann|array|bool|enum|float|int|list|of|par|set|string|tuple|var|record|any|opt)\b)
styles [] = .type;
}
: pattern {
description = expression keyword
regex \= (\b(?:for|forall|exists|if|then|elseif|else|endif|where|let|in)\b)
styles [] = .keyword;
}
: pattern {
description = reserved identifiers
regex \= (\b(?:case|op)\b)
styles [] = .illegal;
}
#######################################
## Library Patterns
#######################################
: pattern {
description = builtin function (stdlib)
regex \= (\b(?:abort|abs|acosh|array_intersect|array_union|array1d|array2d|array3d|array4d|array5d|array6d|asin|assert|atan|bool2int|card|ceil|concat|cos|cosh|dom|dom_array|dom_size|fix|exp|floor|index_set|index_set_1of2|index_set_2of2|index_set_1of3|index_set_2of3|index_set_3of3|int2float|is_fixed|join|lb|lb_array|length|ln|log|log2|log10|min|max|pow|product|round|set2array|show|show_int|show_float|sin|sinh|sqrt|sum|tan|tanh|trace|ub|ub_array)\b)
styles [] = .builtin;
}
: pattern {
description = general predicates (globals)
regex \= (\b(?:circuit|disjoint|maximum|maximum_arg|member|minimum|minimum_arg|network_flow|network_flow_cost|partition_set|range|roots|sliding_sum|subcircuit|sum_pred)\b)
styles [] = .global;
}
: pattern {
description = all different and related constraints (globals)
regex \= (\b(?:alldifferent|all_different|all_disjoint|all_equal|alldifferent_except_0|nvalue|symmetric_all_different)\b)
styles [] = .global;
}
: pattern {
description = lexicographic constraints (globals)
regex \= (\b(?:lex2|lex_greater|lex_greatereq|lex_less|lex_lesseq|strict_lex2|value_precede|value_precede_chain)\b)
styles [] = .global;
}
: pattern {
description = sorting constraints (globals)
regex \= (\b(?:arg_sort|decreasing|increasing|sort)\b)
styles [] = .global;
}
: pattern {
description = channeling constraints (globals)
regex \= (\b(?:int_set_channel|inverse|inverse_set|link_set_to_booleans)\b)
styles [] = .global;
}
: pattern {
description = counting constraints (globals)
regex \= (\b(?:among|at_least|at_most|at_most1|count|count_eq|count_geq|count_gt|count_leq|count_lt|count_neq|distribute|exactly|global_cardinality|global_cardinality_closed|global_cardinality_low_up|global_cardinality_low_up_closed)\b)
styles [] = .global;
}
: pattern {
description = packing constraints (globals)
regex \= (\b(?:bin_packing|bin_packing_capa|bin_packing_load|diffn|diffn_k|diffn_nonstrict|diffn_nonstrict_k|geost|geost_bb|geost_smallest_bb|knapsack)\b)
styles [] = .global;
}
: pattern {
description = scheduling constraints (globals)
regex \= (\b(?:alternative|cumulative|disjunctive|disjunctive_strict|span)\b)
styles [] = .global;
}
: pattern {
description = extensional constraints (globals)
regex \= (\b(?:regular|regular_nfa|table)\b)
styles [] = .global;
}
#######################################
## Identifier Patterns
#######################################
: inline_push {
description = function
regex \= $${__id}(\()
styles [] = .function, .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
:include "main";
}
: pattern {
description = variable
regex \= $${__id}
styles [] = .variable;
}
}
#################################################
## End of Contexts
#################################################
###########################################
## Multi Line Comment Context
###########################################
multi_line_comment : context {
description = multi line comment
: inline_push {
regex \= (/\*)
styles [] = .comment;
default_style = .comment
: pop {
regex \= (\*/)
styles [] = .comment;
}
}
}
###########################################
## Numeric Context
###########################################
numeric : context {
: pattern {
description = octal integer number
regex \= (\b0o[0-7]+)
styles [] = .numeric;
}
: pattern {
description = hexadecimal number
regex \= (\b0x[0-9A-Fa-f]+)
styles [] = .numeric;
}
: pattern {
description = hexadecimal number
regex \= (\b0x[0-9A-Fa-f]+)
styles [] = .numeric;
}
: pattern {
description = floating point number
regex \= (\b\d+(?:(?:.\d+)?[Ee][-+]?\d+|.\d+))
styles [] = .numeric;
}
: pattern {
description = integer number
regex \= (\b\d+)
styles [] = .numeric;
}
}
###########################################
## String Context
###########################################
string : context {
: inline_push {
regex \= (\")
styles [] = .string;
: pop {
regex \= (\")
styles [] = .string;
}
: inline_push {
regex \= (\\\()
styles [] = .punctuation;
: pop {
regex \= (\))
styles [] = .punctuation;
}
: include "main";
}
: pattern {
regex \= (\\["'\\nrvt])
styles [] = .escape_char;
}
: pattern {
regex \= ([^\"\\]+)
styles [] = .string;
}
}
}
}