This repository was archived by the owner on Feb 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.hpp
More file actions
93 lines (79 loc) · 2.28 KB
/
Copy pathparser.hpp
File metadata and controls
93 lines (79 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
/**
* Copyright (C) 2020 Tristan. All Rights Reserved.
* This file is licensed under the BSD 2-Clause license.
* See the COPYING file for licensing information.
*/
#include <tuple>
#include "parser/css/stylesheet.hpp"
#include "parser/css/tokenizer.hpp"
#ifndef PRIVATE_VISIBILITY
#define PRIVATE_VISIBILITY private
#endif
namespace CSS {
class Parser {
public:
inline explicit Parser(const Tokenizer &tokenizer) : tokenizer(tokenizer) {}
// Parse a stylesheet
//
// [Spec]
// Title: CSS Syntax Module Level 3
// Section: 5.3.2.
// URL: https://www.w3.org/TR/css-syntax-3/#parse-stylesheet
[[nodiscard]] Stylesheet
ParseStylesheet() noexcept;
PRIVATE_VISIBILITY:
const Tokenizer &tokenizer;
bool errorOccurred = false;
bool topLevelFlag = false;
std::vector<Token>::const_iterator it;
std::vector<Token>::const_iterator endIterator;
std::vector<Rule> *rules;
// Consume a list of rules
//
// [Spec]
// Title: CSS Syntax Module Level 3
// Section: 5.4.1
// URL: https://www.w3.org/TR/css-syntax-3/#consume-list-of-rules
void
ConsumeListOfRules() noexcept;
// Consume an at-rule
//
// The bool return type indicates whether the iterator was manually
// modified or not, i.e. if at least one token was consumed.
//
// [Spec]
// Title: CSS Syntax Module Level 3
// Section: 5.4.2
// URL: https://www.w3.org/TR/css-syntax-3/#consume-at-rule
[[nodiscard]] bool
ConsumeAtRule() noexcept;
// Consume a qualified rule
//
// The bool return type indicates whether the iterator was manually
// modified or not, i.e. if at least one token was consumed.
//
// [Spec]
// Title: CSS Syntax Module Level 3
// Section: 5.4.3
// URL: https://www.w3.org/TR/css-syntax-3/#consume-a-qualified-rule
[[nodiscard]] bool
ConsumeQualifiedRule() noexcept;
// Consume a declaration
//
// [Spec]
// Title: CSS Syntax Module Level 3
// Section: 5.4.5.
// URL: https://www.w3.org/TR/css-syntax-3/#consume-declaration
void
ConsumeDeclaration() noexcept;
// Consume a component value
//
// [Spec]
// Title: CSS Syntax Module Level 3
// Section: 5.4.6.
// URL: https://www.w3.org/TR/css-syntax-3/#consume-a-component-value
[[nodiscard]] ComponentValue
ConsumeComponentValue() noexcept;
};
} // namespace CSS