parserlib: reimplement d9a80623 properly

This commit is contained in:
tophf 2022-01-18 20:24:41 +03:00
parent f7729eac15
commit 42d6e2f2af

View File

@ -4381,18 +4381,10 @@ self.parserlib = (() => {
let next, tt; let next, tt;
while ((next = stream.get(true)).value !== '}' && (tt = next.type)) { while ((next = stream.get(true)).value !== '}' && (tt = next.type)) {
try { try {
// Pre-check to avoid calling _ws too much as it's wasteful
if (tt === Tokens.S ||
tt === Tokens.COMMENT ||
tt === Tokens.USO_VAR) {
this._ws(next, true);
tt = 0;
}
if (tt === Tokens.SEMICOLON || if (tt === Tokens.SEMICOLON ||
this._ws(next, true) ||
readMargins && this._margin() || readMargins && this._margin() ||
(tt && stream.unget(), this._declaration(true, Props)) || (stream.unget(), this._declaration(true, Props))) {
(next = stream.LT(1)).value === ';' ||
this._ws(null, true)) {
continue; continue;
} }
break; break;
@ -4427,6 +4419,14 @@ self.parserlib = (() => {
} }
_ws(start, skipUsoVar) { _ws(start, skipUsoVar) {
const tt = start && start.type;
if (tt && !(
tt === Tokens.S ||
tt === Tokens.COMMENT ||
tt === Tokens.USO_VAR && skipUsoVar
)) {
return '';
}
const stream = this._tokenStream; const stream = this._tokenStream;
const tokens = skipUsoVar ? TT.usoS : Tokens.S; const tokens = skipUsoVar ? TT.usoS : Tokens.S;
let ws = start ? start.value : ''; let ws = start ? start.value : '';