Skip to content

Commit

Permalink
Merge pull request #20 from lark-parser/issue17b
Browse files Browse the repository at this point in the history
Another bugfix for issue #17
  • Loading branch information
erezsh authored Mar 16, 2022
2 parents 6d7cbee + a91a981 commit d85be6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions larkjs/lark.js
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ class PatternStr extends Pattern {
static get __serialize_fields__() {
return ["value", "flags"];
}
type = "str";
static get type() { return "str"; }
to_regexp() {
return this._get_flags(re.escape(this.value));
}
Expand All @@ -1517,7 +1517,7 @@ class PatternRE extends Pattern {
static get __serialize_fields__() {
return ["value", "flags", "_width"];
}
type = "re";
static get type() { return "re"; }
to_regexp() {
return this._get_flags(this.value);
}
Expand Down Expand Up @@ -1723,12 +1723,12 @@ class _CallChain {
const CallChain = callable_class(_CallChain);
function _create_unless(terminals, g_regex_flags, re_, use_bytes) {
let s, unless;
let tokens_by_type = classify(terminals, (t) => t.pattern.constructor.name);
let tokens_by_type = classify(terminals, (t) => t.pattern.constructor.type);
let embedded_strs = new Set();
let callback = {};
for (const retok of tokens_by_type.get('PatternRE') || []) {
for (const retok of tokens_by_type.get('re') || []) {
unless = [];
for (const strtok of tokens_by_type.get('PatternStr') || []) {
for (const strtok of tokens_by_type.get('str') || []) {
if (strtok.priority !== retok.priority) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_json_parser():

res = js_parser.parse(text, transformer)
expected = r"""{"empty_object":{},"empty_array":[],"booleans":{"YES":true,"NO":false},"numbers":[0,1,-2,3.3,440000,6.6e-7],"strings":["This",["And","That","And a \\\"b"]],"nothing":null}"""
assert res.strip() == expected
assert res.strip() == expected, res

def test():
test_json_parser()
Expand Down

0 comments on commit d85be6b

Please sign in to comment.