From a34636cdd812e0cee1f5232392d19e9522ac1f95 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 10 Feb 2014 17:38:46 +0400 Subject: [PATCH] added block set terminator ']]'... Signed-off-by: Alex A. Naanou --- Slang/slang.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Slang/slang.js b/Slang/slang.js index 90524d0..f82e462 100755 --- a/Slang/slang.js +++ b/Slang/slang.js @@ -106,22 +106,26 @@ var PRE_NAMESPACE = { // XXX use the real reader... // block... // syntax: [ ... ] + // NOTE: we can also terminate several blocks with a single ]] '[': function(context){ var block = [] var code = context.code var cur = code.splice(0, 1)[0] - while(cur != ']' && code.length > 0){ + while(cur != ']' && cur != ']]' && code.length > 0){ if(cur == '['){ cur = this['['](context) } block.push(cur) cur = code.splice(0, 1)[0] } - if(code.length == 0 && cur != ']'){ + if(code.length == 0 && cur != ']' && cur != ']]'){ console.error('Did not find expected "]".') } return block }, + ']': function(context){ console.error('Unexpected "]".') }, + ']]': function(context){ console.error('Unexpected "]]".') }, + // XXX macros are not recursive... 'macro:': function(context){ var ident = context.code.splice(0, 1)