reworking lexer (not enabled yet) + scroll to bottom on exec...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-02-10 05:26:24 +04:00
parent 53b91ecf20
commit 2fc89940c9
2 changed files with 43 additions and 13 deletions

View File

@ -143,6 +143,8 @@ function runCommand(){
next.setAttribute('contenteditable', true)
console.appendChild(next)
next.focus()
window.scrollTo(0,document.body.scrollHeight)
}
NAMESPACE.print = function(context){

View File

@ -61,11 +61,48 @@ function run(context){
}
// XXX make this add '\n' / EOL words to the stream...
var SPLITTER = /\s*\([^\)]*\)\s*|\s*--.*[\n$]|\s*"([^"]*)"\s*|\s*'([^']*)'\s*|\s+/m
//var SPLITTER = /\s*\([^\)]*\)\s*|\s*--.*[\n$]|\s*"([^"]*)"\s*|\s*'([^']*)'\s*|\s+/m
var SPLITTER = RegExp([
// terms to keep in the stream...
/*'('+[
'\\n',
'--',
].join('|')+')',*/
// comments...
'\\s*\\([^\\)]*\\)\\s*',
'\\s*--.*[\\n$]',
// quoted strings...
'\\s*"([^"]*)"\\s*',
"\\s*'([^']*)'\\s*",
// whitespace...
'\\s+',
].join('|'),
'm')
// pre-processor namespace...
var PRE_NAMESPACE = {
// comment...
// syntax: -- ... \n
//
// drop everything until '\n'
//
// NOTE: this depends on explicit '\n' words...
'--': function(context){
var res = ['--']
var code = context.code
var cur = code.splice(0, 1)[0]
res.push(cur)
while(cur != '\n' && code.length > 0){
cur = code.splice(0, 1)[0]
res.push(cur)
}
console.log(res.join(' '))
},
// XXX use the real reader...
// block...
// syntax: [ ... ]
@ -98,19 +135,10 @@ var PRE_NAMESPACE = {
this[ident] = cur[0]
},
// comment...
// drop everything until '\n'
//
// NOTE: this depends on explicit '\n' words...
'--': function(context){
var code = context.code
var cur = code.splice(0, 1)[0]
while(cur != '\n' && code.length > 0){
cur = code.splice(0, 1)[0]
}
},
// a no op...
'\n': function(){},
'\n': function(){
console.log('NL')
},
}