summaryrefslogtreecommitdiff
path: root/src/html_token.cpp
blob: 8589ba8e324a41b7ede691569a0d24c2647b9c8e (plain)
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
#include "html_token.hpp"
#include <matte/logger.h>

const char* TOKEN_TO_NAME_MAP[HtmlTokenType_Length] = {
    "Text",
    "Start Tag",
    "End Tag",
    "Attribute",
    "EOF",
    "Character"
};

void HtmlToken::print() {
    const char* name = TOKEN_TO_NAME_MAP[type];
    switch (type) {
    case HtmlTokenType_Character:
        logger_info("%s, %c", name, character_token);
        break;
    case HtmlTokenType_StartTag:
    case HtmlTokenType_EndTag:
        logger_info("%s, %s", name, tag_name.c_str());
        break;
    default:
        logger_info("%s", name);
    }
}

void HtmlToken::reset() {
    type = HtmlTokenType_None;
    tag_name.clear();
    code_entity.clear();
}