Cogs.Core
parser.h
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: jdtang@google.com (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
20#ifndef GUMBO_PARSER_H_
21#define GUMBO_PARSER_H_
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27struct GumboInternalParserState;
30struct GumboInternalTokenizerState;
31
32// An overarching struct that's threaded through (nearly) all functions in the
33// library, OOP-style. This gives each function access to the options and
34// output, along with any internal state needed for the parse.
35typedef struct GumboInternalParser {
36 // Settings for this parse run.
37 const struct GumboInternalOptions* _options;
38
39 // Output for the parse.
40 struct GumboInternalOutput* _output;
41
42 // The internal tokenizer state, defined as a pointer to avoid a cyclic
43 // dependency on html5tokenizer.h. The main parse routine is responsible for
44 // initializing this on parse start, and destroying it on parse end.
45 // End-users will never see a non-garbage value in this pointer.
46 struct GumboInternalTokenizerState* _tokenizer_state;
47
48 // The internal parser state. Initialized on parse start and destroyed on
49 // parse end; end-users will never see a non-garbage value in this pointer.
50 struct GumboInternalParserState* _parser_state;
52
53#ifdef __cplusplus
54}
55#endif
56
57#endif // GUMBO_PARSER_H_