MiniZinc grammar for tree-sitter
1==========
2Annotation
3==========
4
5annotation simple;
6annotation redirect = simple;
7annotation funclike(int, int);
8annotation funcdef(int: x, int: y) = other(x, y);
9
10---
11
12(source_file
13 (annotation (identifier))
14 (annotation (identifier) (identifier))
15 (annotation (identifier) (type_base (primitive_type)) (type_base (primitive_type)))
16 (annotation (identifier) (type_base (primitive_type)) (identifier) (type_base (primitive_type)) (identifier) (call (identifier) (identifier) (identifier))))
17
18==========
19Assignment
20==========
21
22this = that;
23
24---
25
26(source_file
27 (assignment (identifier) (identifier)))
28
29
30==========
31Constraint
32==========
33
34constraint true;
35
36---
37
38(source_file
39 (constraint (boolean_literal)))
40
41===========
42Declaration
43===========
44
45var int: simple_decl;
46var int: with_ann ::annotated;
47array[X, 1..23] of var int: simple_decl = some_call(X);
48
49---
50
51(source_file
52 (declaration type: (type_base (primitive_type)) name: (identifier))
53 (declaration type: (type_base (primitive_type)) name: (identifier) annotations: (identifier))
54 (declaration type: (array_type (type_base (identifier)) (type_base (infix_operator left: (integer_literal) right: (integer_literal))) (type_base (primitive_type))) name: (identifier) expr: (call name: (identifier) arguments: (identifier))))
55
56===========
57Enumeration
58===========
59
60enum in_dzn;
61enum with_ann ::annotated;
62enum empty = {};
63enum with_members = {a, b, c};
64
65---
66
67(source_file
68 (enumeration name: (identifier))
69 (enumeration name: (identifier) annotations: (identifier))
70 (enumeration name: (identifier))
71 (enumeration name: (identifier) members: (identifier) members: (identifier) members: (identifier)))
72
73========
74Function
75========
76
77function int: this();
78function var int: that() = this();
79function X: with_args(int, float);
80function X: with_named_args(X: x, bool: b) = something(b, x);
81
82---
83
84(source_file
85 (function_item (type_base (primitive_type)) (identifier))
86 (function_item (type_base (primitive_type)) (identifier) (call (identifier)))
87 (function_item (type_base (identifier)) (identifier) (type_base (primitive_type)) (type_base (primitive_type)))
88 (function_item (type_base (identifier)) (identifier) (type_base (identifier)) (identifier) (type_base (primitive_type)) (identifier) (call (identifier) (identifier) (identifier))))
89
90====
91Goal
92====
93
94solve satisfy;
95solve maximize this;
96solve minimize that;
97
98---
99
100(source_file
101 (goal)
102 (goal (identifier))
103 (goal (identifier)))
104
105=======
106Include
107=======
108
109include "globals.mzn";
110
111---
112
113(source_file
114 (include (string_literal)))
115
116=======
117Output
118=======
119
120output ["something"];
121
122---
123
124(source_file
125 (output (array_literal (string_literal))))
126
127=========
128Predicate
129=========
130
131test pred();
132predicate redirecht() = pred();
133predicate with_args(1..10: x, var bool: b) = pred();
134
135---
136
137(source_file
138 (predicate (identifier))
139 (predicate (identifier) (call (identifier)))
140 (predicate (identifier) (type_base (infix_operator (integer_literal) (integer_literal))) (identifier) (type_base (primitive_type)) (identifier) (call (identifier))))