diff --git a/Slang/slang.html b/Slang/slang.html
index 29bb20d..e2aa9bb 100755
--- a/Slang/slang.html
+++ b/Slang/slang.html
@@ -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)
}
diff --git a/Slang/slang.js b/Slang/slang.js
index 0420bc4..a085703 100755
--- a/Slang/slang.js
+++ b/Slang/slang.js
@@ -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