最后活跃于 4 days ago

A simple command parser.

june's Avatar june 修订了这个 Gist 4 days ago. 转到此修订

1 file changed, 29 insertions

command.nv(文件已创建)

@@ -0,0 +1,29 @@
1 + |:: read a line? :@stdio: (10 $x)|
2 + :@stdio: 10
3 + :buffer: $x
4 + |:: read a line :@stdio: 10|
5 + |:: read a line?|
6 + :@stdio: read
7 +
8 + |:: print the buffer? :buffer: $x|
9 + :@stdio: write $x
10 + |:: print the buffer|
11 + :@stdio: write 10
12 +
13 + |:: skip leading whitespace? :buffer: 10 |
14 + |:: skip leading whitespace? :buffer: 9 |
15 + |:: skip leading whitespace? :buffer: ' '|
16 + |:: skip leading whitespace|
17 +
18 + |:: parse a command :buffer: "quit"|
19 + :quit:
20 + |:: parse a command :buffer: "say"|
21 + :: skip leading whitespace
22 + :: print the buffer
23 +
24 + |:: command loop :quit:|
25 + |:: command loop?|
26 + :: read a line
27 + :: parse a command
28 +
29 + ||:: command loop
上一页 下一页