Webserv
Loading...
Searching...
No Matches
Token.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <ostream>
5
6namespace config {
7
23
28typedef struct Token {
29 std::string literal;
31
38 bool isTypeIn(TokenType const arr[], size_t size) const;
40
41std::ostream &operator<<(std::ostream &o, Token const &t);
42std::ostream &operator<<(std::ostream &o, TokenType const t);
43
44} // namespace config
Definition ConfigException.hpp:6
struct config::Token Token
std::ostream & operator<<(std::ostream &o, Token const &t)
Definition Token.cpp:29
TokenType
Represents the type of a lexical token.
Definition Token.hpp:12
@ LEFT_BRACE
The '{' character.
Definition Token.hpp:17
@ STRING
A quoted string literal, e.g., "hello world".
Definition Token.hpp:14
@ IDENTIFIER
A keyword or variable name, e.g., "server_name".
Definition Token.hpp:13
@ UNKNOWN
A token that could not be identified.
Definition Token.hpp:20
@ ENDPOINT
A special token type, perhaps for future use.
Definition Token.hpp:16
@ NUMBER
A numeric literal, e.g., 8080.
Definition Token.hpp:15
@ SEMICOLON
The ';' character.
Definition Token.hpp:19
@ RIGHT_BRACE
The '}' character.
Definition Token.hpp:18
@ END_OF_FILE
A special token representing the end of the input.
Definition Token.hpp:21
Represents a single lexical token with a type and a literal value.
Definition Token.hpp:28
TokenType type
Definition Token.hpp:30
bool isTypeIn(TokenType const arr[], size_t size) const
Checks if the token's type is present in a given array of types.
Definition Token.cpp:34
std::string literal
Definition Token.hpp:29