Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. /+dub.sdl:
  2. dependency "pegged" version="~>0.4.4"
  3. +/
  4. import std.stdio;
  5. import pegged.grammar;
  6.  
  7. mixin(grammar(`
  8. Graph:
  9. Node < Entrance / Connection
  10. Entrance < "E" identifier Type
  11. Type < identifier
  12. Connection < identifier (RedEnding / BlueEnding)
  13.  
  14. RedEnding < "R" identifier
  15. BlueEnding < "B" identifier
  16. `));
  17.  
  18.  
  19. // entrances declare a functio n to call
  20. void main()
  21. {
  22. // "blue entrance" is a value
  23.  
  24. enum parseTree1 = Graph(`
  25. E fun
  26. a B b
  27. b R c
  28. `);
  29. //
  30. auto box = asBlackBox(parseTree1);
  31. box.fun =
  32. // pink functions are called
  33. // blue ending and pink ending
  34. // pink ending triggers calls
  35. // blue
  36. // blue -> blue collapses to blue (lazy function)
  37. // blue -> pink triggers pink when blue changes
  38. // pink -> blue sets a value
  39. // pink -> pink collapses to pink
  40.  
  41.  
  42. writeln("Hello D");
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement