Changed how variables are created

This commit is contained in:
Pasha Bibko
2025-08-04 15:46:19 +01:00
parent a77d5bd129
commit 7e95b7157e
5 changed files with 11 additions and 8 deletions

View File

@@ -65,6 +65,7 @@ namespace LXC::Lexer
// === Symbols === //
Assign = TokenClass::Symbols,
Colon,
CloseBracket,
OpenBracket,

View File

@@ -35,7 +35,7 @@ namespace LXC::Internal
c == ']' || c == '{' ||
c == '}' || c == '(' ||
c == ')' || c == '<' ||
c == '>';
c == '>' || c == ':';
}
static const std::unordered_map<std::string_view, Lexer::Token::TokenType> operatorMap =
@@ -54,6 +54,7 @@ namespace LXC::Internal
static const std::unordered_map<char, Lexer::Token::TokenType> symbolMap =
{
{ ',', Lexer::Token::Comma },
{ ':', Lexer::Token::Colon },
{ '[', Lexer::Token::CloseBracket },
{ ']', Lexer::Token::OpenBracket },

View File

@@ -82,6 +82,7 @@ namespace LXC::Lexer
TOKEN_TYPE_CASE(Token::Identifier);
TOKEN_TYPE_CASE(Token::Assign);
TOKEN_TYPE_CASE(Token::Colon);
TOKEN_TYPE_CASE(Token::CloseBracket);
TOKEN_TYPE_CASE(Token::OpenBracket);
TOKEN_TYPE_CASE(Token::CloseBrace);

View File

@@ -1,8 +1,8 @@
func<int> fib(int num)
func<int> fib(int: num)
{
# Base cases #
if (n == 0) { return 0 }
if (n == 1) { return 1 }
# Base cases (temp excluded) #
# if (n == 0) { return 0 } #
# if (n == 1) { return 1 } #
# RECURSION BABYYYY #
return fib(n - 1) + fib(n - 2)
@@ -10,6 +10,6 @@ func<int> fib(int num)
func<int> main()
{
int res = fib(8)
int: res = fib(8)
return res == 21
}

View File

@@ -1,11 +1,11 @@
func<int> add(int a, int b)
func<int> add(int: a, int: b)
{
return a + b
}
func<int> main()
{
int c = add(3, 4)
int: c = add(3, 4)
if (c == 7)
{
return 0