|
|
@ -1,5 +1,4 @@
|
|
|
|
import { parseExpressionAt } from 'acorn';
|
|
|
|
import { parseExpressionAt } from 'acorn';
|
|
|
|
import repeat from '../../utils/repeat';
|
|
|
|
|
|
|
|
import { Parser } from '../index';
|
|
|
|
import { Parser } from '../index';
|
|
|
|
|
|
|
|
|
|
|
|
const DIRECTIVES: Record<string, {
|
|
|
|
const DIRECTIVES: Record<string, {
|
|
|
@ -101,35 +100,26 @@ Object.keys(DIRECTIVES).forEach(name => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function readExpression(parser: Parser, start: number, quoteMark: string|null) {
|
|
|
|
function readExpression(parser: Parser, start: number, quoteMark: string|null) {
|
|
|
|
let str = '';
|
|
|
|
let i = start;
|
|
|
|
let escaped = false;
|
|
|
|
let escaped = false;
|
|
|
|
|
|
|
|
|
|
|
|
for (let i = start; i < parser.template.length; i += 1) {
|
|
|
|
for (; i < parser.template.length; i += 1) {
|
|
|
|
const char = parser.template[i];
|
|
|
|
const char = parser.template[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (quoteMark) {
|
|
|
|
if (quoteMark) {
|
|
|
|
if (char === quoteMark) {
|
|
|
|
if (char === quoteMark) {
|
|
|
|
if (escaped) {
|
|
|
|
if (!escaped) break;
|
|
|
|
str += quoteMark;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (escaped) {
|
|
|
|
} else if (escaped) {
|
|
|
|
str += '\\' + char;
|
|
|
|
|
|
|
|
escaped = false;
|
|
|
|
escaped = false;
|
|
|
|
} else if (char === '\\') {
|
|
|
|
} else if (char === '\\') {
|
|
|
|
escaped = true;
|
|
|
|
escaped = true;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
str += char;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (/[\s\/>]/.test(char)) {
|
|
|
|
} else if (/[\s\/>]/.test(char)) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
str += char;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const expression = parseExpressionAt(repeat(' ', start) + str, start, {
|
|
|
|
const expression = parseExpressionAt(parser.template.slice(0, i), start, {
|
|
|
|
ecmaVersion: 9,
|
|
|
|
ecmaVersion: 9,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
parser.index = expression.end;
|
|
|
|
parser.index = expression.end;
|
|
|
|