2009-11-11 10:39:14 -06:00
|
|
|
/*
|
2018-08-23 18:40:20 +02:00
|
|
|
* JSON Parser
|
2009-11-11 10:39:14 -06:00
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2018-08-23 18:40:20 +02:00
|
|
|
#ifndef JSON_PARSER_INT_H
|
|
|
|
|
#define JSON_PARSER_INT_H
|
|
|
|
|
|
|
|
|
|
#include "qapi/qmp/json-parser.h"
|
2009-11-11 10:39:14 -06:00
|
|
|
|
|
|
|
|
typedef enum json_token_type {
|
2018-08-31 09:58:40 +02:00
|
|
|
JSON_ERROR = 0, /* must be zero, see json_lexer[] */
|
|
|
|
|
/* Gap for lexer states */
|
|
|
|
|
JSON_LCURLY = 100,
|
|
|
|
|
JSON_MIN = JSON_LCURLY,
|
2015-11-25 22:23:26 +01:00
|
|
|
JSON_RCURLY,
|
|
|
|
|
JSON_LSQUARE,
|
|
|
|
|
JSON_RSQUARE,
|
|
|
|
|
JSON_COLON,
|
|
|
|
|
JSON_COMMA,
|
2009-11-11 10:39:14 -06:00
|
|
|
JSON_INTEGER,
|
|
|
|
|
JSON_FLOAT,
|
|
|
|
|
JSON_KEYWORD,
|
|
|
|
|
JSON_STRING,
|
2018-08-23 18:40:04 +02:00
|
|
|
JSON_INTERP,
|
2018-08-23 18:40:12 +02:00
|
|
|
JSON_END_OF_INPUT,
|
2018-08-31 09:58:38 +02:00
|
|
|
JSON_MAX = JSON_END_OF_INPUT
|
2009-11-11 10:39:14 -06:00
|
|
|
} JSONTokenType;
|
|
|
|
|
|
2018-08-23 18:40:20 +02:00
|
|
|
typedef struct JSONToken JSONToken;
|
2009-11-11 10:39:14 -06:00
|
|
|
|
2018-08-23 18:40:20 +02:00
|
|
|
/* json-lexer.c */
|
2018-08-23 18:40:05 +02:00
|
|
|
void json_lexer_init(JSONLexer *lexer, bool enable_interpolation);
|
2018-08-23 18:39:58 +02:00
|
|
|
void json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
|
|
|
|
|
void json_lexer_flush(JSONLexer *lexer);
|
2009-11-11 10:39:14 -06:00
|
|
|
void json_lexer_destroy(JSONLexer *lexer);
|
|
|
|
|
|
2018-08-23 18:40:20 +02:00
|
|
|
/* json-streamer.c */
|
|
|
|
|
void json_message_process_token(JSONLexer *lexer, GString *input,
|
|
|
|
|
JSONTokenType type, int x, int y);
|
|
|
|
|
|
|
|
|
|
/* json-parser.c */
|
|
|
|
|
JSONToken *json_token(JSONTokenType type, int x, int y, GString *tokstr);
|
|
|
|
|
QObject *json_parser_parse(GQueue *tokens, va_list *ap, Error **errp);
|
|
|
|
|
|
2009-11-11 10:39:14 -06:00
|
|
|
#endif
|