Compare commits
No commits in common. "fd0aed81fd46cc48ca14cf8ec87982c00c949266" and "baa981c224a3b4e4029faa86921f5d4ace9a8331" have entirely different histories.
fd0aed81fd
...
baa981c224
5 changed files with 9 additions and 64 deletions
46
spl/json.spl
46
spl/json.spl
|
@ -1,46 +0,0 @@
|
|||
|
||||
construct json namespace {
|
||||
_StringyJSON
|
||||
;
|
||||
props-to-sjson { s | with spaces props this ;
|
||||
def value, comma
|
||||
"," spaces if { " " concat } =comma
|
||||
|
||||
props:last:get<1> =value
|
||||
value null eq not if {
|
||||
value gettype "array" eq if {
|
||||
"[" value
|
||||
:iter
|
||||
:map<| 0 swap properties this:props-to-sjson>
|
||||
:join<comma> concat
|
||||
"]" concat
|
||||
3 stop
|
||||
}
|
||||
"\""
|
||||
value _str :replace<"\\" "\\\\">:replace<"\"" "\\\""> concat
|
||||
"\"" concat
|
||||
2 stop
|
||||
}
|
||||
|
||||
"{"
|
||||
props
|
||||
:iter
|
||||
:filter<{ b | :to-stack pop with key ; key ":" eq not key ";" eq not and }>
|
||||
:map<{ s |
|
||||
:to-stack with key value ;
|
||||
"\""
|
||||
key :replace<"\\" "\\\\">:replace<"\"" "\\\""> concat
|
||||
"\":" concat spaces if { " " concat }
|
||||
spaces value properties this:props-to-sjson concat
|
||||
}>
|
||||
:join<comma> concat
|
||||
"}" concat
|
||||
}
|
||||
}
|
||||
|
||||
construct json:_StringyJSON {
|
||||
;
|
||||
sjson { s | with spaces this ;
|
||||
spaces this properties json:props-to-sjson
|
||||
}
|
||||
}
|
|
@ -717,8 +717,8 @@ func _'match-else-error { |
|
|||
}
|
||||
|
||||
func _'match-else-push { |
|
||||
dup if {
|
||||
swap pop
|
||||
if {
|
||||
pop
|
||||
}
|
||||
}
|
||||
|
||||
|
|
12
src/lexer.rs
12
src/lexer.rs
|
@ -260,17 +260,19 @@ fn read_block_dyn(
|
|||
"=" => {
|
||||
if str_words[i + 1] == ">" {
|
||||
i += 1;
|
||||
let cword = &str_words[i + 1];
|
||||
if cword.contains(|c| c == '?' || c == '!') {
|
||||
let pushing = if str_words[i + 1] == "?" {
|
||||
i += 1;
|
||||
}
|
||||
let pushing = if cword.contains('?') {
|
||||
words.push(Word::Call("dup".to_owned(), false, 0));
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
let throwing = cword.contains('!');
|
||||
let throwing = if str_words[i + 1] == "!" {
|
||||
i += 1;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
};
|
||||
if str_words[i + 1] == "[" {
|
||||
i += 1;
|
||||
let mut block =
|
||||
|
|
|
@ -17,7 +17,6 @@ pub const SERVER: &str = include_str!("../spl/server.spl");
|
|||
pub const HTTP_SERVER: &str = include_str!("../spl/httpserver/base.spl");
|
||||
pub const HTTP_SERVER_STATIC: &str = include_str!("../spl/httpserver/static.spl");
|
||||
pub const LINKEDLIST: &str = include_str!("../spl/linkedlist.spl");
|
||||
pub const JSON: &str = include_str!("../spl/json.spl");
|
||||
pub const NOP: &str = "";
|
||||
|
||||
pub fn register(runtime: &mut Runtime) {
|
||||
|
@ -39,7 +38,6 @@ pub fn register(runtime: &mut Runtime) {
|
|||
insert("httpserver/base.spl", HTTP_SERVER);
|
||||
insert("httpserver/static.spl", HTTP_SERVER_STATIC);
|
||||
insert("linkedlist.spl", LINKEDLIST);
|
||||
insert("json.spl", JSON);
|
||||
insert("nop.spl", NOP);
|
||||
}
|
||||
}
|
||||
|
|
9
test.spl
9
test.spl
|
@ -6,7 +6,6 @@
|
|||
"spl/time.spl" import
|
||||
"spl/httpserver/base.spl" import
|
||||
"spl/linkedlist.spl" import
|
||||
"spl/json.spl" import
|
||||
|
||||
|
||||
"SPL tester" =program-name
|
||||
|
@ -328,14 +327,6 @@ func main { int | with args ;
|
|||
}
|
||||
}
|
||||
|
||||
^ok =>? ^error not if { println }
|
||||
|
||||
"" println
|
||||
"json test" println
|
||||
|
||||
0 [ 0 1 2 "hi" ] properties json:props-to-sjson println
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue