diff options
| author | _ov4 <hausemasterstream@gmail.com> | 2026-01-30 13:28:45 +0000 |
|---|---|---|
| committer | _ov4 <hausemasterstream@gmail.com> | 2026-01-30 13:28:45 +0000 |
| commit | 93175ba5edb0eacc182f573c4fd4556f089da305 (patch) | |
| tree | 0e50d5e0b50d7298dcb50342583fe4b718ccd1c0 /lib/Parser | |
| parent | bd799e42b40613983c6e3cb9aedf58866ac68605 (diff) | |
Added BYREF and BYVAL
Diffstat (limited to 'lib/Parser')
| -rw-r--r-- | lib/Parser/ParserFunction.cc (renamed from lib/Parser/Parser_Function.cc) | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/Parser/Parser_Function.cc b/lib/Parser/ParserFunction.cc index bdb4ee7..d689aa6 100644 --- a/lib/Parser/Parser_Function.cc +++ b/lib/Parser/ParserFunction.cc @@ -1,16 +1,26 @@ #include "cps/Parser.h" #include "cps/FunctionAST.h" +#include <tuple> using namespace cps; -std::vector<std::pair<std::string, std::string>> Parser::ParsePrototypeArgs() { - std::vector<std::pair<std::string, std::string>> Args; +std::vector<std::tuple<std::string, std::string, bool>> Parser::ParsePrototypeArgs() { + std::vector<std::tuple<std::string, std::string, bool>> Args; if (CurTok != '(') return Args; getNextToken(); while (CurTok != ')') { if (CurTok == -1000 || CurTok == -1001) getNextToken(); + bool IsRef = false; + if (CurTok == tok_byref) { + IsRef = true; + getNextToken(); + } else if (CurTok == tok_byval) { + IsRef = false; + getNextToken(); + } + if (CurTok != tok_identifier) { fprintf(stderr, "Error: Expected argument name\n"); return Args; @@ -35,7 +45,7 @@ std::vector<std::pair<std::string, std::string>> Parser::ParsePrototypeArgs() { return Args; } - Args.push_back({Name, Type}); + Args.emplace_back(Name, Type, IsRef); if (CurTok == ')') break; if (CurTok != ',') { |
