Add boolean literals
This commit is contained in:
parent
db2e88a539
commit
9dd109b90a
|
@ -34,6 +34,7 @@ module.exports = grammar({
|
||||||
_expr: ($) => choice(
|
_expr: ($) => choice(
|
||||||
// Literals
|
// Literals
|
||||||
$.identifier,
|
$.identifier,
|
||||||
|
$.boolean_literal,
|
||||||
$.integer_literal,
|
$.integer_literal,
|
||||||
$._string_literal,
|
$._string_literal,
|
||||||
// Composites
|
// Composites
|
||||||
|
@ -44,6 +45,8 @@ module.exports = grammar({
|
||||||
// The Blueprint scanner makes use of Go's lexer, so copy their rule
|
// The Blueprint scanner makes use of Go's lexer, so copy their rule
|
||||||
identifier: (_) => /[_\p{XID_Start}][_\p{XID_Continue}]*/,
|
identifier: (_) => /[_\p{XID_Start}][_\p{XID_Continue}]*/,
|
||||||
|
|
||||||
|
boolean_literal: (_) => choice("true", "false"),
|
||||||
|
|
||||||
integer_literal: (_) => seq(optional("-"), /[0-9]+/),
|
integer_literal: (_) => seq(optional("-"), /[0-9]+/),
|
||||||
|
|
||||||
// The Blueprint scanner makes use of Go's lexer, so copy their rule
|
// The Blueprint scanner makes use of Go's lexer, so copy their rule
|
||||||
|
|
17
src/grammar.json
generated
17
src/grammar.json
generated
|
@ -75,6 +75,10 @@
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "identifier"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "boolean_literal"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "integer_literal"
|
"name": "integer_literal"
|
||||||
|
@ -97,6 +101,19 @@
|
||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[_\\p{XID_Start}][_\\p{XID_Continue}]*"
|
"value": "[_\\p{XID_Start}][_\\p{XID_Continue}]*"
|
||||||
},
|
},
|
||||||
|
"boolean_literal": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "false"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"integer_literal": {
|
"integer_literal": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
|
25
src/node-types.json
generated
25
src/node-types.json
generated
|
@ -31,6 +31,10 @@
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": true,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "boolean_literal",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -59,6 +63,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "boolean_literal",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
@ -92,6 +101,10 @@
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": false,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "boolean_literal",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -137,6 +150,10 @@
|
||||||
"multiple": true,
|
"multiple": true,
|
||||||
"required": false,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "boolean_literal",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -220,6 +237,10 @@
|
||||||
"type": "escape_sequence",
|
"type": "escape_sequence",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "false",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
"named": true
|
"named": true
|
||||||
|
@ -228,6 +249,10 @@
|
||||||
"type": "raw_string_literal",
|
"type": "raw_string_literal",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "true",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "{",
|
"type": "{",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
3102
src/parser.c
generated
3102
src/parser.c
generated
File diff suppressed because it is too large
Load diff
|
@ -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
|
Integer
|
||||||
================================================================================
|
================================================================================
|
||||||
|
|
Loading…
Reference in a new issue