1
0

Add missing annotation fields

This commit is contained in:
Jip J. Dekker 2021-01-16 13:41:39 +11:00
parent 4d07e3441b
commit 11fd4244c3
5 changed files with 7070 additions and 6728 deletions

View File

@ -43,19 +43,22 @@ Declaration
===========
var int: simple_decl;
var int: with_ann ::annotated;
array[X, 1..23] of var int: simple_decl = some_call(X);
---
(source_file
(declaration (type_base (primitive_type)) (identifier))
(declaration (array_type (type_base (identifier)) (type_base (infix_operator (integer_literal) (integer_literal))) (type_base (primitive_type))) (identifier) (call (identifier) (identifier))))
(declaration type: (type_base (primitive_type)) name: (identifier))
(declaration type: (type_base (primitive_type)) name: (identifier) annotations: (identifier))
(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))))
===========
Enumeration
===========
enum in_dzn;
enum with_ann ::annotated;
enum empty = {};
enum with_members = {a, b, c};
@ -63,6 +66,7 @@ enum with_members = {a, b, c};
(source_file
(enumeration name: (identifier))
(enumeration name: (identifier) annotations: (identifier))
(enumeration name: (identifier))
(enumeration name: (identifier) members: (identifier) members: (identifier) members: (identifier)))

View File

@ -69,6 +69,7 @@ module.exports = grammar({
field("type", $._type),
":",
field("name", $.identifier),
optional(field("annotations", $._annotations)),
optional(seq("=", field("expr", $._expression)))
),
@ -76,6 +77,7 @@ module.exports = grammar({
seq(
"enum",
field("name", $.identifier),
optional(field("annotations", $._annotations)),
optional(seq("=", "{", field("members", sepBy(",", $.identifier)), "}"))
),

32
src/grammar.json vendored
View File

@ -204,6 +204,22 @@
"name": "identifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "annotations",
"content": {
"type": "SYMBOL",
"name": "_annotations"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
@ -246,6 +262,22 @@
"name": "identifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "annotations",
"content": {
"type": "SYMBOL",
"name": "_annotations"
}
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [

28
src/node-types.json vendored
View File

@ -341,6 +341,20 @@
"type": "declaration",
"named": true,
"fields": {
"annotations": {
"multiple": true,
"required": false,
"types": [
{
"type": "::",
"named": false
},
{
"type": "_expression",
"named": true
}
]
},
"expr": {
"multiple": false,
"required": false,
@ -377,6 +391,20 @@
"type": "enumeration",
"named": true,
"fields": {
"annotations": {
"multiple": true,
"required": false,
"types": [
{
"type": "::",
"named": false
},
{
"type": "_expression",
"named": true
}
]
},
"members": {
"multiple": true,
"required": false,

13728
src/parser.c vendored

File diff suppressed because it is too large Load Diff