Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 1 | /* |
Markus Armbruster | 86cdf9e | 2018-08-23 18:40:20 +0200 | [diff] [blame] | 2 | * JSON Parser |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 3 | * |
| 4 | * Copyright IBM, Corp. 2009 |
| 5 | * |
| 6 | * Authors: |
| 7 | * Anthony Liguori <aliguori@us.ibm.com> |
| 8 | * |
| 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. |
| 11 | * |
| 12 | */ |
| 13 | |
Markus Armbruster | 86cdf9e | 2018-08-23 18:40:20 +0200 | [diff] [blame] | 14 | #ifndef JSON_PARSER_INT_H |
| 15 | #define JSON_PARSER_INT_H |
| 16 | |
| 17 | #include "qapi/qmp/json-parser.h" |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 18 | |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 19 | |
| 20 | typedef enum json_token_type { |
Markus Armbruster | b8d3b1d | 2015-11-25 22:23:25 +0100 | [diff] [blame] | 21 | JSON_MIN = 100, |
Markus Armbruster | c546166 | 2015-11-25 22:23:26 +0100 | [diff] [blame] | 22 | JSON_LCURLY = JSON_MIN, |
| 23 | JSON_RCURLY, |
| 24 | JSON_LSQUARE, |
| 25 | JSON_RSQUARE, |
| 26 | JSON_COLON, |
| 27 | JSON_COMMA, |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 28 | JSON_INTEGER, |
| 29 | JSON_FLOAT, |
| 30 | JSON_KEYWORD, |
| 31 | JSON_STRING, |
Markus Armbruster | 6103028 | 2018-08-23 18:40:04 +0200 | [diff] [blame] | 32 | JSON_INTERP, |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 33 | JSON_SKIP, |
Michael Roth | b011f61 | 2011-06-01 12:14:58 -0500 | [diff] [blame] | 34 | JSON_ERROR, |
Markus Armbruster | f927791 | 2018-08-23 18:40:12 +0200 | [diff] [blame] | 35 | JSON_END_OF_INPUT, |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 36 | } JSONTokenType; |
| 37 | |
Markus Armbruster | 86cdf9e | 2018-08-23 18:40:20 +0200 | [diff] [blame] | 38 | typedef struct JSONToken JSONToken; |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 39 | |
Markus Armbruster | 86cdf9e | 2018-08-23 18:40:20 +0200 | [diff] [blame] | 40 | /* json-lexer.c */ |
Markus Armbruster | 2cbd15a | 2018-08-23 18:40:05 +0200 | [diff] [blame] | 41 | void json_lexer_init(JSONLexer *lexer, bool enable_interpolation); |
Marc-André Lureau | 7c1e1d5 | 2018-08-23 18:39:58 +0200 | [diff] [blame] | 42 | void json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size); |
Marc-André Lureau | 7c1e1d5 | 2018-08-23 18:39:58 +0200 | [diff] [blame] | 43 | void json_lexer_flush(JSONLexer *lexer); |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 44 | void json_lexer_destroy(JSONLexer *lexer); |
| 45 | |
Markus Armbruster | 86cdf9e | 2018-08-23 18:40:20 +0200 | [diff] [blame] | 46 | /* json-streamer.c */ |
| 47 | void json_message_process_token(JSONLexer *lexer, GString *input, |
| 48 | JSONTokenType type, int x, int y); |
| 49 | |
| 50 | /* json-parser.c */ |
| 51 | JSONToken *json_token(JSONTokenType type, int x, int y, GString *tokstr); |
| 52 | QObject *json_parser_parse(GQueue *tokens, va_list *ap, Error **errp); |
| 53 | |
Anthony Liguori | 5ab8558 | 2009-11-11 10:39:14 -0600 | [diff] [blame] | 54 | #endif |