Add tests; Fix string parsing
This commit is contained in:
parent
916b59b4b6
commit
e09bc20198
80
Cargo.lock
generated
Normal file
80
Cargo.lock
generated
Normal file
@ -0,0 +1,80 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.148"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.7.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter"
|
||||
version = "0.20.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tree-sitter-dust"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"tree-sitter",
|
||||
]
|
@ -2,7 +2,7 @@
|
||||
Simple Function
|
||||
==================
|
||||
|
||||
function { "Hiya" }
|
||||
function <> { "Hiya" }
|
||||
|
||||
---
|
||||
|
||||
@ -22,7 +22,7 @@ function { "Hiya" }
|
||||
Function Call
|
||||
==================
|
||||
|
||||
foobar <"Hiya">
|
||||
foobar {"Hiya"}
|
||||
|
||||
---
|
||||
|
||||
|
91
corpus/simple_values.txt
Normal file
91
corpus/simple_values.txt
Normal file
@ -0,0 +1,91 @@
|
||||
==================
|
||||
Booleans
|
||||
==================
|
||||
|
||||
true
|
||||
false
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(boolean))))))
|
||||
|
||||
==================
|
||||
Integers
|
||||
==================
|
||||
|
||||
1 2 3
|
||||
456 7
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(integer))))))
|
||||
|
||||
==================
|
||||
Strings
|
||||
==================
|
||||
|
||||
"one" 'two' "three" `four` 'five'
|
||||
|
||||
---
|
||||
|
||||
(root
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string)))))
|
||||
(item
|
||||
(statement
|
||||
(expression
|
||||
(value
|
||||
(string))))))
|
12
grammar.js
12
grammar.js
@ -63,7 +63,7 @@ module.exports = grammar({
|
||||
|
||||
integer: $ => /[-]*[0-9]+[.]{0}/,
|
||||
|
||||
string: $ => /(".*?")|('.*?')|(`.*?`)/,
|
||||
string: $ => /("[^"]*?")|('[^']*?')|(`[^`]*?`)/,
|
||||
|
||||
boolean: $ => choice(
|
||||
'true',
|
||||
@ -142,13 +142,13 @@ module.exports = grammar({
|
||||
),
|
||||
)),
|
||||
|
||||
insert: $ => prec.right(seq(
|
||||
insert: $ => prec.right(1, seq(
|
||||
'insert',
|
||||
repeat1($.list),
|
||||
'into',
|
||||
$.identifier,
|
||||
optional(
|
||||
seq('where', $.expression)
|
||||
seq('where', $.logic)
|
||||
),
|
||||
)),
|
||||
|
||||
@ -166,9 +166,9 @@ module.exports = grammar({
|
||||
|
||||
function_call: $ => prec.right(seq(
|
||||
$.identifier,
|
||||
'<',
|
||||
repeat(seq($.expression, optional(','))),
|
||||
'>',
|
||||
'{',
|
||||
repeat(seq($.expression)),
|
||||
'}',
|
||||
)),
|
||||
|
||||
loop: $ => choice(
|
||||
|
@ -226,7 +226,7 @@
|
||||
},
|
||||
"string": {
|
||||
"type": "PATTERN",
|
||||
"value": "(\".*?\")|('.*?')|(`.*?`)"
|
||||
"value": "(\"[^\"]*?\")|('[^']*?')|(`[^`]*?`)"
|
||||
},
|
||||
"boolean": {
|
||||
"type": "CHOICE",
|
||||
@ -615,7 +615,7 @@
|
||||
},
|
||||
"insert": {
|
||||
"type": "PREC_RIGHT",
|
||||
"value": 0,
|
||||
"value": 1,
|
||||
"content": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
@ -650,7 +650,7 @@
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
"name": "logic"
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -732,7 +732,7 @@
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "<"
|
||||
"value": "{"
|
||||
},
|
||||
{
|
||||
"type": "REPEAT",
|
||||
@ -742,25 +742,13 @@
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "expression"
|
||||
},
|
||||
{
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ","
|
||||
},
|
||||
{
|
||||
"type": "BLANK"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ">"
|
||||
"value": "}"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -180,10 +180,6 @@
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "expression",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "identifier",
|
||||
"named": true
|
||||
@ -191,6 +187,10 @@
|
||||
{
|
||||
"type": "list",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "logic",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
17019
src/parser.c
17019
src/parser.c
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
use std::fs::read_to_string;
|
||||
|
||||
use dust_lib::*;
|
||||
use dust::*;
|
||||
|
||||
#[test]
|
||||
fn collections() {
|
||||
|
Loading…
Reference in New Issue
Block a user