block terminator now working...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-02-10 17:53:13 +04:00
parent c956cd231b
commit 090686bb2e

View File

@ -110,22 +110,26 @@ var PRE_NAMESPACE = {
var block = [] var block = []
var code = context.code var code = context.code
var cur = code.splice(0, 1)[0] var cur = code.splice(0, 1)[0]
//while(cur != ']' && cur != ']]' && code.length > 0){ while(cur != ']' && cur != ']]' && code.length > 0){
while(cur != ']' && code.length > 0){ //while(cur != ']' && code.length > 0){
if(cur == '['){ if(cur == '['){
cur = this['['](context) cur = this['['](context)
} }
block.push(cur) block.push(cur)
cur = code.splice(0, 1)[0] cur = code.splice(0, 1)[0]
} }
//if(code.length == 0 && cur != ']' && cur != ']]'){ // we need this to be able to jump out of all the nested blocks...
if(code.length == 0 && cur != ']'){ if(cur == ']]'){
code.splice(0, 0, cur)
}
if(code.length == 0 && cur != ']' && cur != ']]'){
console.error('Did not find expected "]".') console.error('Did not find expected "]".')
} }
return block return block
}, },
// drop the closing words...
']]': function(context){},
']': function(context){ console.error('Unexpected "]".') }, ']': function(context){ console.error('Unexpected "]".') },
']]': function(context){ console.error('Unexpected "]]".') },
// XXX macros are not recursive... // XXX macros are not recursive...
'macro:': function(context){ 'macro:': function(context){
@ -763,7 +767,7 @@ var BOOTSTRAP = [
' [ pop swap . ]', ' [ pop swap . ]',
' -- and now recursively sum up elements till the list is 1 in length...', ' -- and now recursively sum up elements till the list is 1 in length...',
' else', ' else',
' [ pop rot pop tor add push sum ] ] ]', ' [ pop rot pop tor add push sum ]]',
'', '',
'', '',
'', '',