diff options
Diffstat (limited to 'lib/Parser/Parser.cc')
| -rw-r--r-- | lib/Parser/Parser.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Parser/Parser.cc b/lib/Parser/Parser.cc index 77df9bb..e67dda7 100644 --- a/lib/Parser/Parser.cc +++ b/lib/Parser/Parser.cc @@ -59,7 +59,7 @@ std::unique_ptr<ExprAST> Parser::ParseIdentifierExpr() { getNextToken(); auto Args = ParseExprList(')', true); if (!Args) return nullptr; - return std::make_unique<CallExprAST>(IdName, std::move(*Args)); + return std::make_unique<CallExprAST>(IdName, std::move(*Args), Line); } if (CurTok == '[') { @@ -213,6 +213,7 @@ void Parser::syncToStatementStart() { case tok_function: case tok_procedure: case tok_call: case tok_return: case tok_else: case tok_endif: case tok_endwhile: case tok_until: case tok_next: case tok_endfunction: case tok_endprocedure: + case tok_openfile: case tok_readfile: case tok_writefile: case tok_closefile: return; default: getNextToken(); @@ -537,6 +538,18 @@ std::unique_ptr<StmtAST> Parser::ParseStatementImpl() { else if (CurTok == tok_return) { return ParseReturnStmt(); } + else if (CurTok == tok_openfile) { + return ParseOpenFile(); + } + else if (CurTok == tok_readfile) { + return ParseReadFile(); + } + else if (CurTok == tok_writefile) { + return ParseWriteFile(); + } + else if (CurTok == tok_closefile) { + return ParseCloseFile(); + } fprintf(stderr, "Error: Unexpected token at line %d when expecting a statement\n", Lex.getLine()); getNextToken(); // guarantee progress so error recovery cannot loop forever |
