Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /+dub.sdl:
- dependency "pegged" version="~>0.4.4"
- +/
- import std.stdio;
- import pegged.grammar;
- mixin(grammar(`
- Graph:
- Node < Entrance / Connection
- Entrance < "E" identifier Type
- Type < identifier
- Connection < identifier (RedEnding / BlueEnding)
- RedEnding < "R" identifier
- BlueEnding < "B" identifier
- `));
- // entrances declare a functio n to call
- void main()
- {
- // "blue entrance" is a value
- enum parseTree1 = Graph(`
- E fun
- a B b
- b R c
- `);
- //
- auto box = asBlackBox(parseTree1);
- box.fun =
- // pink functions are called
- // blue ending and pink ending
- // pink ending triggers calls
- // blue
- // blue -> blue collapses to blue (lazy function)
- // blue -> pink triggers pink when blue changes
- // pink -> blue sets a value
- // pink -> pink collapses to pink
- writeln("Hello D");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement