Change aggregate binding syntax

This commit is contained in:
2026-04-15 08:43:03 -06:00
parent 36edac0355
commit 23a6db2481
6 changed files with 2913 additions and 2411 deletions

View File

@@ -8,13 +8,13 @@ define output decision Queen(Coord, Coord)
Queen(row, col) :- Coord row, Coord col.
; Exactly one queen goes on each row.
:- For(row), @count Queen(row, _) = 1.
:- @count col : Queen(row, _) = 1.
; Exactly one queen goes on each column.
:- For(col), @count Queen(_, col) = 1.
:- @count col : Queen(_, col) = 1.
; At most one queen can go along each main diagonal.
:- For(diag), @count { Queen (row, col), diag = row + col } <= 1.
:- @count diag : { Queen (row, col), diag = row + col } <= 1.
; At most one queen can go along each orthogonal diagonal.
:- For(diag), @count { Queen (row, col), diag = row - col } <= 1.
:- @count diag : { Queen (row, col), diag = row - col } <= 1.

View File

@@ -131,6 +131,7 @@ export default grammar({
aggregate: $ => seq(
field("op", $.aggregate_op),
optional(seq(list(field("witness", $.variable)), ":")),
choice(
field("atom", $.atom),
seq("{", field("body", $.rule_body ), "}"),

View File

@@ -12,7 +12,7 @@
(definition relation: (symbol) @function)
(atom head: (symbol) @function)
[ ":-" "," "." ] @punctuation.delimiter
[ ":-" "," "." ":" ] @punctuation.delimiter
[ "(" ")" "{" "}" ] @punctuation.bracket
(aggregate_op) @keyword

View File

@@ -742,6 +742,56 @@
"name": "aggregate_op"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "witness",
"content": {
"type": "SYMBOL",
"name": "variable"
}
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "witness",
"content": {
"type": "SYMBOL",
"name": "variable"
}
}
]
}
}
]
},
{
"type": "STRING",
"value": ":"
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [

View File

@@ -32,6 +32,16 @@
"named": true
}
]
},
"witness": {
"multiple": true,
"required": false,
"types": [
{
"type": "variable",
"named": true
}
]
}
}
},
@@ -669,6 +679,10 @@
"type": "0",
"named": false
},
{
"type": ":",
"named": false
},
{
"type": ":-",
"named": false

File diff suppressed because it is too large Load Diff