root / json-lexer.h @ ba5e5090
History | View | Annotate | Download (977 Bytes)
1 | 5ab8558d | Anthony Liguori | /*
|
---|---|---|---|
2 | 5ab8558d | Anthony Liguori | * JSON lexer
|
3 | 5ab8558d | Anthony Liguori | *
|
4 | 5ab8558d | Anthony Liguori | * Copyright IBM, Corp. 2009
|
5 | 5ab8558d | Anthony Liguori | *
|
6 | 5ab8558d | Anthony Liguori | * Authors:
|
7 | 5ab8558d | Anthony Liguori | * Anthony Liguori <aliguori@us.ibm.com>
|
8 | 5ab8558d | Anthony Liguori | *
|
9 | 5ab8558d | Anthony Liguori | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
10 | 5ab8558d | Anthony Liguori | * See the COPYING.LIB file in the top-level directory.
|
11 | 5ab8558d | Anthony Liguori | *
|
12 | 5ab8558d | Anthony Liguori | */
|
13 | 5ab8558d | Anthony Liguori | |
14 | 5ab8558d | Anthony Liguori | #ifndef QEMU_JSON_LEXER_H
|
15 | 5ab8558d | Anthony Liguori | #define QEMU_JSON_LEXER_H
|
16 | 5ab8558d | Anthony Liguori | |
17 | 5ab8558d | Anthony Liguori | #include "qstring.h" |
18 | 5ab8558d | Anthony Liguori | #include "qlist.h" |
19 | 5ab8558d | Anthony Liguori | |
20 | 5ab8558d | Anthony Liguori | typedef enum json_token_type { |
21 | 5ab8558d | Anthony Liguori | JSON_OPERATOR = 100,
|
22 | 5ab8558d | Anthony Liguori | JSON_INTEGER, |
23 | 5ab8558d | Anthony Liguori | JSON_FLOAT, |
24 | 5ab8558d | Anthony Liguori | JSON_KEYWORD, |
25 | 5ab8558d | Anthony Liguori | JSON_STRING, |
26 | 5ab8558d | Anthony Liguori | JSON_ESCAPE, |
27 | 5ab8558d | Anthony Liguori | JSON_SKIP, |
28 | 5ab8558d | Anthony Liguori | } JSONTokenType; |
29 | 5ab8558d | Anthony Liguori | |
30 | 5ab8558d | Anthony Liguori | typedef struct JSONLexer JSONLexer; |
31 | 5ab8558d | Anthony Liguori | |
32 | 5ab8558d | Anthony Liguori | typedef void (JSONLexerEmitter)(JSONLexer *, QString *, JSONTokenType, int x, int y); |
33 | 5ab8558d | Anthony Liguori | |
34 | 5ab8558d | Anthony Liguori | struct JSONLexer
|
35 | 5ab8558d | Anthony Liguori | { |
36 | 5ab8558d | Anthony Liguori | JSONLexerEmitter *emit; |
37 | 5ab8558d | Anthony Liguori | int state;
|
38 | 5ab8558d | Anthony Liguori | QString *token; |
39 | 5ab8558d | Anthony Liguori | int x, y;
|
40 | 5ab8558d | Anthony Liguori | }; |
41 | 5ab8558d | Anthony Liguori | |
42 | 5ab8558d | Anthony Liguori | void json_lexer_init(JSONLexer *lexer, JSONLexerEmitter func);
|
43 | 5ab8558d | Anthony Liguori | |
44 | 5ab8558d | Anthony Liguori | int json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size); |
45 | 5ab8558d | Anthony Liguori | |
46 | 5ab8558d | Anthony Liguori | int json_lexer_flush(JSONLexer *lexer);
|
47 | 5ab8558d | Anthony Liguori | |
48 | 5ab8558d | Anthony Liguori | void json_lexer_destroy(JSONLexer *lexer);
|
49 | 5ab8558d | Anthony Liguori | |
50 | 5ab8558d | Anthony Liguori | #endif |