On Sunday, 2 August 2015 at 17:29:57 UTC, Jacob Carlborg wrote:
On 02/08/15 18:08, cym13 wrote:
You can't build a regular expression for any grammar. You can
for some
grammars but those are only a simple subset. For example,
checking
parens balance is impossible with common (not recursive)
regular
expressions only, and even with recursion it soon reaches its
limitations.
TextMate grammars support recursion, it's possible to define a
grammar with balanced parentheses [1].
[1] https://manual.macromates.com/en/language_grammars
Yes, that will work for this simple example, but what of
interleaved parentheses ? Say you want (), [] and "" to match,
how can you do ?
[[("]("), "])(", ")"]]
There are constructs that aren't possibly doable using even
extend regular expressions. That's why grammars were invented
after all.
Reading your documentation, it seems that you are not expected to
reduce the grammar to a regular expression, rather it uses many
regular expressions to describes parts of the language grammar,
so that should work.