Fix parsing of empty strings in javascript and golang
This commit is contained in:
parent
c30055ba18
commit
4c9ac3dada
6 changed files with 3578 additions and 3579 deletions
|
|
@ -81,6 +81,7 @@ namespace tree_sitter_examples {
|
|||
sym("math_op"),
|
||||
sym("bool_op"),
|
||||
sym("number"),
|
||||
sym("string"),
|
||||
sym("var_name") }) },
|
||||
{ "math_op", choice({
|
||||
infix_op("*", "expression", 2),
|
||||
|
|
@ -107,7 +108,7 @@ namespace tree_sitter_examples {
|
|||
sym("type_name"),
|
||||
blank() }) }) },
|
||||
|
||||
{ "string", pattern("\"([^\"]|\\\\\")+\"") },
|
||||
{ "string", delimited("\"") },
|
||||
{ "package_name", sym("_identifier") },
|
||||
{ "var_name", sym("_identifier") },
|
||||
{ "type_name", sym("_identifier") },
|
||||
|
|
|
|||
|
|
@ -47,10 +47,12 @@ namespace tree_sitter_examples {
|
|||
}
|
||||
|
||||
rule_ptr delimited(std::string delimiter) {
|
||||
return seq({
|
||||
return token(seq({
|
||||
str(delimiter),
|
||||
pattern("([^" + delimiter + "]|\\\\" + delimiter + ")+"),
|
||||
repeat(choice({
|
||||
pattern("[^" + delimiter + "]"),
|
||||
seq({ str("\\"), str(delimiter) }) })),
|
||||
str(delimiter)
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -4,13 +4,13 @@ parses trivial programs
|
|||
package trivial
|
||||
|
||||
type x int64
|
||||
var y = 0
|
||||
var y = ""
|
||||
func z() {}
|
||||
---
|
||||
(program
|
||||
(package_directive (package_name))
|
||||
(type_declaration (type_name) (type_name))
|
||||
(var_declaration (var_name) (number))
|
||||
(var_declaration (var_name) (string))
|
||||
(func_declaration (var_name) (statement_block)))
|
||||
|
||||
==========================================
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ theFunction(
|
|||
100.0,
|
||||
200,
|
||||
/the-regex/,
|
||||
'',
|
||||
"",
|
||||
'the-single-quoted-string',
|
||||
"the-double-quoted-string"
|
||||
);
|
||||
|
|
@ -15,6 +17,8 @@ theFunction(
|
|||
(number)
|
||||
(regex)
|
||||
(string)
|
||||
(string)
|
||||
(string)
|
||||
(string))))
|
||||
|
||||
==========================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue