Merge pull request #2 from catseye/develop-2019-1
Develop 2019-1
Chris Pressey authored 1 year, 10 months ago
GitHub committed 1 year, 10 months ago
0 | b97221f44b177b089b217ddcb876867916bd3380 rel_1_0_2011_1214 | |
1 | 3071f1a0f3d45b62722faa5d9c77b5b532e85b96 rel_1_0_2014_0819 | |
2 | afa5863bee292699c192684fb7393cb44264c3a8 rel_1_0_2015_0101 | |
3 | f1ca72f918540e48ff8d094f4dd04c67e2a1918a rel_1_0_2016_0504 |
0 | #!/bin/sh | |
1 | ||
2 | THIS=`realpath $0` | |
3 | DIR=`dirname $THIS` | |
4 | NAME=`basename $THIS` | |
5 | SRC=$DIR/../src | |
6 | if [ -x $DIR/$NAME.exe ] ; then | |
7 | exec $DIR/$NAME.exe $* | |
8 | elif command -v runhaskell 2>&1 >/dev/null ; then | |
9 | exec runhaskell -i$SRC $SRC/Main.hs $* | |
10 | elif command -v runhugs 2>&1 >/dev/null ; then | |
11 | exec runhugs -i$SRC $SRC/Main.hs $* | |
12 | else | |
13 | echo "Cannot run $NAME; neither $NAME.exe, runhaskell, nor runhugs found." | |
14 | exit 1 | |
15 | fi |
1 | 1 | |
2 | 2 | PROG=qlzqqlzuup |
3 | 3 | |
4 | if [ x`which ghc` = x -a x`which runhugs` = x ]; then | |
5 | echo "Neither ghc nor runhugs found on search path." | |
6 | exit 1 | |
4 | if command -v ghc >/dev/null 2>&1; then | |
5 | echo "building $PROG.exe with ghc" | |
6 | (cd src && ghc --make Main.hs -o ../bin/$PROG.exe) | |
7 | else | |
8 | echo "ghc not found, not building $PROG.exe" | |
7 | 9 | fi |
8 | 10 | |
9 | mkdir -p bin | |
10 | ||
11 | if [ x`which ghc` = x -o ! x$USE_HUGS = x ]; then | |
12 | # create script to run with Hugs | |
13 | cat >bin/$PROG <<'EOF' | |
14 | #!/bin/sh | |
15 | THIS=`realpath $0` | |
16 | DIR=`dirname $THIS`/../src | |
17 | runhugs $DIR/Main.hs $* | |
18 | EOF | |
19 | chmod 755 bin/$PROG | |
11 | if command -v hastec >/dev/null 2>&1; then | |
12 | echo "building $PROG.js with hastec" | |
13 | (cd src && hastec --make HasteMain.hs -o ../demo/$PROG.js) | |
20 | 14 | else |
21 | cd src && ghc --make Main.hs -o ../bin/$PROG | |
15 | echo "hastec not found, not building $PROG.js" | |
22 | 16 | fi |
0 | function launch(config) { | |
1 | config.container.innerHTML = ` | |
2 | <textarea id="prog" rows="10" cols="80"></textarea> | |
3 | <div id="control-panel"></div> | |
4 | <div><button id="run-button">Run</button></div> | |
5 | <pre id="result"></pre> | |
6 | `; | |
7 | ||
8 | function makeSelect(container, labelText, optionsArray, fun) { | |
9 | var label = document.createElement('label'); | |
10 | label.innerHTML = labelText; | |
11 | container.appendChild(label); | |
12 | var select = document.createElement("select"); | |
13 | for (var i = 0; i < optionsArray.length; i++) { | |
14 | var op = document.createElement("option"); | |
15 | op.text = optionsArray[i].filename; | |
16 | op.value = optionsArray[i].contents; | |
17 | select.options.add(op); | |
18 | } | |
19 | select.onchange = function(e) { | |
20 | fun(optionsArray[select.selectedIndex]); | |
21 | }; | |
22 | select.selectedIndex = 0; | |
23 | label.appendChild(select); | |
24 | return select; | |
25 | }; | |
26 | ||
27 | function selectOptionByText(selectElem, text) { | |
28 | var optElem; | |
29 | for (var i = 0; optElem = selectElem.options[i]; i++) { | |
30 | if (optElem.text === text) { | |
31 | selectElem.selectedIndex = i; | |
32 | selectElem.dispatchEvent(new Event('change')); | |
33 | return; | |
34 | } | |
35 | } | |
36 | } | |
37 | ||
38 | var controlPanel = document.getElementById('control-panel'); | |
39 | var select = makeSelect(controlPanel, "example program:", examplePrograms, function(option) { | |
40 | document.getElementById('prog').value = option.contents; | |
41 | }); | |
42 | selectOptionByText(select, "length-and-sum.quylthulg"); | |
43 | } | |
44 | ||
45 | launch({ container: document.getElementById('installation') }); |
0 | <!DOCTYPE html> | |
1 | <head> | |
2 | <meta charset="utf-8"> | |
3 | <title>Quylthulg</title> | |
4 | </head> | |
5 | <body> | |
6 | ||
7 | <h1>Quylthulg</h1> | |
8 | ||
9 | <p>(Qlzqqlzuup.hs compiled to .js by <code>hastec</code>, running in HTML5 document)</p> | |
10 | ||
11 | <div id="installation"></div> | |
12 | ||
13 | <script src="../eg/examplePrograms.jsonp.js"></script> | |
14 | <script src="qlzqqlzuup-hastec-launcher.js"></script> | |
15 | <script src="qlzqqlzuup.js"></script> | |
16 | </body> |
0 | examplePrograms = [ | |
1 | { | |
2 | "contents": "foreach $x$ = :L:[1, 2, 3, goto $L$] with $a$ = 0 be $x$ else be null\n", | |
3 | "filename": "infinite-loop.quylthulg" | |
4 | }, | |
5 | { | |
6 | "contents": "foreach $x$ = [10, 20, 40]\n with $a$ = ,0,0, be\n ,+<$a$<0<+1+,+>$a$>0>+$x$+,\n else be\n null\n", | |
7 | "filename": "length-and-sum.quylthulg" | |
8 | }, | |
9 | { | |
10 | "contents": "foreach $x$ = [10, 20, 40, 80]\n with $a$ = null be\n ,$x$,$a$,\n else be\n null\n", | |
11 | "filename": "reverse.quylthulg" | |
12 | }, | |
13 | { | |
14 | "contents": "{*[SQR][*{X}*{X}*]}{*[X][5]}{SQR}\n", | |
15 | "filename": "square.quylthulg" | |
16 | }, | |
17 | { | |
18 | "contents": "foreach $x$ = [10, 20, 40, 80, 60, 10, 30]\n with $a$ = ,null,[1,1,1,1], be\n foreach $n$=>>$a$>null>>null>\n with $r$=99999 be\n ,,$x$,<$a$<null<,,>>$a$>null>>null>,\n else be\n abort\n else be\n null\n", | |
19 | "filename": "take-3-reverse.quylthulg" | |
20 | }, | |
21 | { | |
22 | "contents": "foreach $x$ = :L:[10, 20, goto $L$]\n with $a$ = ,null,[1,1,1,1,1,1], be\n foreach $n$=>>$a$>null>>null>\n with $r$=99999 be\n ,,$x$,<$a$<null<,,>>$a$>null>>null>,\n else be\n abort\n else be\n null\n", | |
23 | "filename": "take-5-from-cyclic-list.quylthulg" | |
24 | } | |
25 | ]; |
0 | module Main where | |
1 | ||
2 | import Haste | |
3 | import Haste.DOM | |
4 | import Haste.Events | |
5 | ||
6 | import Qlzqqlzuup | |
7 | ||
8 | main = withElems ["prog", "result", "run-button"] driver | |
9 | ||
10 | escapeHTML "" = "" | |
11 | escapeHTML ('<' : rest) = "<" ++ escapeHTML rest | |
12 | escapeHTML ('>' : rest) = ">" ++ escapeHTML rest | |
13 | escapeHTML ('&' : rest) = "&" ++ escapeHTML rest | |
14 | escapeHTML (c : rest) = (c : escapeHTML rest) | |
15 | ||
16 | driver [progElem, resultElem, runButtonElem] = do | |
17 | onEvent runButtonElem Click $ \_ -> execute | |
18 | where | |
19 | execute = do | |
20 | Just prog <- getValue progElem | |
21 | setProp resultElem "innerHTML" (escapeHTML $ showRun prog) |
0 | 0 | #!/bin/sh |
1 | 1 | |
2 | ./build.sh || exit 1 | |
3 | ||
4 | falderal tests/Quylthulg.markdown | |
2 | APPLIANCES="tests/appliances/qlzqqlzuup.md" | |
3 | falderal $APPLIANCES tests/Quylthulg.markdown |
4 | 4 | exhaustive, but provides a basic sanity check that the language I've designed |
5 | 5 | here comes close to what I had in mind. |
6 | 6 | |
7 | Quylthulg Tests | |
8 | --------------- | |
9 | ||
10 | 7 | -> Tests for functionality "Interpret Quylthulg Program" |
11 | ||
12 | -> Functionality "Interpret Quylthulg Program" is implemented by | |
13 | -> shell command | |
14 | -> "bin/qlzqqlzuup %(test-body-file)" | |
15 | ||
16 | -> Functionality "Interpret Quylthulg Program" is implemented by | |
17 | -> shell command | |
18 | -> "bin/qlzqqlzuup -m %(test-body-file)" | |
19 | 8 | |
20 | 9 | Integer expressions. |
21 | 10 | -------------------- |