OILS / demo / old / run.sh View on Github | oilshell.org

76 lines, 40 significant
1#!/usr/bin/env bash
2#
3# Usage:
4# ./run.sh <function name>
5
6set -o nounset
7set -o pipefail
8set -o errexit
9
10export PYTHONPATH=.
11
12# OHeap V1 no longer works, but I'm saving the code for reference.
13asdl-oheap-cpp() {
14 local schema=${1:-asdl/typed_arith.asdl}
15 local src=${2:-_tmp/typed_arith.asdl.h}
16 misc/old/gen_oheap_cpp.py cpp $schema > $src
17 ls -l $src
18 wc -l $src
19}
20
21#
22# UNTESTED
23#
24
25smoke-test() {
26 local arith_expr=${1:-"2 + 3 * 4"}
27 # Print Schema (asdl_.py, py_meta.py)
28 asdl-py asdl/arith.asdl
29
30 # Parse real values and pretty print (format.py)
31 asdl-arith-format "$arith_expr"
32
33 # encode.py
34 asdl-arith-oheap "$arith_expr"
35}
36
37asdl-arith-oheap() {
38 local arith_expr=${1:-"1 + 2 * 3"}
39 local name=arith
40 local data=_tmp/${name}.bin
41
42 # Write a binary
43 asdl-arith-encode "$arith_expr" $data
44
45 local bin=_tmp/${name}_demo
46
47 build-demo asdl/arith.asdl
48
49 set -x
50 #gdb-trace $bin $data
51 $bin $data
52}
53
54# TODO: How big is oheap vs. the virtual memory size?
55
56osh-demo() {
57 local name=osh
58 local data=_tmp/${name}.bin
59
60 local code='echo hi; echo bye # comment'
61 local code='declare -r -x foo' # for testing repeated array
62 local code='echo x && echo y && echo z || die' # for && || chains
63 #local code='echo $(( 2 + 3 ))'
64 #local code='echo $(( -2 * -3 ))' # test negative integers
65 bin/osh -n --ast-format oheap -c "$code" > $data
66
67 ls -l $data
68
69 core/id_kind_gen.py cpp > _tmp/id_kind.h
70 build-demo osh/osh.asdl
71
72 local bin=_tmp/${name}_demo
73 $bin $data
74}
75
76"$@"