読者です 読者をやめる 読者になる 読者になる

IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

streemのインストール

作業場所の作成

foo:work03 $ mkdir streem
foo:work03 $ cd streem

ソースコードの取得

foo:streem $ git clone https://github.com/matz/streem.git
Cloning into 'streem'...
remote: Counting objects: 4041, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 4041 (delta 3), reused 0 (delta 0), pack-reused 4033
Receiving objects: 100% (4041/4041), 758.46 KiB | 263.00 KiB/s, done.
Resolving deltas: 100% (2857/2857), done.
Checking connectivity... done.
foo:streem $ pwd
/Users//work03/streem
foo:streem $ ls
streem

取得内容の確認

foo:streem $ tree ./streem/
./streem/
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── examples
│   ├── 01cat.strm
│   ├── 02hello.strm
│   ├── 03fizzbuzz.strm
│   ├── 04emit.strm
│   ├── 05emit.strm
│   ├── 05filter.strm
│   ├── 06echo.strm
│   ├── 07netcat.strm
│   ├── 08chat.strm
│   └── 09match.strm
├── src
│   ├── Makefile
│   ├── args.c
│   ├── array.c
│   ├── atomic.h
│   ├── core.c
│   ├── csv.c
│   ├── env.c
│   ├── exec.c
│   ├── graph.c
│   ├── init.c
│   ├── io.c
│   ├── iter.c
│   ├── khash.h
│   ├── kvs.c
│   ├── latch.c
│   ├── lex.l
│   ├── main.c
│   ├── math.c
│   ├── ncpu.c
│   ├── node.c
│   ├── node.h
│   ├── ns.c
│   ├── number.c
│   ├── parse.y
│   ├── pollfd.c
│   ├── pollfd.h
│   ├── queue.c
│   ├── queue.h
│   ├── random.c
│   ├── signal.c
│   ├── socket.c
│   ├── sort.c
│   ├── stat.c
│   ├── string.c
│   ├── strm.h
│   ├── strptime.c
│   ├── time.c
│   └── value.c
└── vagrant
    ├── Vagrantfile
    └── bootstrap.sh

3 directories, 54 files

ブランチ作成

foo:streem $ git branch
* master
foo:streem $ git branch test01
foo:streem $ git checkout test01
Switched to branch 'test01'
foo:streem $ git branch
  master
* test01

コンパイル(ワーニングがでますが、実行には問題ないようです。)

foo:streem $ make 
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src all
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o args.o args.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o array.o array.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o core.o core.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o csv.o csv.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o env.o env.c
env.c:4:1: warning: unused function 'kh_destroy_env' [-Wunused-function]
KHASH_MAP_INIT_INT64(env, strm_value);
^
./khash.h:584:2: note: expanded from macro 'KHASH_MAP_INIT_INT64'
        KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
        ^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:205:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_destroy_##name(kh_##name##_t *h) \
                   ^
<scratch space>:243:1: note: expanded from here
kh_destroy_env
^
env.c:4:1: warning: unused function 'kh_clear_env' [-Wunused-function]
./khash.h:584:2: note: expanded from macro 'KHASH_MAP_INIT_INT64'
        KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
        ^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:213:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_clear_##name(kh_##name##_t *h) \
                   ^
<scratch space>:246:1: note: expanded from here
kh_clear_env
^
2 warnings generated.
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o exec.o exec.c
exec.c:399:12: warning: variable 'n' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  else if (lambda->body->type == NODE_PLAMBDA) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exec.c:429:7: note: uninitialized use occurs here
  if (n == STRM_NG && strm) {
      ^
exec.c:399:8: note: remove the 'if' if its condition is always true
  else if (lambda->body->type == NODE_PLAMBDA) {
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exec.c:377:11: note: initialize the variable 'n' to silence this warning
  int i, n;
          ^
           = 0
1 warning generated.
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o graph.o graph.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o init.o init.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o io.o io.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o iter.o iter.c
iter.c:555:1: warning: unused function 'kh_destroy_rbk' [-Wunused-function]
KHASH_MAP_INIT_INT64(rbk, strm_value);
^
./khash.h:584:2: note: expanded from macro 'KHASH_MAP_INIT_INT64'
        KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
        ^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:205:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_destroy_##name(kh_##name##_t *h) \
                   ^
<scratch space>:243:1: note: expanded from here
kh_destroy_rbk
^
iter.c:555:1: warning: unused function 'kh_clear_rbk' [-Wunused-function]
./khash.h:584:2: note: expanded from macro 'KHASH_MAP_INIT_INT64'
        KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
        ^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:213:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_clear_##name(kh_##name##_t *h) \
                   ^
<scratch space>:246:1: note: expanded from here
kh_clear_rbk
^
iter.c:555:1: warning: unused function 'kh_get_rbk' [-Wunused-function]
./khash.h:584:2: note: expanded from macro 'KHASH_MAP_INIT_INT64'
        KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
        ^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:220:16: note: expanded from macro 'KHASH_IMPL'
        SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
                      ^
<scratch space>:249:1: note: expanded from here
kh_get_rbk
^
3 warnings generated.
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o kvs.o kvs.c
kvs.c:5:1: warning: unused function 'kh_clear_kvs' [-Wunused-function]
KHASH_INIT(kvs, strm_string, strm_value, 1, kh_int64_hash_func, kh_int64_hash_equal);
^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:213:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_clear_##name(kh_##name##_t *h) \
                   ^
<scratch space>:122:1: note: expanded from here
kh_clear_kvs
^
kvs.c:6:1: warning: unused function 'kh_clear_txn' [-Wunused-function]
KHASH_INIT(txn, strm_string, strm_value, 1, kh_int64_hash_func, kh_int64_hash_equal);
^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:213:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_clear_##name(kh_##name##_t *h) \
                   ^
<scratch space>:150:1: note: expanded from here
kh_clear_txn
^
2 warnings generated.
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o latch.o latch.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o main.o main.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o math.o math.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o ncpu.o ncpu.c
flex --header-file=lex.yy.h -olex.yy.c lex.l
bison -y -d -o y.tab.c parse.y
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o node.o node.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o ns.o ns.c
ns.c:4:1: warning: unused function 'kh_destroy_ns' [-Wunused-function]
KHASH_MAP_INIT_INT64(ns, strm_state*);
^
./khash.h:584:2: note: expanded from macro 'KHASH_MAP_INIT_INT64'
        KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
        ^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:205:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_destroy_##name(kh_##name##_t *h) \
                   ^
<scratch space>:243:1: note: expanded from here
kh_destroy_ns
^
ns.c:4:1: warning: unused function 'kh_clear_ns' [-Wunused-function]
./khash.h:584:2: note: expanded from macro 'KHASH_MAP_INIT_INT64'
        KHASH_INIT(name, khint64_t, khval_t, 1, kh_int64_hash_func, kh_int64_hash_equal)
        ^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:213:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_clear_##name(kh_##name##_t *h) \
                   ^
<scratch space>:246:1: note: expanded from here
kh_clear_ns
^
2 warnings generated.
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o number.o number.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o pollfd.o pollfd.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o queue.o queue.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o random.o random.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o signal.o signal.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o socket.o socket.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o sort.o sort.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o stat.o stat.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o string.o string.c
string.c:62:1: warning: unused function 'kh_destroy_sym' [-Wunused-function]
KHASH_INIT(sym, struct sym_key, strm_string, 1, sym_hash, sym_eq);
^
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:205:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_destroy_##name(kh_##name##_t *h) \
                   ^
<scratch space>:119:1: note: expanded from here
kh_destroy_sym
^
string.c:62:1: warning: unused function 'kh_clear_sym' [-Wunused-function]
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:213:13: note: expanded from macro 'KHASH_IMPL'
        SCOPE void kh_clear_##name(kh_##name##_t *h) \
                   ^
<scratch space>:122:1: note: expanded from here
kh_clear_sym
^
string.c:62:1: warning: unused function 'kh_get_sym' [-Wunused-function]
./khash.h:349:2: note: expanded from macro 'KHASH_INIT'
        KHASH_INIT2(name, static kh_inline, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:346:2: note: expanded from macro 'KHASH_INIT2'
        KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal)
        ^
./khash.h:220:16: note: expanded from macro 'KHASH_IMPL'
        SCOPE khint_t kh_get_##name(const kh_##name##_t *h, khkey_t key) \
                      ^
<scratch space>:125:1: note: expanded from here
kh_get_sym
^
3 warnings generated.
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o strptime.o strptime.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o time.o time.c
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE -MMD -MP -c -o value.o value.c
gcc -g -MMD -MP -c y.tab.c -o parse.o
mkdir -p "$(dirname ../bin/streem)"
gcc -std=gnu99 -g -ggdb -Wall -DNO_LOCKFREE_QUEUE args.o array.o core.o csv.o env.o exec.o graph.o init.o io.o iter.o kvs.o latch.o main.o math.o ncpu.o node.o ns.o number.o pollfd.o queue.o random.o signal.o socket.o sort.o stat.o string.o strptime.o time.o value.o parse.o -o ../bin/streem -lpthread -lm
foo:streem $ 

実行(vで構文木の内容が出力されます。eはコマンドラインで直接プログラムを指定する方法です。)

foo:streem $ ./bin/streem -ve "1+1"
NODES:
 OP:
  op: +
  VALUE(NUMBER): 1
  VALUE(NUMBER): 1
foo:streem $ ./bin/streem -ve "print 1+1"
-e:1:syntax error, unexpected lit_number, expecting $end
foo:streem $ ./bin/streem -ve "print (1+1)"
NODES:
 CALL:
   print
   ARRAY:
    OP:
     op: +
     VALUE(NUMBER): 1
     VALUE(NUMBER): 1
2
foo:streem $ ./bin/streem -ve "stdin | stdout"
NODES:
 OP:
  op: |
  IDENT: stdin
  IDENT: stdout
aa
aa
bb
bb
^C

ファイルからの実行

foo:streem $ ./bin/streem ./examples/05filter.strm 
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
foo:streem $ 

統計情報

sorce line word char
../streem/src/args.c 240 569 5502
../streem/src/array.c 161 399 3291
../streem/src/core.c 273 593 5418
../streem/src/csv.c 480 1326 10733
../streem/src/env.c 117 322 2485
../streem/src/exec.c 1144 3135 28917
../streem/src/graph.c 243 558 4419
../streem/src/init.c 29 51 787
../streem/src/io.c 393 977 7996
../streem/src/iter.c 841 2117 17859
../streem/src/kvs.c 431 1231 10174
../streem/src/latch.c 235 521 4733
../streem/src/lex.yy.c 2466 10114 70602
../streem/src/main.c 340 791 7755
../streem/src/math.c 94 231 2335
../streem/src/ncpu.c 37 48 433
../streem/src/node.c 712 1537 12889
../streem/src/ns.c 69 172 1396
../streem/src/number.c 167 420 4205
../streem/src/pollfd.c 254 803 6150
../streem/src/queue.c 194 435 3608
../streem/src/random.c 249 647 5168
../streem/src/signal.c 84 213 1599
../streem/src/socket.c 203 548 4924
../streem/src/sort.c 593 1566 13128
../streem/src/stat.c 541 1573 12498
../streem/src/string.c 437 1048 8580
../streem/src/strptime.c 359 1088 12730
../streem/src/time.c 605 1742 14295
../streem/src/value.c 531 1200 10454
../streem/src/y.tab.c 2779 11110 86882
total 15301 47085 381945
find ../streem/src -name '*.c' | xargs wc | awk  '{print "|" $4 "|" $1 "|" $2 "|" $3 "|"}'