| 1 | /* |
| 2 | * JSON Parser |
| 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 | |
| 14 | #ifndef JSON_PARSER_INT_H |
| 15 | #define JSON_PARSER_INT_H |
| 16 | |
| 17 | #include "qobject/json-parser.h" |
| 18 | |
| 19 | typedef enum json_token_type { |
| 20 | JSON_ERROR = 0, /* must be zero, see json_lexer[] */ |
| 21 | /* Gap for lexer states */ |
| 22 | JSON_LCURLY = 100, |
| 23 | JSON_MIN = JSON_LCURLY, |
| 24 | JSON_RCURLY, |
| 25 | JSON_LSQUARE, |
| 26 | JSON_RSQUARE, |
| 27 | JSON_COLON, |
| 28 | JSON_COMMA, |
| 29 | JSON_INTEGER, |
| 30 | JSON_FLOAT, |
| 31 | JSON_KEYWORD, |
| 32 | JSON_STRING, |
| 33 | JSON_INTERP, |
| 34 | JSON_END_OF_INPUT, |
| 35 | JSON_MAX = JSON_END_OF_INPUT |
| 36 | } JSONTokenType; |
| 37 | |
| 38 | typedef struct JSONToken { |
| 39 | JSONTokenType type; |
| 40 | int x; |
| 41 | int y; |
| 42 | char *str; |
| 43 | } JSONToken; |
| 44 | |
| 45 | /* json-lexer.c */ |
| 46 | void json_lexer_init(JSONLexer *lexer, bool enable_interpolation); |
| 47 | void json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size); |
| 48 | void json_lexer_flush(JSONLexer *lexer); |
| 49 | void json_lexer_destroy(JSONLexer *lexer); |
| 50 | |
| 51 | /* json-streamer.c */ |
| 52 | void json_message_process_token(JSONLexer *lexer, GString *input, |
| 53 | JSONTokenType type, int x, int y); |
| 54 | |
| 55 | /* json-parser.c */ |
| 56 | void json_parser_init(JSONParserContext *ctxt, va_list *ap); |
| 57 | void json_parser_reset(JSONParserContext *ctxt); |
| 58 | QObject *json_parser_feed(JSONParserContext *ctxt, const JSONToken *token, Error **errp); |
| 59 | void json_parser_destroy(JSONParserContext *ctxt); |
| 60 | |
| 61 | #endif |