Advertisement
Guest User

Untitled

a guest
May 1st, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tyrant = require("./tyranny").tyrant
  2. var console = require("beautiful-log")
  3.  
  4. var george = new tyrant()
  5. george.addTokens({
  6.     "OPEN": /^\($/,
  7.     "CLOSE": /^\)$/
  8. })
  9.  
  10. george.addRules({
  11.     "E": "(OPEN CLOSE)|(OPEN {E} CLOSE)|[{E} {E}]"
  12. })
  13.  
  14. console.log(george.parse("()"))
  15. console.log(george.parse("(())"))
  16. console.log(george.parse("(()())"))
  17. console.log(george.parse("()()(())"))
  18. console.log(george.parse("(()"))
  19. console.log(george.parse(")("))
  20.  
  21. var nero = new tyrant()
  22. nero.addTokens({
  23.     "LAMBDA": /^L $/,
  24.     "DOT": /^\.$/,
  25.     "STRING": /^[a-zA-Z0-9]+$/,
  26.     "OPEN": /^\($/,
  27.     "CLOSE": /^\)$/,
  28.     "COMMA": /^, ?$/
  29. })
  30.  
  31. nero.addRules({
  32.     "E": "[LAMBDA STRING DOT {E}]|[OPEN ({E}) COMMA {E} CLOSE]|[STRING]"
  33. })
  34.  
  35. console.log(nero.parse('L hi.hi'))
  36. console.log(nero.parse('L hi.(L TEST.hi, hi)'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement