cleanup
This commit is contained in:
25
grammar.js
25
grammar.js
@@ -1,5 +1,4 @@
|
|||||||
const
|
const
|
||||||
//TODO figure out how to subtact regex sets
|
|
||||||
unicodeLetter = /\p{L}/
|
unicodeLetter = /\p{L}/
|
||||||
unicodePunctuation = /\p{Pc}/
|
unicodePunctuation = /\p{Pc}/
|
||||||
unicodeDigit = /[0-9]/
|
unicodeDigit = /[0-9]/
|
||||||
@@ -41,7 +40,7 @@ module.exports = grammar({
|
|||||||
'}',
|
'}',
|
||||||
),
|
),
|
||||||
|
|
||||||
// TODO: not to spec, but maybe good enough
|
// TODO: not to spec but good enough for now
|
||||||
identifier: $ => token(seq(
|
identifier: $ => token(seq(
|
||||||
unicodeLetter,
|
unicodeLetter,
|
||||||
repeat(choice(unicodeLetter, unicodeDigit, unicodePunctuation))
|
repeat(choice(unicodeLetter, unicodeDigit, unicodePunctuation))
|
||||||
@@ -70,13 +69,18 @@ module.exports = grammar({
|
|||||||
literal_value: $ => choice(
|
literal_value: $ => choice(
|
||||||
$.numeric_lit,
|
$.numeric_lit,
|
||||||
$.string_lit,
|
$.string_lit,
|
||||||
'true',
|
$.bool_lit,
|
||||||
'false',
|
$.null_lit,
|
||||||
'null',
|
|
||||||
),
|
),
|
||||||
|
|
||||||
numeric_lit: $ => /[0-9]+(\.[0-9]+([eE][-+]?[0-9]+)?)?/,
|
numeric_lit: $ => /[0-9]+(\.[0-9]+([eE][-+]?[0-9]+)?)?/,
|
||||||
|
|
||||||
|
string_lit: $ => seq('"', repeat(/./), '"'),
|
||||||
|
|
||||||
|
bool_lit: $ => choice('true', 'false'),
|
||||||
|
|
||||||
|
null_lit: $ => 'null',
|
||||||
|
|
||||||
collection_value: $ => choice(
|
collection_value: $ => choice(
|
||||||
$.tuple,
|
$.tuple,
|
||||||
$.object,
|
$.object,
|
||||||
@@ -108,17 +112,6 @@ module.exports = grammar({
|
|||||||
|
|
||||||
variable_expr: $ => $.identifier,
|
variable_expr: $ => $.identifier,
|
||||||
|
|
||||||
// TODO: template expressions
|
|
||||||
//template_expr: $ => choice(
|
|
||||||
//$.quoted_template,
|
|
||||||
//$.heredoc_template,
|
|
||||||
//),
|
|
||||||
//quoted_template: $ => seq('"', /\w+/, '"'),
|
|
||||||
//heredoc_template: $ => '',
|
|
||||||
|
|
||||||
// TODO: string_literals are special template literals
|
|
||||||
string_lit: $ => seq('"', /\w+/, '"'),
|
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
// http://stackoverflow.com/questions/13014947/regex-to-match-a-c-style-multiline-comment/36328890#36328890
|
||||||
comment: $ => token(choice(
|
comment: $ => token(choice(
|
||||||
seq('#', /.*/),
|
seq('#', /.*/),
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
; highlights.scm
|
; highlights.scm
|
||||||
|
|
||||||
(string_lit) @keyword
|
(identifier) @string.special
|
||||||
(identifier) @type
|
(string_lit) @string
|
||||||
(numeric_lit) @number
|
(numeric_lit) @number
|
||||||
|
(bool_lit) @boolean
|
||||||
|
(null_lit) @null
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
||||||
|
|||||||
@@ -175,16 +175,12 @@
|
|||||||
"name": "string_lit"
|
"name": "string_lit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "SYMBOL",
|
||||||
"value": "true"
|
"name": "bool_lit"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "SYMBOL",
|
||||||
"value": "false"
|
"name": "null_lit"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "null"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -192,6 +188,43 @@
|
|||||||
"type": "PATTERN",
|
"type": "PATTERN",
|
||||||
"value": "[0-9]+(\\.[0-9]+([eE][-+]?[0-9]+)?)?"
|
"value": "[0-9]+(\\.[0-9]+([eE][-+]?[0-9]+)?)?"
|
||||||
},
|
},
|
||||||
|
"string_lit": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "\""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT",
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "\""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"bool_lit": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "true"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "false"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"null_lit": {
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "null"
|
||||||
|
},
|
||||||
"collection_value": {
|
"collection_value": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
@@ -336,23 +369,6 @@
|
|||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "identifier"
|
||||||
},
|
},
|
||||||
"string_lit": {
|
|
||||||
"type": "SEQ",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "\""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "\\w+"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "\""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"comment": {
|
"comment": {
|
||||||
"type": "TOKEN",
|
"type": "TOKEN",
|
||||||
"content": {
|
"content": {
|
||||||
|
|||||||
@@ -60,6 +60,11 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "bool_lit",
|
||||||
|
"named": true,
|
||||||
|
"fields": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "collection_value",
|
"type": "collection_value",
|
||||||
"named": true,
|
"named": true,
|
||||||
@@ -142,8 +147,16 @@
|
|||||||
"fields": {},
|
"fields": {},
|
||||||
"children": {
|
"children": {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": false,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "bool_lit",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "null_lit",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "numeric_lit",
|
"type": "numeric_lit",
|
||||||
"named": true
|
"named": true
|
||||||
@@ -269,8 +282,8 @@
|
|||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "null",
|
"type": "null_lit",
|
||||||
"named": false
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "numeric_lit",
|
"type": "numeric_lit",
|
||||||
|
|||||||
1139
src/parser.c
1139
src/parser.c
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user