Guest User

Untitled

a guest
Apr 26th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. grammar Shell
  2. rule command
  3. (interpolation / simple)+ {
  4. def execute(&block)
  5. yield elements.map do |e|
  6. if e.respond_to? :simple
  7. puts e.text_value
  8. e.text_value
  9. else
  10. e.execute(&block)
  11. end
  12. end.join
  13. end
  14. }
  15. end
  16.  
  17. rule interpolation
  18. '$(' command ')' {
  19. def execute(&block)
  20. yield command.execute(&block)
  21. end
  22. }
  23. end
  24.  
  25. rule simple
  26. (!'$(' !')' .)+ {
  27. def execute(&block)
  28. yield text_value
  29. end
  30. }
  31. end
  32. end
Add Comment
Please, Sign In to add comment