Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env io
- Yajl
- Regex
- Message do(
- asMap := method(
- if(
- self name allMatchesOfRegex("(^[0-9\"])|true|false|nil") isNotEmpty,
- return Map with("type", "literal", "value", doString(self name))
- )
- if(
- self name == ";",
- return Map with("type", "statement_sep")
- )
- if(
- self arguments size > 0,
- Map with("type", "call", "name", self name, "arguments", self arguments),
- Map with("type", "var", "name", self name)
- )
- )
- asList := method(
- if(self next isNil,
- list(self asMap),
- self next asList prepend(self asMap)
- )
- )
- asJson := method(
- self asList asJson
- )
- )
- Block asJson := method(
- m := Map with("body", self message asList)
- if(self argumentNames isNotEmpty,
- m atPut("params", self argumentNames)
- )
- m asJson
- )
- if(
- System isLaunchScript,
- block(a, b,
- c := getInput(2)
- d = true
- return a+b*c+1
- ) asJson println
- )
Add Comment
Please, Sign In to add comment