mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 02:30:08 +00:00
several bug fixes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a08c14a591
commit
a3d1705bc4
@ -8,11 +8,6 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.command {
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
@ -37,15 +32,23 @@
|
||||
opacity: 0.2;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
font-style: italic;
|
||||
}
|
||||
.output {
|
||||
font-weight: bold;
|
||||
}
|
||||
.error:before,
|
||||
.output:before {
|
||||
content: ">";
|
||||
color: blue;
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
margin: 5px;
|
||||
}
|
||||
.output:before {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
|
||||
#stack {
|
||||
@ -105,8 +108,20 @@ NAMESPACE.print = function(context){
|
||||
c.appendChild(data)
|
||||
}
|
||||
|
||||
// XXX should this break exec?
|
||||
NAMESPACE.err = function(context){
|
||||
throw context.stack[context.stack.length-1]
|
||||
var c = document.getElementById('console')
|
||||
var e = context.stack[context.stack.length-1]
|
||||
console.error('>>>', e)
|
||||
|
||||
var err = document.createElement('div')
|
||||
err.classList.add('error')
|
||||
if(e.message != null){
|
||||
err.innerText = e.message
|
||||
} else {
|
||||
err.innerText = e
|
||||
}
|
||||
c.appendChild(err)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -159,9 +159,12 @@ var NAMESPACE = {
|
||||
if(typeof(code) == typeof('abc')){
|
||||
// XXX BUG: '"aaa" "bbb"' translates to ['"aaa"', '" "', '"bbb"']
|
||||
// i.e. quotes w/o whitespace are eaten...
|
||||
if(/^(['"]).*\1$/m.test(code)){
|
||||
code = code.split(/^(['"])(.*)\1$/m)[2]
|
||||
if(/^\s*(['"]).*\1\s*$/m.test(code)){
|
||||
code = code.split(/^\s*(['"])(.*)\1\s*$/m)[2]
|
||||
}
|
||||
|
||||
console.log(code)
|
||||
|
||||
var res = []
|
||||
code = code
|
||||
// split by strings whitespace and block comments...
|
||||
@ -546,10 +549,9 @@ function slang(code, context){
|
||||
context = context == null ? CONTEXT : context
|
||||
|
||||
if(typeof(code) == typeof('abc')){
|
||||
//code = [ '"'+code+'"', 'lex', 'prep', 'exec' ]
|
||||
code = [ code, 'lex', 'prep', 'exec' ]
|
||||
code = [ '\\', code, 'lex', 'prep', 'exec' ]
|
||||
} else {
|
||||
code = [ [code], 'b2s', 'prep', 'exec' ]
|
||||
code = [ code, 'prep', 'exec' ]
|
||||
}
|
||||
|
||||
context.code = code
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user