fez-lisp 1.5.194 → 1.5.195
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/macros.js +27 -2
package/package.json
CHANGED
package/src/macros.js
CHANGED
@@ -671,7 +671,31 @@ export const replaceStrings = (source) => {
|
|
671
671
|
)
|
672
672
|
return source
|
673
673
|
}
|
674
|
-
|
674
|
+
export const replaceTemplateLiteralStrings = (source) => {
|
675
|
+
// const quotes = source.match(/"(.*?)"/g)
|
676
|
+
const quotes = source.match(/`"(?:.*?(\n|\r))*?.*?"/g)
|
677
|
+
// TODO: handle escaping
|
678
|
+
if (quotes)
|
679
|
+
for (const q of quotes) {
|
680
|
+
const string = [...q.replaceAll('\r', '')].slice(2, -1)
|
681
|
+
let str = `(array `
|
682
|
+
let isVar = false
|
683
|
+
for (let i = 0; i < string.length; ++i) {
|
684
|
+
if (isVar) {
|
685
|
+
if (string[i] === '}') {
|
686
|
+
isVar = false
|
687
|
+
str += ' (array '
|
688
|
+
} else str += string[i]
|
689
|
+
} else if (string[i] === '{') {
|
690
|
+
isVar = true
|
691
|
+
str += ') '
|
692
|
+
} else str += string[i].charCodeAt(0) + ' '
|
693
|
+
}
|
694
|
+
str += ')'
|
695
|
+
source = source.replaceAll(q, `(array:concat (array ${str}))`)
|
696
|
+
}
|
697
|
+
return source
|
698
|
+
}
|
675
699
|
const iron = (scope) => {
|
676
700
|
const indecies = scope
|
677
701
|
.map((x, i) => {
|
@@ -708,7 +732,8 @@ export const replaceQuotes = (source) =>
|
|
708
732
|
.replaceAll(/\{/g, `(${SUGGAR.CREATE_LIST} `)
|
709
733
|
.replaceAll(/\}/g, ')')
|
710
734
|
|
711
|
-
export const deSuggarSource = (source) =>
|
735
|
+
export const deSuggarSource = (source) =>
|
736
|
+
replaceQuotes(replaceStrings(replaceTemplateLiteralStrings(source)))
|
712
737
|
export const handleUnbalancedQuotes = (source) => {
|
713
738
|
const diff = (source.match(/\"/g) ?? []).length % 2
|
714
739
|
if (diff !== 0) throw new SyntaxError(`Quotes are unbalanced "`)
|