summaryrefslogtreecommitdiff
path: root/static/js/main.js
blob: a3583ada58108293597d046cbe445a2fd967f9dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const prog = `
DISCOVER HOW TO factorial WITH n
WE SAID
    WHAT IF n IS ACTUALLY 0
    WE SAID
        SHOCKING DEVELOPMENT 1
    END OF STORY
    LIES! WE SAID
        SHOCKING DEVELOPMENT n MULTIPLY factorial OF n SUBTRACT 1
    END OF STORY
END OF STORY

EXPERTS CLAIM result TO BE factorial OF 10
YOU WON'T WANT TO MISS 'RESULT IS'
YOU WON'T WANT TO MISS result

PLEASE LIKE AND SUBSCRIBE
`;

const Runtime = {
    print(s) {
        console.log(s.toString());
    }
}

// main
try {
    const tokens = tokenize(prog);
    const nodes = new Parser(tokens).parse();
    const env = new Environment(Runtime);
    env.run(nodes);
} catch (e) {
    console.error(e);
}

const {
    Component,
} = window.Torus;

class Editor extends Component {
    init() {
        this.val = '';
    }
    compose() {

    }
}

class App extends Component {
    compose() {
        return jdom`<main>
            <h1>Tabloid</h1>
            <p class="subtitle">The Clickbait Headline Programming Language</p>
        </main>`;
    }
}

const app = new App();
document.body.appendChild(app.node);