]> pd.if.org Git - json/blob - scan.h
initial commit
[json] / scan.h
1 #include <ctype.h>
2 #include <string.h>
3
4 #include <stdlib.h>
5
6 #include "json.h"
7
8 #define PSTRING (-1)
9 #define PNUMBER (-2)
10 #define PTRUE (-3)
11 #define PFALSE (-4)
12 #define PNULL (-5)
13
14 #define NUMERROR 1
15 #define TOKENERROR 2
16 struct scanner {
17         void *(*allocate)(size_t s);
18         void *(*reallocate)(void *p, size_t s);
19         void (*free)(void *p);
20 };
21
22 #define NEED_MORE 0
23
24 int scanner_init(struct scanner *s);
25
26 struct token {
27         int len;
28         char ch;
29         int type;
30         int maybe;
31         int error;
32         int state;
33         unsigned int unicode;
34         char str[1024];
35 };
36
37 /* returns a pointer to the last unused character */
38 /* fills in t.
39  */
40 int scan_json_ch(int input, struct token *t);