refactor(furc): rename some token types to PascalCase

This commit is contained in:
2026-06-01 17:37:36 +02:00
parent 0958389b90
commit 6ffe1cefbe
4 changed files with 50 additions and 50 deletions
+6 -6
View File
@@ -106,12 +106,12 @@ token_handle<> lexer::next_token() {
};
static std::map<std::string_view, token_t, compare> s_tokens = {
{ "(", token_t::Lparen },
{ ")", token_t::Rparen },
{ "{", token_t::Lbrace },
{ "}", token_t::Rbrace },
{ "[", token_t::Lbracket },
{ "]", token_t::Rbracket },
{ "(", token_t::LParen },
{ ")", token_t::RParen },
{ "{", token_t::LBrace },
{ "}", token_t::RBrace },
{ "[", token_t::LBracket },
{ "]", token_t::RBracket },
{ ";", token_t::Semicolon },
{ ":", token_t::Colon },
{ ",", token_t::Comma },
+17 -17
View File
@@ -46,15 +46,15 @@ ast::declaration_node_h parser::parse_declaration() {
token_handle<> name = eat_token(token_t::Identifier);
if (name.has_error()) return { name.location(), name.error() };
auto tok = eat_token(token_t::Lparen);
auto tok = eat_token(token_t::LParen);
if (tok.has_error()) return tok;
tok = eat_token(token_t::Rparen);
tok = eat_token(token_t::RParen);
if (tok.has_error()) return tok;
const auto& peek = peek_token();
if (peek.has_error()) return peek;
switch (peek->type) {
case token_t::Lbrace: {
case token_t::LBrace: {
ast::body_h body = parse_body();
if (body.has_error()) return body;
return ast::function_definition_node_h{ first.location(), m_arena, *name, std::move(body) };
@@ -72,12 +72,12 @@ ast::declaration_node_h parser::parse_declaration() {
case token_t::None:
case token_t::Identifier:
case token_t::Integer:
case token_t::Lparen:
case token_t::Rparen:
case token_t::Lbrace:
case token_t::Rbrace:
case token_t::Lbracket:
case token_t::Rbracket:
case token_t::LParen:
case token_t::RParen:
case token_t::LBrace:
case token_t::RBrace:
case token_t::LBracket:
case token_t::RBracket:
case token_t::Semicolon:
case token_t::Colon:
default: {
@@ -107,12 +107,12 @@ ast::statement_node_h parser::parse_statement() {
}
case keyword_token::If: {
auto tok = next_token();
auto err = eat_token(token_t::Lparen);
auto err = eat_token(token_t::LParen);
if (err.has_error()) return err;
auto cond = parse_expression();
err = eat_token(token_t::Rparen);
err = eat_token(token_t::RParen);
if (err.has_error()) return err;
auto then = parse_statement();
@@ -136,7 +136,7 @@ ast::statement_node_h parser::parse_statement() {
default: break;
}
}
case token_t::Lbrace: return ast::compound_statement_node_h{ location, m_arena, parse_body() };
case token_t::LBrace: return ast::compound_statement_node_h{ location, m_arena, parse_body() };
default: break;
}
@@ -187,10 +187,10 @@ ast::expression_node_h parser::parse_expression_primary() {
m_arena,
handle<std::string_view>{ tok.location(), (*tok)->string } };
}
case token_t::Lparen: {
case token_t::LParen: {
auto tok = next_token();
auto node = parse_expression();
auto err = eat_token(token_t::Rparen);
auto err = eat_token(token_t::RParen);
if (err.has_error()) return err;
return node;
}
@@ -366,15 +366,15 @@ ast::expression_node_h parser::parse_expression_rhs(ast::expression_node_h&& ini
ast::body_h parser::parse_body() {
ast::body body;
token_handle<> begin = eat_token(token_t::Lbrace);
token_handle<> begin = eat_token(token_t::LBrace);
if (begin.has_error()) return begin;
body.begin = begin.location();
while (!peek_token().has_error() && peek_token()->type != token_t::None && peek_token()->type != token_t::Rbrace) {
while (!peek_token().has_error() && peek_token()->type != token_t::None && peek_token()->type != token_t::RBrace) {
body.statements.push_back(parse_statement());
}
token_handle<> end = eat_token(token_t::Rbrace);
token_handle<> end = eat_token(token_t::RBrace);
if (end.has_error()) return end;
body.end = end.location();