On Sunday, 2 August 2015 at 14:50:35 UTC, Jacob Carlborg wrote:
I'm trying to read the D grammar [1] to enhance the D TextMate bundle. If we take the add expression as an example. It's defined like this in the grammar:

AddExpression:
    MulExpression
    AddExpression + MulExpression
    AddExpression - MulExpression
    CatExpression

And like this in the grammar made by Brian [2]:

addExpression:
      mulExpression
    | addExpression ('+' | '-' | '~') mulExpression
    ;

I'm not so familiar with grammars but this looks like it's recursive. Is it possible to translate this piece of grammar to a regular expression? TextMate uses regular expressions and a couple of enhancements/extensions to define a grammar for a language.

[1] http://dlang.org/grammar.html
[2] https://rawgit.com/Hackerpilot/DGrammar/master/grammar.html

http://stackoverflow.com/a/1732454/672906

Reply via email to