mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 18:50:08 +00:00
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:
parent
53b91ecf20
commit
2fc89940c9
@ -143,6 +143,8 @@ function runCommand(){
|
|||||||
next.setAttribute('contenteditable', true)
|
next.setAttribute('contenteditable', true)
|
||||||
console.appendChild(next)
|
console.appendChild(next)
|
||||||
next.focus()
|
next.focus()
|
||||||
|
|
||||||
|
window.scrollTo(0,document.body.scrollHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
NAMESPACE.print = function(context){
|
NAMESPACE.print = function(context){
|
||||||
|
|||||||
@ -61,11 +61,48 @@ function run(context){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX make this add '\n' / EOL words to the stream...
|
// 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...
|
// pre-processor namespace...
|
||||||
var PRE_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...
|
// XXX use the real reader...
|
||||||
// block...
|
// block...
|
||||||
// syntax: [ ... ]
|
// syntax: [ ... ]
|
||||||
@ -98,19 +135,10 @@ var PRE_NAMESPACE = {
|
|||||||
this[ident] = cur[0]
|
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...
|
// a no op...
|
||||||
'\n': function(){},
|
'\n': function(){
|
||||||
|
console.log('NL')
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user