Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/GassaFM/interpr
Browse files Browse the repository at this point in the history
  • Loading branch information
GassaFM committed Mar 21, 2020
2 parents fc1d505 + 739d14e commit f7c4cc2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.dub
*.exe
6 changes: 6 additions & 0 deletions dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name "interpr"
description "Interpreter for Pr, toy programming language for learning parallel algorithms."
authors "Ivan Kazmenko"
homepage "https://github.com/GassaFM/interpr"
license "MIT"
targetType "executable"
8 changes: 7 additions & 1 deletion source/parser.d
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ final class StatementParser
if (!t.empty)
{
line = t.front;
if (line.tokens.front == "else")
if (line.indent == prevIndent &&
line.tokens.front == "else")
{
t.popFront ();
line.tokens.consume ("else", line);
Expand Down Expand Up @@ -556,6 +557,11 @@ final class StatementParser

FunctionBlock parseFunctionBlock (string prevIndent)
{
if (t.empty)
{
enforce (!t.empty, "program is empty");
}

auto line = t.front;
check (line.indent == prevIndent, line,
"indent does not match");
Expand Down
3 changes: 2 additions & 1 deletion source/runner.d
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ class Runner
return 0;
}

assert (false);
throw new Exception ("call of non-existing function: " ~
call.name);
}

long evalExpression (Expression e)
Expand Down

0 comments on commit f7c4cc2

Please sign in to comment.