json-parser-int.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef JSON_PARSER_INT_H
  14. #define JSON_PARSER_INT_H
  15. #include "qobject/json-parser.h"
  16. typedef enum json_token_type {
  17. JSON_ERROR = 0, /* must be zero, see json_lexer[] */
  18. /* Gap for lexer states */
  19. JSON_LCURLY = 100,
  20. JSON_MIN = JSON_LCURLY,
  21. JSON_RCURLY,
  22. JSON_LSQUARE,
  23. JSON_RSQUARE,
  24. JSON_COLON,
  25. JSON_COMMA,
  26. JSON_INTEGER,
  27. JSON_FLOAT,
  28. JSON_KEYWORD,
  29. JSON_STRING,
  30. JSON_INTERP,
  31. JSON_END_OF_INPUT,
  32. JSON_MAX = JSON_END_OF_INPUT
  33. } JSONTokenType;
  34. typedef struct JSONToken JSONToken;
  35. /* json-lexer.c */
  36. void json_lexer_init(JSONLexer *lexer, bool enable_interpolation);
  37. void json_lexer_feed(JSONLexer *lexer, const char *buffer, size_t size);
  38. void json_lexer_flush(JSONLexer *lexer);
  39. void json_lexer_destroy(JSONLexer *lexer);
  40. /* json-streamer.c */
  41. void json_message_process_token(JSONLexer *lexer, GString *input,
  42. JSONTokenType type, int x, int y);
  43. /* json-parser.c */
  44. JSONToken *json_token(JSONTokenType type, int x, int y, GString *tokstr);
  45. QObject *json_parser_parse(GQueue *tokens, va_list *ap, Error **errp);
  46. #endif