qjson: Spell out some silent assumptions
[qemu/ar7.git] / include / qapi / qmp / json-lexer.h
blob61a143f5bf210b75588a8052402deb474e4d36f0
1 /*
2 * JSON lexer
4 * Copyright IBM, Corp. 2009
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
14 #ifndef QEMU_JSON_LEXER_H
15 #define QEMU_JSON_LEXER_H
17 #include "qapi/qmp/qstring.h"
18 #include "qapi/qmp/qlist.h"
20 typedef enum json_token_type {
21 JSON_MIN = 100,
22 JSON_OPERATOR = JSON_MIN,
23 JSON_INTEGER,
24 JSON_FLOAT,
25 JSON_KEYWORD,
26 JSON_STRING,
27 JSON_ESCAPE,
28 JSON_SKIP,
29 JSON_ERROR,
30 } JSONTokenType;
32 typedef struct JSONLexer JSONLexer;
34 typedef void (JSONLexerEmitter)(JSONLexer *, QString *, JSONTokenType, int x, int y);
36 struct JSONLexer
38 JSONLexerEmitter *emit;
39 int state;
40 QString *token;
41 int x, y;
44 void json_lexer_init(JSONLexer *lexer, JSONLexerEmitter func);
46 int json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
48 int json_lexer_flush(JSONLexer *lexer);
50 void json_lexer_destroy(JSONLexer *lexer);
52 #endif