2009-11-12 00:39:14 +08:00
|
|
|
/*
|
|
|
|
* JSON lexer
|
|
|
|
*
|
|
|
|
* Copyright IBM, Corp. 2009
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anthony Liguori <aliguori@us.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
|
|
|
|
* See the COPYING.LIB file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QEMU_JSON_LEXER_H
|
|
|
|
#define QEMU_JSON_LEXER_H
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum json_token_type {
|
2015-11-26 05:23:25 +08:00
|
|
|
JSON_MIN = 100,
|
2015-11-26 05:23:26 +08:00
|
|
|
JSON_LCURLY = JSON_MIN,
|
|
|
|
JSON_RCURLY,
|
|
|
|
JSON_LSQUARE,
|
|
|
|
JSON_RSQUARE,
|
|
|
|
JSON_COLON,
|
|
|
|
JSON_COMMA,
|
2009-11-12 00:39:14 +08:00
|
|
|
JSON_INTEGER,
|
|
|
|
JSON_FLOAT,
|
|
|
|
JSON_KEYWORD,
|
|
|
|
JSON_STRING,
|
2018-08-24 00:40:04 +08:00
|
|
|
JSON_INTERP,
|
2009-11-12 00:39:14 +08:00
|
|
|
JSON_SKIP,
|
2011-06-02 01:14:58 +08:00
|
|
|
JSON_ERROR,
|
2018-08-24 00:40:12 +08:00
|
|
|
JSON_END_OF_INPUT,
|
2009-11-12 00:39:14 +08:00
|
|
|
} JSONTokenType;
|
|
|
|
|
2018-08-24 00:40:00 +08:00
|
|
|
typedef struct JSONLexer {
|
2018-08-24 00:40:05 +08:00
|
|
|
int start_state, state;
|
2015-11-26 05:23:29 +08:00
|
|
|
GString *token;
|
2009-11-12 00:39:14 +08:00
|
|
|
int x, y;
|
2018-08-24 00:40:00 +08:00
|
|
|
} JSONLexer;
|
2009-11-12 00:39:14 +08:00
|
|
|
|
2018-08-24 00:40:05 +08:00
|
|
|
void json_lexer_init(JSONLexer *lexer, bool enable_interpolation);
|
2009-11-12 00:39:14 +08:00
|
|
|
|
2018-08-24 00:39:58 +08:00
|
|
|
void json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
|
2009-11-12 00:39:14 +08:00
|
|
|
|
2018-08-24 00:39:58 +08:00
|
|
|
void json_lexer_flush(JSONLexer *lexer);
|
2009-11-12 00:39:14 +08:00
|
|
|
|
|
|
|
void json_lexer_destroy(JSONLexer *lexer);
|
|
|
|
|
|
|
|
#endif
|