Guest User

Untitled

a guest
May 27th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #!/usr/bin/env io
  2.  
  3. Yajl
  4. Regex
  5.  
  6. Message do(
  7. asMap := method(
  8.  
  9. if(
  10. self name allMatchesOfRegex("(^[0-9\"])|true|false|nil") isNotEmpty,
  11. return Map with("type", "literal", "value", doString(self name))
  12. )
  13.  
  14. if(
  15. self name == ";",
  16. return Map with("type", "statement_sep")
  17. )
  18.  
  19. if(
  20. self arguments size > 0,
  21. Map with("type", "call", "name", self name, "arguments", self arguments),
  22. Map with("type", "var", "name", self name)
  23. )
  24. )
  25.  
  26. asList := method(
  27. if(self next isNil,
  28. list(self asMap),
  29. self next asList prepend(self asMap)
  30. )
  31. )
  32.  
  33. asJson := method(
  34. self asList asJson
  35. )
  36. )
  37.  
  38. Block asJson := method(
  39. m := Map with("body", self message asList)
  40. if(self argumentNames isNotEmpty,
  41. m atPut("params", self argumentNames)
  42. )
  43.  
  44. m asJson
  45. )
  46.  
  47. if(
  48. System isLaunchScript,
  49. block(a, b,
  50. c := getInput(2)
  51. d = true
  52. return a+b*c+1
  53. ) asJson println
  54. )
Add Comment
Please, Sign In to add comment