diff --git a/Lexer/inc/Token.h b/Lexer/inc/Token.h index 38dba29..dfd3073 100644 --- a/Lexer/inc/Token.h +++ b/Lexer/inc/Token.h @@ -65,6 +65,7 @@ namespace LXC::Lexer // === Symbols === // Assign = TokenClass::Symbols, + Colon, CloseBracket, OpenBracket, diff --git a/Lexer/src/Lexer.cpp b/Lexer/src/Lexer.cpp index a7e4043..c634f39 100644 --- a/Lexer/src/Lexer.cpp +++ b/Lexer/src/Lexer.cpp @@ -35,7 +35,7 @@ namespace LXC::Internal c == ']' || c == '{' || c == '}' || c == '(' || c == ')' || c == '<' || - c == '>'; + c == '>' || c == ':'; } static const std::unordered_map operatorMap = @@ -54,6 +54,7 @@ namespace LXC::Internal static const std::unordered_map symbolMap = { { ',', Lexer::Token::Comma }, + { ':', Lexer::Token::Colon }, { '[', Lexer::Token::CloseBracket }, { ']', Lexer::Token::OpenBracket }, diff --git a/Lexer/src/Token.cpp b/Lexer/src/Token.cpp index 7296c9c..48797a3 100644 --- a/Lexer/src/Token.cpp +++ b/Lexer/src/Token.cpp @@ -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); diff --git a/examples/Fib.lx b/examples/Fib.lx index afc334e..59d1c9a 100644 --- a/examples/Fib.lx +++ b/examples/Fib.lx @@ -1,8 +1,8 @@ -func fib(int num) +func 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 fib(int num) func main() { - int res = fib(8) + int: res = fib(8) return res == 21 } diff --git a/examples/LawsOfMath.lx b/examples/LawsOfMath.lx index f25be8d..f8a0c8c 100644 --- a/examples/LawsOfMath.lx +++ b/examples/LawsOfMath.lx @@ -1,11 +1,11 @@ -func add(int a, int b) +func add(int: a, int: b) { return a + b } func main() { - int c = add(3, 4) + int: c = add(3, 4) if (c == 7) { return 0