Open ymeine opened 11 years ago
Sublime Text's syntax definition implementation is worth having a look at! :wink:
Here is the draft of the reference.
And a real-life example in the case of Aria Templates.
Sublime Text's one is very similar to TextMate's one, and Ace got inspired by the latter.
We can see that the grammars for AT and HTML are really close: since they are both markup based.
Moreover, whatever (I think) the language being defined by the grammar, the rules share the same pattern:
And some common patterns are used, to define list of some elements, etc.
It would be great to be able to define the rules in a more abstract level, with more properties, more semantics, and more flexibility. In JSON or whatever already existing standard format.
So instead of defining a block element in HTML like this:
we would pass this information:
We could even imagine some rule factories for common patterns. The above would be written:
This would handle nicely the conditional assignment in case an element is optional, also the numbering of white spaces, errors, permissive / partial parsers, ...