tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-12-22 18:04:24 +03:00
parent 5252724ab2
commit 0da65957fd

View File

@ -90,22 +90,23 @@ var SPLITTER = RegExp([
// helpers... // helpers...
// XXX should these skip quoted ends? // XXX should these skip quoted ends?
var collectUntil = function(end){ var collect = function(start, end){
return function(context){ return function(context){
var res = ['--'] var res = start ? [start] : []
var code = context.code var code = context.code
var cur = code.shift() var cur = code.shift()
res.push(cur) res.push(cur)
while(cur != end && code.length > 0){ while(cur != end && code.length > 0){
cur = code.splice(0, 1)[0] cur = code.shift()
res.push(cur) res.push(cur)
} }
return res return res
} }
} }
var dropUntil = function(end){ var drop = function(start, end){
var collector = collectUntil(end) var collector = collect(start, end)
return function(context){ collector(context) } //return function(context){ collector(context) }
return function(context){ console.log('XXX', collector(context).join(' ')) }
} }
@ -117,8 +118,8 @@ var PRE_NAMESPACE = {
// drop everything until '\n' // drop everything until '\n'
// //
// NOTE: this depends on explicit '\n' words... // NOTE: this depends on explicit '\n' words...
'--': dropUntil('\n'), //'--': drop('--', '\n'),
//'(': dropUntil(')'), '(': drop('(', ')'),
// XXX use the real reader... // XXX use the real reader...
// block... // block...