parser.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2010 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //
  15. // Author: [email protected] (Jonathan Tang)
  16. //
  17. // Contains the definition of the top-level GumboParser structure that's
  18. // threaded through basically every internal function in the library.
  19. #ifndef GUMBO_PARSER_H_
  20. #define GUMBO_PARSER_H_
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. struct GumboInternalParserState;
  25. struct GumboInternalOutput;
  26. struct GumboInternalOptions;
  27. struct GumboInternalTokenizerState;
  28. // An overarching struct that's threaded through (nearly) all functions in the
  29. // library, OOP-style. This gives each function access to the options and
  30. // output, along with any internal state needed for the parse.
  31. typedef struct GumboInternalParser {
  32. // Settings for this parse run.
  33. const struct GumboInternalOptions* _options;
  34. // Output for the parse.
  35. struct GumboInternalOutput* _output;
  36. // The internal tokenizer state, defined as a pointer to avoid a cyclic
  37. // dependency on html5tokenizer.h. The main parse routine is responsible for
  38. // initializing this on parse start, and destroying it on parse end.
  39. // End-users will never see a non-garbage value in this pointer.
  40. struct GumboInternalTokenizerState* _tokenizer_state;
  41. // The internal parser state. Initialized on parse start and destroyed on
  42. // parse end; end-users will never see a non-garbage value in this pointer.
  43. struct GumboInternalParserState* _parser_state;
  44. } GumboParser;
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif // GUMBO_PARSER_H_