Skip to content

Commit ab7bcff

Browse files
authored
Merge pull request miloyip#40 from miloyip/draft
Add tutorial 05
2 parents 9d4ea46 + 6af7159 commit ab7bcff

27 files changed

+1309
-1
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
2. [解析数字](tutorial02/tutorial02.md)(2016/9/18 完成):JSON number 的语法。练习 JSON number 类型的校验。[解析数字解答篇](tutorial02_answer/tutorial02_answer.md)(2016/9/20 完成)。
4343
3. [解析字符串](tutorial03/tutorial03.md)(2016/9/22 完成):使用 union 存储 variant、自动扩展的堆栈、JSON string 的语法、valgrind。练习最基本的 JSON string 类型的解析、内存释放。[解析字符串解答篇](tutorial03_answer/tutorial03_answer.md)(2016/9/27 完成)。
4444
4. [Unicode](tutorial04/tutorial04.md)(2016/10/2 完成):Unicode 和 UTF-8 的基本知识、JSON string 的 unicode 处理。练习完成 JSON string 类型的解析。[Unicode 解答篇](tutorial04_answer/tutorial04_answer.md)(2016/10/6 完成)。
45-
5. 解析数组:JSON array 的语法。练习完成 JSON array 类型的解析、相关内存释放。
45+
5. [解析数组](tutorial05/tutorial05.md)(2016/10/7 完成):JSON array 的语法。练习完成 JSON array 类型的解析、相关内存释放。
4646
6. 解析对象:JSON object 的语法、重构 string 解析函数。练习完成 JSON object 的解析、相关内存释放。
4747
7. 生成器:JSON 生成过程、注意事项。练习完成 JSON 生成器。
4848
8. 访问:JSON array/object 的访问及修改。练习完成相关功能。

tutorial05/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required (VERSION 2.6)
2+
project (leptjson_test C)
3+
4+
if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
5+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -pedantic -Wall")
6+
endif()
7+
8+
add_library(leptjson leptjson.c)
9+
add_executable(leptjson_test test.c)
10+
target_link_libraries(leptjson_test leptjson)

tutorial05/images/makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%.png: %.dot
2+
dot $< -Tpng -o $@
3+
4+
DOTFILES = $(basename $(wildcard *.dot))
5+
all: $(addsuffix .png, $(DOTFILES))
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
digraph {
2+
rankdir=TB
3+
compound=true
4+
fontname="Inconsolata, Consolas"
5+
fontsize=10
6+
margin="0,0"
7+
ranksep=0.3
8+
nodesep=1
9+
penwidth=0.5
10+
11+
node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5, colorscheme=spectral7]
12+
edge [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5]
13+
14+
{
15+
node [shape=record, style=filled, margin=0.1, height=0.3]
16+
json [fillcolor=3, label="<j>[|\"|a|b|c|\"|,|[|1|,|2|]|,|3|]|\\0"]
17+
stack [fillcolor=4, label="<t> | | | | | |"]
18+
}
19+
{
20+
node [shape=plaintext, margin=0]
21+
22+
cjson [label="c->json"]
23+
ctop [label="c->top"]
24+
desc [style=solid,label="\l1. lept_parse()\l 2. lept_parse_value() \l 3. lept_parse_array()"]
25+
}
26+
27+
cjson -> json:j
28+
ctop -> stack:t
29+
json -> desc [style=invis]
30+
}
13.7 KB
Loading
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
digraph {
2+
rankdir=TB
3+
compound=true
4+
fontname="Inconsolata, Consolas"
5+
fontsize=10
6+
margin="0,0"
7+
ranksep=0.3
8+
nodesep=1
9+
penwidth=0.5
10+
11+
node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5, colorscheme=spectral7]
12+
edge [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5]
13+
14+
{
15+
node [shape=record, style=filled, margin=0.1, height=0.3]
16+
json [fillcolor=3, label="[|<j>\"|a|b|c|\"|,|[|1|,|2|]|,|3|]|\\0"]
17+
stack [fillcolor=4, label="<t>| | | | | |"]
18+
}
19+
{
20+
node [shape=plaintext, margin=0]
21+
22+
cjson [label="c->json"]
23+
ctop [label="c->top"]
24+
desc [style=solid,label="\l1. lept_parse()\l 2. lept_parse_value()\l 3. lept_parse_array()\l 4. lept_parse_value()\l 5. lept_parse_string()"]
25+
}
26+
{
27+
node [shape=Mrecord,style=filled]
28+
29+
e [fillcolor=5,label="{null|}"]
30+
}
31+
32+
cjson -> json:j
33+
ctop -> stack:t
34+
json -> desc [style=invis]
35+
stack -> e [style=invis]
36+
}
19.7 KB
Loading
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
digraph {
2+
rankdir=TB
3+
compound=true
4+
fontname="Inconsolata, Consolas"
5+
fontsize=10
6+
margin="0,0"
7+
ranksep=0.3
8+
nodesep=1
9+
penwidth=0.5
10+
11+
node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5, colorscheme=spectral7]
12+
edge [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5]
13+
14+
{
15+
node [shape=record, style=filled, margin=0.1, height=0.3]
16+
json [fillcolor=3, label="[|\"|a|b|c|<j>\"|,|[|1|,|2|]|,|3|]|\\0"]
17+
stack [fillcolor=4, label="a|b|c|<t>| | |"]
18+
}
19+
{
20+
node [shape=plaintext, margin=0]
21+
22+
cjson [label="c->json"]
23+
ctop [label="c->top"]
24+
desc [style=solid,label="\l1. lept_parse()\l 2. lept_parse_value()\l 3. lept_parse_array()\l 4. lept_parse_value()\l 5. lept_parse_string()"]
25+
}
26+
27+
{
28+
node [shape=Mrecord,style=filled]
29+
30+
e [fillcolor=5,label="{null|}"]
31+
}
32+
33+
cjson -> json:j
34+
ctop -> stack:t
35+
json -> desc [style=invis]
36+
stack -> e [style=invis]
37+
}
20.6 KB
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
digraph {
2+
rankdir=TB
3+
compound=true
4+
fontname="Inconsolata, Consolas"
5+
fontsize=10
6+
margin="0,0"
7+
ranksep=0.3
8+
nodesep=1
9+
penwidth=0.5
10+
11+
node [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5, colorscheme=spectral7]
12+
edge [fontname="Inconsolata, Consolas", fontsize=10, penwidth=0.5]
13+
14+
{
15+
node [shape=record, style=filled, margin=0.1, height=0.3]
16+
json [fillcolor=3, label="[|\"|a|b|c|<j>\"|,|[|1|,|2|]|,|3|]|\\0"]
17+
stack [fillcolor=4, label="<t> | | | | | |"]
18+
abc [fillcolor=3, label="<h>a|b|c|\\0"]
19+
}
20+
{
21+
node [shape=plaintext, margin=0]
22+
23+
cjson [label="c->json"]
24+
ctop [label="c->top"]
25+
desc [style=solid,label="\l1. lept_parse()\l 2. lept_parse_value()\l 3. lept_parse_array()\l 4. lept_parse_value()\l 5. lept_parse_string()"]
26+
}
27+
28+
{
29+
node [shape=Mrecord,style=filled]
30+
31+
s [fillcolor=6,label="{string|<s>s|len=3}"]
32+
}
33+
34+
cjson -> json:j
35+
ctop -> stack:t
36+
json -> desc [style=invis]
37+
stack -> s [style=invis]
38+
s:s -> abc:h
39+
}

0 commit comments

Comments
 (0)