diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-12-20 22:42:59 +1030 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-12-20 22:42:59 +1030 |
commit | 4f0b8d47af36dcd7cc1c41f3314805265250aa95 (patch) | |
tree | cd2f92a2d798f830fd1f374b3219dd7275071b18 /devel | |
parent | 7612cef30d371b12d07f80dde2d4ff7dff1082e5 (diff) | |
download | lua-cjson-4f0b8d47af36dcd7cc1c41f3314805265250aa95.tar.gz lua-cjson-4f0b8d47af36dcd7cc1c41f3314805265250aa95.tar.bz2 lua-cjson-4f0b8d47af36dcd7cc1c41f3314805265250aa95.zip |
Add original JSON parser design outline
Diffstat (limited to 'devel')
-rw-r--r-- | devel/json_parser_outline.txt | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/devel/json_parser_outline.txt b/devel/json_parser_outline.txt new file mode 100644 index 0000000..01db78d --- /dev/null +++ b/devel/json_parser_outline.txt | |||
@@ -0,0 +1,50 @@ | |||
1 | parser: | ||
2 | - call parse_value | ||
3 | - next_token | ||
4 | ? <EOF> nop. | ||
5 | |||
6 | parse_value: | ||
7 | - next_token | ||
8 | ? <OBJ_BEGIN> call parse_object. | ||
9 | ? <ARR_BEGIN> call parse_array. | ||
10 | ? <STRING> push. return. | ||
11 | ? <BOOLEAN> push. return. | ||
12 | ? <NULL> push. return. | ||
13 | ? <NUMBER> push. return. | ||
14 | |||
15 | parse_object: | ||
16 | - push table | ||
17 | - next_token | ||
18 | ? <STRING> push. | ||
19 | - next_token | ||
20 | ? <COLON> nop. | ||
21 | - call parse_value | ||
22 | - set table | ||
23 | - next_token | ||
24 | ? <OBJ_END> return. | ||
25 | ? <COMMA> loop parse_object. | ||
26 | |||
27 | parse_array: | ||
28 | - push table | ||
29 | - call parse_value | ||
30 | - table append | ||
31 | - next_token | ||
32 | ? <COMMA> loop parse_array. | ||
33 | ? ] return. | ||
34 | |||
35 | next_token: | ||
36 | - check next character | ||
37 | ? { return <OBJ_BEGIN> | ||
38 | ? } return <OBJ_END> | ||
39 | ? [ return <ARR_BEGIN> | ||
40 | ? ] return <ARR_END> | ||
41 | ? , return <COMMA> | ||
42 | ? : return <COLON> | ||
43 | ? [-0-9] gobble number. return <NUMBER> | ||
44 | ? " gobble string. return <STRING> | ||
45 | ? [ \t\n] eat whitespace. | ||
46 | ? n Check "null". return <NULL> or <UNKNOWN> | ||
47 | ? t Check "true". return <BOOLEAN> or <UNKNOWN> | ||
48 | ? f Check "false". return <BOOLEAN> or <UNKNOWN> | ||
49 | ? . return <UNKNOWN> | ||
50 | ? \0 return <END> | ||