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 pathmarkup_declaration_open.cpp
More file actions
45 lines (38 loc) · 1.48 KB
/
Copy pathmarkup_declaration_open.cpp
File metadata and controls
45 lines (38 loc) · 1.48 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
/**
* 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 "markup_declaration_open.hpp"
#include <iostream>
#include <vector>
bool
HTML::Tokenizer::MarkupDeclarationOpen::Parse() {
if (!context.eof) {
if (context.i + 1 < context.documentSize && context.character == Unicode::HYPHEN_MINUS
&& context.document->data[context.i + 1] == Unicode::HYPHEN_MINUS) {
context.toConsumeNext = 1;
context.commentToken = HTML::Tokenizer::CommentToken(Unicode::UString(""));
context.state = HTML::Tokenizer::ParserState::COMMENT_START;
return true;
}
if (context.i + 6 < context.documentSize) {
if (context.document->data.StartsWithIgnoreCaseAL(context.i, "DOCTYPE", 7)) {
context.toConsumeNext = 6;
context.state = HTML::Tokenizer::ParserState::DOCTYPE;
return true;
}
if (context.character == Unicode::LEFT_SQUARE_BRACKET
&& context.document->data.EqualsAL(context.i + 1, "CDATA", 5) // Case-sensitive!
&& context.document->data[context.i + 6] == Unicode::RIGHT_SQUARE_BRACKET) {
// TODO ?
throw std::runtime_error("TODO in MARKUP_DECLARATION_OPEN / CDATA");
}
}
}
context.LogError(HTML::Tokenizer::ParserError::INCORRECTLY_OPENED_COMMENT);
context.commentToken = HTML::Tokenizer::CommentToken(Unicode::UString(""));
context.i--; // Don't consume anything
context.state = HTML::Tokenizer::ParserState::BOGUS_COMMENT;
return true;
}