Add boolean literals

This commit is contained in:
Bruno BELANYI 2024-04-07 23:39:47 +01:00
parent db2e88a539
commit 9dd109b90a
5 changed files with 2581 additions and 600 deletions

View file

@ -34,6 +34,7 @@ module.exports = grammar({
_expr: ($) => choice(
// Literals
$.identifier,
$.boolean_literal,
$.integer_literal,
$._string_literal,
// Composites
@ -44,6 +45,8 @@ module.exports = grammar({
// The Blueprint scanner makes use of Go's lexer, so copy their rule
identifier: (_) => /[_\p{XID_Start}][_\p{XID_Continue}]*/,
boolean_literal: (_) => choice("true", "false"),
integer_literal: (_) => seq(optional("-"), /[0-9]+/),
// The Blueprint scanner makes use of Go's lexer, so copy their rule

17
src/grammar.json generated
View file

@ -75,6 +75,10 @@
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "boolean_literal"
},
{
"type": "SYMBOL",
"name": "integer_literal"
@ -97,6 +101,19 @@
"type": "PATTERN",
"value": "[_\\p{XID_Start}][_\\p{XID_Continue}]*"
},
"boolean_literal": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "true"
},
{
"type": "STRING",
"value": "false"
}
]
},
"integer_literal": {
"type": "SEQ",
"members": [

25
src/node-types.json generated
View file

@ -31,6 +31,10 @@
"multiple": false,
"required": true,
"types": [
{
"type": "boolean_literal",
"named": true
},
{
"type": "identifier",
"named": true
@ -59,6 +63,11 @@
}
}
},
{
"type": "boolean_literal",
"named": true,
"fields": {}
},
{
"type": "comment",
"named": true,
@ -92,6 +101,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": "boolean_literal",
"named": true
},
{
"type": "identifier",
"named": true
@ -137,6 +150,10 @@
"multiple": true,
"required": false,
"types": [
{
"type": "boolean_literal",
"named": true
},
{
"type": "identifier",
"named": true
@ -220,6 +237,10 @@
"type": "escape_sequence",
"named": true
},
{
"type": "false",
"named": false
},
{
"type": "identifier",
"named": true
@ -228,6 +249,10 @@
"type": "raw_string_literal",
"named": true
},
{
"type": "true",
"named": false
},
{
"type": "{",
"named": false

3102
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,37 @@
================================================================================
Boolean
================================================================================
foo = false
foo = true
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
(boolean_literal))
(assignment
(identifier)
(boolean_literal)))
================================================================================
Boolean (identifier/literal)
================================================================================
true = false
false = true
--------------------------------------------------------------------------------
(source_file
(assignment
(identifier)
(boolean_literal))
(assignment
(identifier)
(boolean_literal)))
================================================================================
Integer
================================================================================