1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef QEMU_JSON_LEXER_H
15#define QEMU_JSON_LEXER_H
16
17#include "qstring.h"
18#include "qlist.h"
19
20typedef enum json_token_type {
21 JSON_OPERATOR = 100,
22 JSON_INTEGER,
23 JSON_FLOAT,
24 JSON_KEYWORD,
25 JSON_STRING,
26 JSON_ESCAPE,
27 JSON_SKIP,
28 JSON_ERROR,
29} JSONTokenType;
30
31typedef struct JSONLexer JSONLexer;
32
33typedef void (JSONLexerEmitter)(JSONLexer *, QString *, JSONTokenType, int x, int y);
34
35struct JSONLexer
36{
37 JSONLexerEmitter *emit;
38 int state;
39 QString *token;
40 int x, y;
41};
42
43void json_lexer_init(JSONLexer *lexer, JSONLexerEmitter func);
44
45int json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
46
47int json_lexer_flush(JSONLexer *lexer);
48
49void json_lexer_destroy(JSONLexer *lexer);
50
51#endif
52