Experimenting with parser further.

This commit is contained in:
Joshua Bemenderfer
2022-11-13 09:50:23 -05:00
parent f7a37681de
commit e07e3a837c
5 changed files with 151 additions and 23 deletions

View File

@@ -1,18 +1,18 @@
import { parseLine as f, createLineData as s } from "./parser.js";
function d(t, l = " ") {
function d(i, l = " ") {
let n = s(null, l);
const i = {
const t = {
ended: !1,
clone() {
return d(t.clone(), l);
return d(i.clone(), l);
},
async next() {
if (n.line = await t.next(), n.line === null)
if (n.line = await i.next(), n.line === null)
return !0;
f(n);
},
current() {
return i;
return t;
},
line() {
var e;
@@ -26,16 +26,19 @@ function d(t, l = " ") {
var e;
return (e = n.line) == null ? void 0 : e.slice(n.offsetTail);
},
level() {
return n.level;
},
async content(e = -1, r = []) {
var u;
return e === -1 && (e = n.level + 1), await i.next() || n.level < e ? r.join(`
`) : (r.push(((u = n.line) == null ? void 0 : u.slice(e)) || ""), i.content(e, r));
return e === -1 && (e = n.level + 1), await t.next() || n.level < e ? r.join(`
`) : (r.push(((u = n.line) == null ? void 0 : u.slice(e)) || ""), t.content(e, r));
},
async seek(e, r = -1) {
return r === -1 && (r = n.level), await i.next() ? !1 : i.head() === e ? i : n.level < r ? !1 : i.seek(e, r);
return r === -1 && (r = n.level), await t.next() ? !1 : t.head() === e ? t : n.level < r ? !1 : t.seek(e, r);
}
};
return i;
return t;
}
export {
d as useDocument