Change some name visibilities

This commit is contained in:
Fabian Stamm 2024-10-02 18:51:24 +02:00
parent 2d1d028fee
commit 54191a699b
4 changed files with 644 additions and 663 deletions

View File

@ -5,7 +5,6 @@ module.exports = grammar({
name: "jrpc", name: "jrpc",
rules: { rules: {
// TODO: add the actual grammar rules
document: ($) => repeat($._statement), document: ($) => repeat($._statement),
_statement: ($) => _statement: ($) =>
choice( choice(
@ -24,10 +23,10 @@ module.exports = grammar({
enum_values: ($) => enum_values: ($) =>
seq( seq(
"{", "{",
optional(seq($.enum_value, repeat(seq(",", $.enum_value)))), optional(seq($._enum_value, repeat(seq(",", $._enum_value)))),
"}", "}",
), ),
enum_value: ($) => _enum_value: ($) =>
choice($.enum_value_declaration, $.enum_value_assignment), choice($.enum_value_declaration, $.enum_value_assignment),
enum_value_assignment: ($) => seq($.identifier, "=", $.number), enum_value_assignment: ($) => seq($.identifier, "=", $.number),
enum_value_declaration: ($) => seq($.identifier), enum_value_declaration: ($) => seq($.identifier),
@ -73,7 +72,7 @@ module.exports = grammar({
field("name", $.identifier), field("name", $.identifier),
field("parameters", $.function_arguments), field("parameters", $.function_arguments),
":", ":",
field("return_type", $.type), field("return_type", $._type),
";", ";",
), ),
function_arguments: ($) => function_arguments: ($) =>
@ -88,7 +87,7 @@ module.exports = grammar({
seq( seq(
field("argument_identifier", $.identifier), field("argument_identifier", $.identifier),
":", ":",
field("argument_type", $.type), field("argument_type", $._type),
), ),
pair: ($) => pair: ($) =>
@ -96,14 +95,14 @@ module.exports = grammar({
field("key", $.identifier), field("key", $.identifier),
optional("?"), optional("?"),
":", ":",
field("value", $.type), field("value", $._type),
), ),
type: ($) => _type: ($) =>
choice($.map_type, $.array_type, $.primitive_type, $.identifier), choice($.map_type, $.array_type, $.primitive_type, $.identifier),
primitive_type: ($) => choice("int", "string", "float", "boolean", "void"), primitive_type: ($) => choice("int", "string", "float", "boolean", "void"),
array_type: ($) => seq(choice($.primitive_type, $.identifier), "[]"), array_type: ($) => seq(choice($.primitive_type, $.identifier), "[]"),
map_type: ($) => seq("{", $.map_key_type, ",", $.type, "}"), map_type: ($) => seq("{", $.map_key_type, ",", $._type, "}"),
map_key_type: ($) => choice("int", "string"), map_key_type: ($) => choice("int", "string"),
identifier: ($) => /[a-zA-Z_][a-zA-Z_0-9]*/, identifier: ($) => /[a-zA-Z_][a-zA-Z_0-9]*/,

16
src/grammar.json generated
View File

@ -140,7 +140,7 @@
"members": [ "members": [
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "enum_value" "name": "_enum_value"
}, },
{ {
"type": "REPEAT", "type": "REPEAT",
@ -153,7 +153,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "enum_value" "name": "_enum_value"
} }
] ]
} }
@ -171,7 +171,7 @@
} }
] ]
}, },
"enum_value": { "_enum_value": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -451,7 +451,7 @@
"name": "return_type", "name": "return_type",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "type" "name": "_type"
} }
}, },
{ {
@ -526,7 +526,7 @@
"name": "argument_type", "name": "argument_type",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "type" "name": "_type"
} }
} }
] ]
@ -563,12 +563,12 @@
"name": "value", "name": "value",
"content": { "content": {
"type": "SYMBOL", "type": "SYMBOL",
"name": "type" "name": "_type"
} }
} }
] ]
}, },
"type": { "_type": {
"type": "CHOICE", "type": "CHOICE",
"members": [ "members": [
{ {
@ -653,7 +653,7 @@
}, },
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "type" "name": "_type"
}, },
{ {
"type": "STRING", "type": "STRING",

108
src/node-types.json generated
View File

@ -132,25 +132,6 @@
] ]
} }
}, },
{
"type": "enum_value",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "enum_value_assignment",
"named": true
},
{
"type": "enum_value_declaration",
"named": true
}
]
}
},
{ {
"type": "enum_value_assignment", "type": "enum_value_assignment",
"named": true, "named": true,
@ -194,7 +175,11 @@
"required": false, "required": false,
"types": [ "types": [
{ {
"type": "enum_value", "type": "enum_value_assignment",
"named": true
},
{
"type": "enum_value_declaration",
"named": true "named": true
} }
] ]
@ -219,7 +204,19 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "type", "type": "array_type",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "map_type",
"named": true
},
{
"type": "primitive_type",
"named": true "named": true
} }
] ]
@ -288,12 +285,24 @@
"multiple": true, "multiple": true,
"required": true, "required": true,
"types": [ "types": [
{
"type": "array_type",
"named": true
},
{
"type": "identifier",
"named": true
},
{ {
"type": "map_key_type", "type": "map_key_type",
"named": true "named": true
}, },
{ {
"type": "type", "type": "map_type",
"named": true
},
{
"type": "primitive_type",
"named": true "named": true
} }
] ]
@ -318,7 +327,19 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "type", "type": "array_type",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "map_type",
"named": true
},
{
"type": "primitive_type",
"named": true "named": true
} }
] ]
@ -378,7 +399,19 @@
"required": true, "required": true,
"types": [ "types": [
{ {
"type": "type", "type": "array_type",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "map_type",
"named": true
},
{
"type": "primitive_type",
"named": true "named": true
} }
] ]
@ -453,33 +486,6 @@
] ]
} }
}, },
{
"type": "type",
"named": true,
"fields": {},
"children": {
"multiple": false,
"required": true,
"types": [
{
"type": "array_type",
"named": true
},
{
"type": "identifier",
"named": true
},
{
"type": "map_type",
"named": true
},
{
"type": "primitive_type",
"named": true
}
]
}
},
{ {
"type": "type_declaration", "type": "type_declaration",
"named": true, "named": true,

1168
src/parser.c generated

File diff suppressed because it is too large Load Diff