aboutsummaryrefslogtreecommitdiff
path: root/lib/core/control_flow.nom
diff options
context:
space:
mode:
Diffstat (limited to 'lib/core/control_flow.nom')
-rw-r--r--lib/core/control_flow.nom64
1 files changed, 39 insertions, 25 deletions
diff --git a/lib/core/control_flow.nom b/lib/core/control_flow.nom
index 715630b..c4c1770 100644
--- a/lib/core/control_flow.nom
+++ b/lib/core/control_flow.nom
@@ -328,29 +328,34 @@ test:
$clause = "if"
$else_allowed = (yes)
unless ($body.type is "Block"):
- compile error at $body "'if' expected a Block, but got a \($body.type)."
- "Perhaps you forgot to put a ':' after 'if'?"
+ at $body fail ("
+ Compile error: 'if' expected a Block, but got a \($body.type).
+ Hint: Perhaps you forgot to put a ':' after 'if'?
+ ")
for $line in $body:
unless
(($line.type is "Action") and ((size of $line) >= 2)) and
$line.(size of $line) is "Block" syntax tree
..:
- compile error at $line "Invalid line for the body of an 'if' block." ("
- Each line should contain one or more conditional expressions followed by a block, or "else"\
- .. followed by a block.
+ at $line fail ("
+ Compile error: Invalid line for the body of an 'if' block.
+ Hint: Each line should contain one or more conditional expressions followed \
+ ..by a block, or "else" followed by a block.
")
$action = $line.(size of $line)
if (($line.1 is "else") and ((size of $line) == 2)):
unless $else_allowed:
- compile error at $line "You can't have two 'else' blocks."
- "Merge all of the 'else' blocks together."
+ at $line fail ("
+ Compile error: You can't have two 'else' blocks.
+ Hint: Merge all of the 'else' blocks together.
+ ")
unless ((size of "\$code") > 0):
- compile error at $line
- .."You can't have an 'else' block without a preceding condition" ("
- If you want the code in this block to always execute, you don't need a conditional block \
- ..around it. Otherwise, make sure the 'else' block comes last.
+ at $line fail ("
+ Compile error: You can't have an 'else' block without a preceding condition.
+ Hint: If you want the code in this block to always execute, you don't need a \
+ ..conditional block around it. Otherwise, make sure the 'else' block comes last.
")
$code, add "\nelse\n " ($action as lua)
@@ -365,8 +370,10 @@ test:
$clause = "\nelseif"
if ((size of "\$code") == 0):
- compile error at $body "'if' block has an empty body."
- "This means nothing would happen, so the 'if' block should be deleted."
+ at $body fail ("
+ Compile error: 'if' block has an empty body.
+ Hint: This means nothing would happen, so the 'if' block should be deleted.
+ ")
$code, add "\nend --when"
return $code
@@ -392,28 +399,33 @@ test:
$else_allowed = (yes)
define mangler
unless ($body.type is "Block"):
- compile error at $body "'if' expected a Block, but got a \($body.type)"
- "Perhaps you forgot to put a ':' after the 'is'?"
+ at $body fail ("
+ Compile error: 'if' expected a Block, but got a \($body.type).
+ Hint: Perhaps you forgot to put a ':' after the 'is'?
+ ")
for $line in $body:
unless
(($line.type is "Action") and ((size of $line) >= 2)) and
$line.(size of $line) is "Block" syntax tree
..:
- compile error at $line "Invalid line for 'if' block." ("
- Each line should contain expressions followed by a block, or "else" followed by a block
+ at $line fail ("
+ Compile error: Invalid line for 'if' block.
+ Hint: Each line should contain expressions followed by a block, or "else" followed by a block.
")
$action = $line.(size of $line)
if (($line.1 is "else") and ((size of $line) == 2)):
unless $else_allowed:
- compile error at $line "You can't have two 'else' blocks."
- "Merge all of the 'else' blocks together."
+ at $line fail ("
+ Compile error: You can't have two 'else' blocks.
+ Hint: Merge all of the 'else' blocks together.
+ ")
unless ((size of "\$code") > 0):
- compile error at $line
- .."You can't have an 'else' block without a preceding condition" ("
- If you want the code in this block to always execute, you don't need a conditional block \
- ..around it. Otherwise, make sure the 'else' block comes last.
+ at $line fail ("
+ Compile error: You can't have an 'else' block without a preceding condition.
+ Hint: If you want the code in this block to always execute, you don't need \
+ ..a conditional block around it. Otherwise, make sure the 'else' block comes last.
")
$code, add "\nelse\n " ($action as lua)
@@ -428,8 +440,10 @@ test:
$clause = "\nelseif"
if ((size of "\$code") == 0):
- compile error at $body "'if' block has an empty body."
- "This means nothing would happen, so the 'if' block should be deleted."
+ at $body fail ("
+ Compile error: 'if' block has an empty body.
+ Hint: This means nothing would happen, so the 'if' block should be deleted.
+ ")
$code, add "\nend --when"
return