Skip to content

Commit e9613be

Browse files
committed
fix
1 parent 1cfe603 commit e9613be

File tree

3 files changed

+61
-10
lines changed

3 files changed

+61
-10
lines changed

interpreter/main.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,59 @@ int main(int argc, char* argv[])
7777

7878
return 1;
7979
}
80+
81+
// #include <algorithm>
82+
// #include <cmath>
83+
// #include <cstdint>
84+
// #include <iostream>
85+
// #include <set>
86+
87+
// uint64_t hamber(uint64_t n)
88+
// {
89+
// std::set<uint64_t> numbers;
90+
91+
// uint64_t prevThresh = 0;
92+
// uint64_t threshold = 3;
93+
// uint64_t x = 0;
94+
// uint64_t y = 0;
95+
// uint64_t z = 0;
96+
97+
// uint64_t result = 0;
98+
// while (numbers.size() < n) {
99+
// x = prevThresh;
100+
// y = prevThresh;
101+
// z = prevThresh;
102+
// for (; z < threshold; ++z) {
103+
// y = prevThresh;
104+
// x = prevThresh;
105+
// for (; y < threshold; ++y) {
106+
// x = prevThresh;
107+
// for (; x < threshold; ++x) {
108+
// result = pow(2, x) * pow(3, y) * pow(5, z);
109+
// std::cout << x << " " << y << " " << z << " = " << result << std::endl;
110+
// numbers.insert(result);
111+
// }
112+
// }
113+
// }
114+
115+
// x = y = z = threshold;
116+
// prevThresh += 2;
117+
// threshold += 2;
118+
// }
119+
120+
// auto it = numbers.begin();
121+
// for (int i = 0; i < n; ++i) {
122+
// it++;
123+
// }
124+
125+
// it--;
126+
127+
// return *it;
128+
// }
129+
130+
// int main(int, char* argv[])
131+
// {
132+
// uint64_t arg = std::stoi(argv[1]);
133+
// std::cout << hamber(arg) << std::endl;
134+
// return 0;
135+
// }

interpreter/src/Lexer.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
void Lexer::registerBuiltInMethod(const std::string& functionName)
66
{
77
auto [it, res] = _builtInMethods.insert(functionName);
8-
if (res) {
9-
std::cout << "success" << std::endl;
10-
} else {
11-
std::cout << "lypton" << std::endl;
12-
}
138
}
149

1510
void Lexer::advance()

interpreter/src/Parser.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ std::shared_ptr<AstNode> Parser::statement()
190190
} else if (_currentToken.getType() == TokenType::VARIABLE_DECLARATION) {
191191
return variableDeclaration();
192192
} else if (_currentToken.getType() == TokenType::ID) {
193-
if (_lexer.peekNextToken().getType() == TokenType::LPAREN) {
193+
if (std::string value = _currentToken.getStringValue(); value.at(value.size() - 2) == '(' && value.at(value.size() - 1) == ')') {
194194
return functionCall();
195195
} else {
196196
return assignmentStatement();
@@ -301,8 +301,8 @@ std::shared_ptr<AstNode> Parser::functionDeclaration()
301301
eat(TokenType::FUN_DECLARATION);
302302
std::string functionName = _currentToken.getStringValue();
303303
eat(TokenType::ID);
304-
eat(TokenType::LPAREN);
305-
eat(TokenType::RPAREN);
304+
// eat(TokenType::LPAREN);
305+
// eat(TokenType::RPAREN);
306306
eat(TokenType::COLON);
307307
eat(TokenType::START);
308308

@@ -320,8 +320,8 @@ std::shared_ptr<AstNode> Parser::functionCall()
320320
{
321321
const std::string functionName = _currentToken.getStringValue();
322322
eat(TokenType::ID);
323-
eat(TokenType::LPAREN);
324-
eat(TokenType::RPAREN);
323+
// eat(TokenType::LPAREN);
324+
// eat(TokenType::RPAREN);
325325

326326
return std::make_shared<FunCall>(functionName);
327327
}

0 commit comments

Comments
 (0)