mirror of
https://github.com/flynx/Slang.git
synced 2025-10-29 18:50: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;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
|
||||||
color: red;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.command {
|
.command {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
padding-right: 5px;
|
padding-right: 5px;
|
||||||
@ -37,15 +32,23 @@
|
|||||||
opacity: 0.2;
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: red;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
.output {
|
.output {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.error:before,
|
||||||
.output:before {
|
.output:before {
|
||||||
content: ">";
|
content: ">";
|
||||||
color: blue;
|
color: red;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
}
|
}
|
||||||
|
.output:before {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#stack {
|
#stack {
|
||||||
@ -105,8 +108,20 @@ NAMESPACE.print = function(context){
|
|||||||
c.appendChild(data)
|
c.appendChild(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX should this break exec?
|
||||||
NAMESPACE.err = function(context){
|
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')){
|
if(typeof(code) == typeof('abc')){
|
||||||
// XXX BUG: '"aaa" "bbb"' translates to ['"aaa"', '" "', '"bbb"']
|
// XXX BUG: '"aaa" "bbb"' translates to ['"aaa"', '" "', '"bbb"']
|
||||||
// i.e. quotes w/o whitespace are eaten...
|
// i.e. quotes w/o whitespace are eaten...
|
||||||
if(/^(['"]).*\1$/m.test(code)){
|
if(/^\s*(['"]).*\1\s*$/m.test(code)){
|
||||||
code = code.split(/^(['"])(.*)\1$/m)[2]
|
code = code.split(/^\s*(['"])(.*)\1\s*$/m)[2]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(code)
|
||||||
|
|
||||||
var res = []
|
var res = []
|
||||||
code = code
|
code = code
|
||||||
// split by strings whitespace and block comments...
|
// split by strings whitespace and block comments...
|
||||||
@ -546,10 +549,9 @@ function slang(code, context){
|
|||||||
context = context == null ? CONTEXT : context
|
context = context == null ? CONTEXT : context
|
||||||
|
|
||||||
if(typeof(code) == typeof('abc')){
|
if(typeof(code) == typeof('abc')){
|
||||||
//code = [ '"'+code+'"', 'lex', 'prep', 'exec' ]
|
code = [ '\\', code, 'lex', 'prep', 'exec' ]
|
||||||
code = [ code, 'lex', 'prep', 'exec' ]
|
|
||||||
} else {
|
} else {
|
||||||
code = [ [code], 'b2s', 'prep', 'exec' ]
|
code = [ code, 'prep', 'exec' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
context.code = code
|
context.code = code
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user