Modularize UI, make it a bit more Lisp independent
This commit is contained in:
parent
e1e1b90579
commit
c3edf193c4
19 changed files with 973 additions and 884 deletions
|
|
@ -1,78 +1 @@
|
|||
import { CodePointString, sourceText } from 'source-region';
|
||||
import { parseDocument, programOf } from './parser';
|
||||
import { matchCodePointString } from './recognizers';
|
||||
import { Program } from './syntax';
|
||||
|
||||
// === Experiments ===
|
||||
|
||||
function experiment00_emptyDocument(): void {
|
||||
logParse("empty document", "");
|
||||
}
|
||||
|
||||
function experiment01_topLevelExpressions(): void {
|
||||
logParse("top-level expressions", "foo 123 (bar baz_1 qux-2) [a, b, c]");
|
||||
}
|
||||
|
||||
function experiment02_nestedLists(): void {
|
||||
logParse("nested lists", "(define square (_ x) (* x x))");
|
||||
}
|
||||
|
||||
function experiment03_unclosedList(): void {
|
||||
logParse("unclosed list", "(foo 123\n (bar 456)");
|
||||
}
|
||||
|
||||
function experiment04_recoverAtDocumentLevel(): void {
|
||||
logParse("document recovery", "foo ) @@@ (bar 1) 99");
|
||||
}
|
||||
|
||||
function experiment05_recoverInsideList(): void {
|
||||
logParse("list recovery", "(foo @@@ 1 (bar # 2) baz)");
|
||||
}
|
||||
|
||||
function experiment06_unicodeSpans(): void {
|
||||
logParse("unicode spans", "alpha 💥 (beta 2)");
|
||||
}
|
||||
|
||||
function experiment07_matchCodePointString(): void {
|
||||
const region = sourceText("λx").fullRegion();
|
||||
const cursor = region.makeCursor();
|
||||
const lambda = CodePointString.makeFromString("λ");
|
||||
console.log("==== recognizer:match code point string ====");
|
||||
console.dir(matchCodePointString(cursor, lambda), { depth: null });
|
||||
console.log("cursor", cursor.current());
|
||||
}
|
||||
|
||||
function experiment08_squareListSeparator(): void {
|
||||
logParse("square list separator", "[a, b c, d]");
|
||||
}
|
||||
|
||||
function experiment09_invalidNumberFragment(): void {
|
||||
logParse("invalid number fragment", "123fasd");
|
||||
}
|
||||
|
||||
function experiment10_repeatedLeadingComma(): void {
|
||||
logParse("repeated leading comma", "[, , foo, bar]");
|
||||
}
|
||||
|
||||
function logParse(name: string, input: string): void {
|
||||
const region = sourceText(input).fullRegion();
|
||||
const result = parseDocument(region);
|
||||
console.log(`==== parser:${name} ====`);
|
||||
console.log(input);
|
||||
console.log(result.syntax.tag, Program.show(programOf(result.syntax)));
|
||||
console.dir(result.errors, { depth: null });
|
||||
}
|
||||
|
||||
[
|
||||
experiment00_emptyDocument,
|
||||
experiment01_topLevelExpressions,
|
||||
experiment02_nestedLists,
|
||||
experiment03_unclosedList,
|
||||
experiment04_recoverAtDocumentLevel,
|
||||
experiment05_recoverInsideList,
|
||||
experiment06_unicodeSpans,
|
||||
experiment07_matchCodePointString,
|
||||
experiment08_squareListSeparator,
|
||||
experiment09_invalidNumberFragment,
|
||||
experiment10_repeatedLeadingComma,
|
||||
].forEach((experiment) => experiment());
|
||||
import './languages/lisp/experiments';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue