mirror of
				https://github.com/flynx/Course-JavaScript.git
				synced 2025-10-31 03:50:10 +00:00 
			
		
		
		
	block terminator now working...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									c956cd231b
								
							
						
					
					
						commit
						090686bb2e
					
				| @ -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){ | ||||||
| @ -719,7 +723,7 @@ var BOOTSTRAP = [ | |||||||
| '	dup [ -1 eq ] ?', | '	dup [ -1 eq ] ?', | ||||||
| '		[ . push ]', | '		[ . push ]', | ||||||
| '	else', | '	else', | ||||||
| '		[ inc before ] ]', | '		[ inc before ]]', | ||||||
| '', | '', | ||||||
| '-- push element to tail of block...', | '-- push element to tail of block...', | ||||||
| ':: push ( b e -- b ) [ swap len rot swap tor to ]', | ':: push ( b e -- b ) [ swap len rot swap tor to ]', | ||||||
| @ -750,7 +754,7 @@ var BOOTSTRAP = [ | |||||||
| '		[ drop ]', | '		[ drop ]', | ||||||
| '	-- dec push new and continue...', | '	-- dec push new and continue...', | ||||||
| '	else', | '	else', | ||||||
| '		[ 1 sub 0 before range ] ]', | '		[ 1 sub 0 before range ]]', | ||||||
| '', | '', | ||||||
| '-- Sum up the elements of a block...', | '-- Sum up the elements of a block...', | ||||||
| ':: sum ( L -- s ) [', | ':: sum ( L -- s ) [', | ||||||
| @ -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 ]]', | ||||||
| '', | '', | ||||||
| '', | '', | ||||||
| '', | '', | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user