json: Fix streamer not to ignore trailing unterminated structures
[qemu.git] / include / qapi / qmp / json-lexer.h
blob508fc7bdafca29ced23f12b7489bde4c41345a75
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
18 typedef enum json_token_type {
19 JSON_MIN = 100,
20 JSON_LCURLY = JSON_MIN,
21 JSON_RCURLY,
22 JSON_LSQUARE,
23 JSON_RSQUARE,
24 JSON_COLON,
25 JSON_COMMA,
26 JSON_INTEGER,
27 JSON_FLOAT,
28 JSON_KEYWORD,
29 JSON_STRING,
30 JSON_INTERP,
31 JSON_SKIP,
32 JSON_ERROR,
33 JSON_END_OF_INPUT,
34 } JSONTokenType;
36 typedef struct JSONLexer {
37 int start_state, state;
38 GString *token;
39 int x, y;
40 } JSONLexer;
42 void json_lexer_init(JSONLexer *lexer, bool enable_interpolation);
44 void json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
46 void json_lexer_flush(JSONLexer *lexer);
48 void json_lexer_destroy(JSONLexer *lexer);
50 #endif