From b1a300874e9b67972a5a0f82855d083109fd3361 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Sat, 30 Apr 2022 14:25:41 -0700 Subject: [PATCH] fix: issue with expression continuations containing equals --- .changeset/strong-buckets-attack.md | 5 + .../attr-operators-space-before.expected.txt | 249 ++++++----- .../attr-operators-space-between.expected.txt | 398 +++++++++--------- src/states/EXPRESSION.ts | 4 +- 4 files changed, 316 insertions(+), 340 deletions(-) create mode 100644 .changeset/strong-buckets-attack.md diff --git a/.changeset/strong-buckets-attack.md b/.changeset/strong-buckets-attack.md new file mode 100644 index 00000000..c8dbdb87 --- /dev/null +++ b/.changeset/strong-buckets-attack.md @@ -0,0 +1,5 @@ +--- +"htmljs-parser": patch +--- + +Fix expression continuations containing equals not consuming enough characters diff --git a/src/__tests__/fixtures/attr-operators-space-before/__snapshots__/attr-operators-space-before.expected.txt b/src/__tests__/fixtures/attr-operators-space-before/__snapshots__/attr-operators-space-before.expected.txt index fa33db75..cb85e90c 100644 --- a/src/__tests__/fixtures/attr-operators-space-before/__snapshots__/attr-operators-space-before.expected.txt +++ b/src/__tests__/fixtures/attr-operators-space-before/__snapshots__/attr-operators-space-before.expected.txt @@ -493,10 +493,10 @@ │ │╰─ attrName ╰─ ╰─ tagName 66╭─ =y a/> - │ │││ │╰─ text "=y a/>\n" - │ │││ ╰─ openTagEnd - │ ││╰─ attrValue.value - │ │├─ attrValue "=x" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x >=y" + │ │├─ attrValue "=x >=y" │ │╰─ attrName ╰─ ╰─ tagName 67╭─ @@ -507,125 +507,110 @@ │ │╰─ attrName ╰─ ╰─ tagName 68╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x &&=y" - │ ││├─ attrValue "=x &&=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x &&=y" + │ │├─ attrValue "=x &&=y" + │ │╰─ attrName + ╰─ ╰─ tagName 69╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x |=y" - │ ││├─ attrValue "=x |=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x |=y" + │ │├─ attrValue "=x |=y" + │ │╰─ attrName + ╰─ ╰─ tagName 70╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x ||=y" - │ ││├─ attrValue "=x ||=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x ||=y" + │ │├─ attrValue "=x ||=y" + │ │╰─ attrName + ╰─ ╰─ tagName 71╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x ^=y" - │ ││├─ attrValue "=x ^=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x ^=y" + │ │├─ attrValue "=x ^=y" + │ │╰─ attrName + ╰─ ╰─ tagName 72╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x ~=y" - │ ││├─ attrValue "=x ~=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x ~=y" + │ │├─ attrValue "=x ~=y" + │ │╰─ attrName + ╰─ ╰─ tagName 73╭─ >=y a/> - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x >>=y" - │ ││├─ attrValue "=x >>=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x >>=y" + │ │├─ attrValue "=x >>=y" + │ │╰─ attrName + ╰─ ╰─ tagName 74╭─ >>=y a/> - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x >>>=y" - │ ││├─ attrValue "=x >>>=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x >>>=y" + │ │├─ attrValue "=x >>>=y" + │ │╰─ attrName + ╰─ ╰─ tagName 75╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x -=y" - │ ││├─ attrValue "=x -=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x -=y" + │ │├─ attrValue "=x -=y" + │ │╰─ attrName + ╰─ ╰─ tagName 76╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x /=y" - │ ││├─ attrValue "=x /=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x /=y" + │ │├─ attrValue "=x /=y" + │ │╰─ attrName + ╰─ ╰─ tagName 77╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x *=y" - │ ││├─ attrValue "=x *=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x *=y" + │ │├─ attrValue "=x *=y" + │ │╰─ attrName + ╰─ ╰─ tagName 78╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x **=y" - │ ││├─ attrValue "=x **=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x **=y" + │ │├─ attrValue "=x **=y" + │ │╰─ attrName + ╰─ ╰─ tagName 79╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x %=y" - │ ││├─ attrValue "=x %=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x %=y" + │ │├─ attrValue "=x %=y" + │ │╰─ attrName + ╰─ ╰─ tagName 80╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x +=y" - │ ││├─ attrValue "=x +=y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x +=y" + │ │├─ attrValue "=x +=y" + │ │╰─ attrName + ╰─ ╰─ tagName 81╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x++ +y" - │ ││├─ attrValue "=x++ +y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x++ +y" + │ │├─ attrValue "=x++ +y" + │ │╰─ attrName + ╰─ ╰─ tagName 82╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x+ ++y" - │ ││├─ attrValue "=x+ ++y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x+ ++y" + │ │├─ attrValue "=x+ ++y" + │ │╰─ attrName + ╰─ ╰─ tagName 83╭─ y │ ││││ ││ │╰─ openTagEnd:selfClosed "/>" │ ││││ ││ ╰─ tagName @@ -635,7 +620,7 @@ │ ││├─ attrValue "=x" │ ││╰─ attrName │ │╰─ tagName - ╰─ ╰─ text "\n" + ╰─ ╰─ error(MISSING_END_TAG:Missing ending "a" tag) "" 84╭─ >y a/> │ ││││ │╰─ openTagEnd:selfClosed "/>" │ ││││ ╰─ attrName @@ -669,34 +654,36 @@ │ │╰─ tagName ╰─ ╰─ text "\n" 88╭─ y a/> - │ ││││ │╰─ text "y a/>\n" - │ ││││ ╰─ openTagEnd - │ │││╰─ attrValue.value "x =" - │ ││├─ attrValue "=x =" + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "x =>y" + │ ││├─ attrValue "=x =>y" │ ││╰─ attrName │ │╰─ tagName ╰─ ╰─ text "\n" 89╭─ (y ) a/> - │ │││ │╰─ text " (y ) a/>\n" - │ │││ ╰─ openTagEnd - │ ││╰─ attrValue.value "x =" - │ │├─ attrValue "=x =" - │ │╰─ attrName - ╰─ ╰─ tagName + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "x => (y )" + │ ││├─ attrValue "=x => (y )" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" 90╭─ {y } a/> - │ ││││ │╰─ text " {y } a/>\n" - │ ││││ ╰─ openTagEnd - │ │││╰─ attrValue.value "x =" - │ ││├─ attrValue "=x =" + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "x => {y }" + │ ││├─ attrValue "=x => {y }" │ ││╰─ attrName │ │╰─ tagName - ╰─ ╰─ error(MISSING_END_TAG:Missing ending "a" tag) "" + ╰─ ╰─ text "\n" 91╭─ - │ │││ │╰─ openTagEnd:selfClosed "/>" - │ │││ ╰─ attrName - │ ││╰─ attrValue.value "( x ) {y }" - │ │├─ attrValue "=( x ) {y }" - │ │╰─ attrName - ╰─ ╰─ tagName + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "( x ) {y }" + │ ││├─ attrValue "=( x ) {y }" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" 92╭─ ╰─ ╰─ text "\n" \ No newline at end of file diff --git a/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt b/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt index ceb9f924..0e128333 100644 --- a/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt +++ b/src/__tests__/fixtures/attr-operators-space-between/__snapshots__/attr-operators-space-between.expected.txt @@ -677,10 +677,10 @@ │ │╰─ attrName ╰─ ╰─ tagName 89╭─ = y a/> - │ │││ │╰─ text "= y a/>\n" - │ │││ ╰─ openTagEnd - │ ││╰─ attrValue.value - │ │├─ attrValue "=x" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x >= y" + │ │├─ attrValue "=x >= y" │ │╰─ attrName ╰─ ╰─ tagName 90╭─ @@ -691,178 +691,157 @@ │ │╰─ attrName ╰─ ╰─ tagName 91╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x &&= y" - │ ││├─ attrValue "=x &&= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x &&= y" + │ │├─ attrValue "=x &&= y" + │ │╰─ attrName + ╰─ ╰─ tagName 92╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x |= y" - │ ││├─ attrValue "=x |= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x |= y" + │ │├─ attrValue "=x |= y" + │ │╰─ attrName + ╰─ ╰─ tagName 93╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x ||= y" - │ ││├─ attrValue "=x ||= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x ||= y" + │ │├─ attrValue "=x ||= y" + │ │╰─ attrName + ╰─ ╰─ tagName 94╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x ^= y" - │ ││├─ attrValue "=x ^= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x ^= y" + │ │├─ attrValue "=x ^= y" + │ │╰─ attrName + ╰─ ╰─ tagName 95╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x ~= y" - │ ││├─ attrValue "=x ~= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x ~= y" + │ │├─ attrValue "=x ~= y" + │ │╰─ attrName + ╰─ ╰─ tagName 96╭─ >= y a/> - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x >>= y" - │ ││├─ attrValue "=x >>= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x >>= y" + │ │├─ attrValue "=x >>= y" + │ │╰─ attrName + ╰─ ╰─ tagName 97╭─ >>= y a/> - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x >>>= y" - │ ││├─ attrValue "=x >>>= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x >>>= y" + │ │├─ attrValue "=x >>>= y" + │ │╰─ attrName + ╰─ ╰─ tagName 98╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x -= y" - │ ││├─ attrValue "=x -= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x -= y" + │ │├─ attrValue "=x -= y" + │ │╰─ attrName + ╰─ ╰─ tagName 99╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x /= y" - │ ││├─ attrValue "=x /= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x /= y" + │ │├─ attrValue "=x /= y" + │ │╰─ attrName + ╰─ ╰─ tagName 100╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x *= y" - │ ││├─ attrValue "=x *= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x *= y" + │ │├─ attrValue "=x *= y" + │ │╰─ attrName + ╰─ ╰─ tagName 101╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x **= y" - │ ││├─ attrValue "=x **= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x **= y" + │ │├─ attrValue "=x **= y" + │ │╰─ attrName + ╰─ ╰─ tagName 102╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x %= y" - │ ││├─ attrValue "=x %= y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x %= y" + │ │├─ attrValue "=x %= y" + │ │╰─ attrName + ╰─ ╰─ tagName 103╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x += y" - │ ││├─ attrValue "=x += y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x += y" + │ │├─ attrValue "=x += y" + │ │╰─ attrName + ╰─ ╰─ tagName 104╭─ - │ ││││ │ ╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName "in;" - │ │││╰─ attrValue.value - │ ││├─ attrValue "=x" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │ ╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName "in;" + │ ││╰─ attrValue.value + │ │├─ attrValue "=x" + │ │╰─ attrName + ╰─ ╰─ tagName 105╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x in y" - │ ││├─ attrValue "=x in y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x in y" + │ │├─ attrValue "=x in y" + │ │╰─ attrName + ╰─ ╰─ tagName 106╭─ - │ ││││ │ ││╰─ openTagEnd:selfClosed "/>" - │ ││││ │ │╰─ attrValue.value - │ ││││ │ ╰─ attrValue "=y" - │ ││││ ╰─ attrName "in" - │ │││╰─ attrValue.value - │ ││├─ attrValue "=x" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │ ││╰─ openTagEnd:selfClosed "/>" + │ │││ │ │╰─ attrValue.value + │ │││ │ ╰─ attrValue "=y" + │ │││ ╰─ attrName "in" + │ ││╰─ attrValue.value + │ │├─ attrValue "=x" + │ │╰─ attrName + ╰─ ╰─ tagName 107╭─ - │ ││││ │ │╰─ openTagEnd:selfClosed "/>" - │ ││││ │ ╰─ attrName - │ ││││ ╰─ attrName "in" - │ │││╰─ attrValue.value - │ ││├─ attrValue "=x" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │ │╰─ openTagEnd:selfClosed "/>" + │ │││ │ ╰─ attrName + │ │││ ╰─ attrName "in" + │ ││╰─ attrValue.value + │ │├─ attrValue "=x" + │ │╰─ attrName + ╰─ ╰─ tagName 108╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x instanceof y" - │ ││├─ attrValue "=x instanceof y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x instanceof y" + │ │├─ attrValue "=x instanceof y" + │ │╰─ attrName + ╰─ ╰─ tagName 109╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x ++ + y" - │ ││├─ attrValue "=x ++ + y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x ++ + y" + │ │├─ attrValue "=x ++ + y" + │ │╰─ attrName + ╰─ ╰─ tagName 110╭─ - │ ││││ │╰─ openTagEnd:selfClosed "/>" - │ ││││ ╰─ attrName - │ │││╰─ attrValue.value "x + ++ y" - │ ││├─ attrValue "=x + ++ y" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │╰─ openTagEnd:selfClosed "/>" + │ │││ ╰─ attrName + │ ││╰─ attrValue.value "x + ++ y" + │ │├─ attrValue "=x + ++ y" + │ │╰─ attrName + ╰─ ╰─ tagName 111╭─ - │ ││││ │ │ │╰─ openTagEnd:selfClosed "/>" - │ ││││ │ │ ╰─ attrName - │ ││││ │ ╰─ attrName - │ ││││ ╰─ attrName "++" - │ │││╰─ attrValue.value - │ ││├─ attrValue "=x" - │ ││╰─ attrName - │ │╰─ tagName - ╰─ ╰─ text "\n" + │ │││ │ │ │╰─ openTagEnd:selfClosed "/>" + │ │││ │ │ ╰─ attrName + │ │││ │ ╰─ attrName + │ │││ ╰─ attrName "++" + │ ││╰─ attrValue.value + │ │├─ attrValue "=x" + │ │╰─ attrName + ╰─ ╰─ tagName 112╭─ y │ ││││ ││ │╰─ openTagEnd:selfClosed "/>" │ ││││ ││ ╰─ tagName @@ -872,7 +851,7 @@ │ ││├─ attrValue "=x" │ ││╰─ attrName │ │╰─ tagName - ╰─ ╰─ text "\n" + ╰─ ╰─ error(MISSING_END_TAG:Missing ending "a" tag) "" 113╭─ > y a/> │ ││││ │╰─ openTagEnd:selfClosed "/>" │ ││││ ╰─ attrName @@ -906,69 +885,74 @@ │ │╰─ tagName ╰─ ╰─ text "\n" 117╭─ y a/> - │ ││││ │╰─ text " y a/>\n" - │ ││││ ╰─ openTagEnd - │ │││╰─ attrValue.value "x =" - │ ││├─ attrValue "=x =" + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "x => y" + │ ││├─ attrValue "=x => y" │ ││╰─ attrName │ │╰─ tagName ╰─ ╰─ text "\n" 118╭─ ( y ) a/> - │ │││ │╰─ text " ( y ) a/>\n" - │ │││ ╰─ openTagEnd - │ ││╰─ attrValue.value "x =" - │ │├─ attrValue "=x =" - │ │╰─ attrName - ╰─ ╰─ tagName + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "x => ( y )" + │ ││├─ attrValue "=x => ( y )" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" 119╭─ { y } a/> - │ │││ │╰─ text " { y } a/>\n" - │ │││ ╰─ openTagEnd - │ ││╰─ attrValue.value "x =" - │ │├─ attrValue "=x =" - │ │╰─ attrName - ╰─ ╰─ tagName + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "x => { y }" + │ ││├─ attrValue "=x => { y }" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" 120╭─ - │ │││ │╰─ openTagEnd:selfClosed "/>" - │ │││ ╰─ attrName - │ ││╰─ attrValue.value "( x ) { y }" - │ │├─ attrValue "=( x ) { y }" - │ │╰─ attrName - ╰─ ╰─ tagName + │ ││││ │╰─ openTagEnd:selfClosed "/>" + │ ││││ ╰─ attrName + │ │││╰─ attrValue.value "( x ) { y }" + │ ││├─ attrValue "=( x ) { y }" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" 121╭─ { console.log("y") } a/> - │ │││ │ │╰─ text " { console.log(\"y\") } a/>\n" - │ │││ │ ╰─ openTagEnd - │ │││ ╰─ attrValue.value "(x) =" - │ ││├─ attrValue "= (x) =" + │ │││ │ │╰─ openTagEnd:selfClosed "/>" + │ │││ │ ╰─ attrName + │ │││ ╰─ attrValue.value "(x) => { console.log(\"y\") }" + │ ││├─ attrValue "= (x) => { console.log(\"y\") }" │ ││╰─ attrName │ │╰─ tagName ╰─ ╰─ text "\n" 122╭─ { console.log("y") } a/> - │ ││ │ │╰─ text " { console.log(\"y\") } a/>\n" - │ ││ │ ╰─ openTagEnd - │ ││ ╰─ attrValue.value "async x =" - │ │├─ attrValue "= async x =" - │ │╰─ attrName - ╰─ ╰─ tagName + │ │││ │ │╰─ openTagEnd:selfClosed "/>" + │ │││ │ ╰─ attrName + │ │││ ╰─ attrValue.value "async x => { console.log(\"y\") }" + │ ││├─ attrValue "= async x => { console.log(\"y\") }" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" 123╭─ - │ ││ │ │╰─ openTagEnd:selfClosed "/>" - │ ││ │ ╰─ attrName - │ ││ ╰─ attrValue.value "function (x) { console.log(\"y\") }" - │ │├─ attrValue "= function (x) { console.log(\"y\") }" - │ │╰─ attrName - ╰─ ╰─ tagName + │ │││ │ │╰─ openTagEnd:selfClosed "/>" + │ │││ │ ╰─ attrName + │ │││ ╰─ attrValue.value "function (x) { console.log(\"y\") }" + │ ││├─ attrValue "= function (x) { console.log(\"y\") }" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" 124╭─ { console.log("y") } a/> - │ │││ │ │╰─ text " { console.log(\"y\") } a/>\n" - │ │││ │ ╰─ openTagEnd - │ │││ ╰─ attrValue.value "x =" - │ ││├─ attrValue "= x =" + │ │││ │ │╰─ openTagEnd:selfClosed "/>" + │ │││ │ ╰─ attrName + │ │││ ╰─ attrValue.value "x => { console.log(\"y\") }" + │ ││├─ attrValue "= x => { console.log(\"y\") }" │ ││╰─ attrName │ │╰─ tagName - │ ├─ text "\n" - ╰─ ╰─ error(MISSING_END_TAG:Missing ending "a" tag) "" + ╰─ ╰─ text "\n" 125╭─ - │ ││ │ │╰─ openTagEnd:selfClosed "/>" - │ ││ │ ╰─ attrName - │ ││ ╰─ attrValue.value "async function (x) { console.log(\"y\") }" - │ │├─ attrValue "= async function (x) { console.log(\"y\") }" - │ │╰─ attrName - ╰─ ╰─ tagName \ No newline at end of file + │ │││ │ │╰─ openTagEnd:selfClosed "/>" + │ │││ │ ╰─ attrName + │ │││ ╰─ attrValue.value "async function (x) { console.log(\"y\") }" + │ ││├─ attrValue "= async function (x) { console.log(\"y\") }" + │ ││╰─ attrName + │ │╰─ tagName + ╰─ ╰─ text "\n" \ No newline at end of file diff --git a/src/states/EXPRESSION.ts b/src/states/EXPRESSION.ts index 1a2da473..3b8967e7 100644 --- a/src/states/EXPRESSION.ts +++ b/src/states/EXPRESSION.ts @@ -203,8 +203,8 @@ export const EXPRESSION: StateDefinition = { function buildOperatorPattern(isConcise: boolean) { const binary = - "[!~*%&^|?:<]+" + // Any of these characters can always continue an expression - "|(?<=[!=<>&^~|/*?%+-])=|=(?=[!=<>&^~|/*?%+-])" + // Match equality and multi char assignment operators w/o matching equals by itself + "(?:[!~*%&^|?:<]+=*)+" + // Any of these characters can always continue an expression + "|[>/+-=]+=|=>" + // Match equality and multi char assignment operators w/o matching equals by itself "|(?"}])` + // We only continue after a forward slash if it isn't //, /* (or /> in html mode)