Hey folks,
I'm still unsure how to parse the grammars described in Villages Concept and stuff.
At the moment I'm just using a Scanner on the whole file and work witch a lot of if-then-else constructs.
As the files have an own syntax, I thought about using a state machine (hand coded or using a library). Are there any other/better ways doing this.
Or may there be a better structure for grammar files that is easy to parse and still readable/understandable?
All in all a grammar could look like this (in concept, not carved in stone yet)
Any advice is appreciated
I'm still unsure how to parse the grammars described in Villages Concept and stuff.
At the moment I'm just using a Scanner on the whole file and work witch a lot of if-then-else constructs.
As the files have an own syntax, I thought about using a state machine (hand coded or using a library). Are there any other/better ways doing this.
Or may there be a better structure for grammar files that is easy to parse and still readable/understandable?
All in all a grammar could look like this (in concept, not carved in stone yet)
Code:
# Header with meta information
biomes : PLAIN,DESERT,...;
styles : MEDIEVAL;
functionality: FORGE;
# Now the rules are following
building : (height >= 12)
::- floor(height/3) floor(height/3) floor(height/3);
floor
::- facades rooms;
facades
::- Comp("sidefaces"){facade};
facade
::- ... ;