Re: Interpreting the D grammar

2015-08-06 Thread H. S. Teoh via Digitalmars-d
On Thu, Aug 06, 2015 at 11:15:15PM +, Tofu Ninja via Digitalmars-d wrote: > On Thursday, 6 August 2015 at 23:08:01 UTC, Casper Færgemand wrote: > >On Sunday, 2 August 2015 at 16:37:06 UTC, MakersF wrote: > >>Of course it's recursive! Do you want the grammar to be able to only > >>define a finit

Re: Interpreting the D grammar

2015-08-06 Thread Tofu Ninja via Digitalmars-d
On Thursday, 6 August 2015 at 23:08:01 UTC, Casper Færgemand wrote: On Sunday, 2 August 2015 at 16:37:06 UTC, MakersF wrote: Of course it's recursive! Do you want the grammar to be able to only define a finite number of programs? a* seems pretty infinite to me. :P (0|1)* Just define your la

Re: Interpreting the D grammar

2015-08-06 Thread Timon Gehr via Digitalmars-d
On 08/07/2015 01:07 AM, "Casper =?UTF-8?B?RsOmcmdlbWFuZCI=?= " wrote: On Sunday, 2 August 2015 at 16:37:06 UTC, MakersF wrote: Of course it's recursive! Do you want the grammar to be able to only define a finite number of programs? a* seems pretty infinite to me. :P And any grammar defining

Re: Interpreting the D grammar

2015-08-06 Thread via Digitalmars-d
On Sunday, 2 August 2015 at 16:37:06 UTC, MakersF wrote: Of course it's recursive! Do you want the grammar to be able to only define a finite number of programs? a* seems pretty infinite to me. :P

Re: Interpreting the D grammar

2015-08-06 Thread Jacob Carlborg via Digitalmars-d
On 06/08/15 20:14, deadalnix wrote: http://stackoverflow.com/a/1732454/672906 I don't have so much of a choice. TextMate supports what it supports. There are TextMate grammars for very many languages, so it's not a problem of not being able to represent a language grammar in TextMate. I jus

Re: Interpreting the D grammar

2015-08-06 Thread deadalnix via Digitalmars-d
On Sunday, 2 August 2015 at 16:08:24 UTC, cym13 wrote: 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:

Re: Interpreting the D grammar

2015-08-06 Thread deadalnix via Digitalmars-d
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 AddE

Re: Interpreting the D grammar

2015-08-06 Thread Jacob Carlborg via Digitalmars-d
On 06/08/15 10:26, MakersF wrote: Then your best shot is to approximate the grammar with the regual expressions you have access to. You'll get to a point where some constructs can not be correctly represented; at that point you should probably write a regex which produces what the grammar produc

Re: Interpreting the D grammar

2015-08-06 Thread Dmitry Olshansky via Digitalmars-d
On 06-Aug-2015 11:26, MakersF wrote: On Sunday, 2 August 2015 at 18:22:01 UTC, Jacob Carlborg wrote: On 02/08/15 19:15, Xinok wrote: I guess you're not familiar with the theoretical aspect of "formal languages". The D grammar is a context-free grammar which cannot be reduced to a regular expre

Re: Interpreting the D grammar

2015-08-06 Thread MakersF via Digitalmars-d
On Sunday, 2 August 2015 at 18:22:01 UTC, Jacob Carlborg wrote: On 02/08/15 19:15, Xinok wrote: I guess you're not familiar with the theoretical aspect of "formal languages". The D grammar is a context-free grammar which cannot be reduced to a regular expression. As cym13 stated, there are so

Re: Interpreting the D grammar

2015-08-02 Thread Jacob Carlborg via Digitalmars-d
On 02/08/15 19:15, Xinok wrote: I guess you're not familiar with the theoretical aspect of "formal languages". The D grammar is a context-free grammar which cannot be reduced to a regular expression. As cym13 stated, there are some simple context-free grammars which can be rewritten as regular e

Re: Interpreting the D grammar

2015-08-02 Thread Xinok via Digitalmars-d
On Sunday, 2 August 2015 at 17:33:35 UTC, Jacob Carlborg wrote: On 02/08/15 18:37, MakersF wrote: Of course it's recursive! Do you want the grammar to be able to only define a finite number of programs? I don't know how this work, that's why I'm asking. But I read something about left recur

Re: Interpreting the D grammar

2015-08-02 Thread cym13 via Digitalmars-d
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) re

Re: Interpreting the D grammar

2015-08-02 Thread Jacob Carlborg via Digitalmars-d
On 02/08/15 18:37, MakersF wrote: Of course it's recursive! Do you want the grammar to be able to only define a finite number of programs? I don't know how this work, that's why I'm asking. But I read something about left recursion needs to be removed to be able to parse a grammar, at least

Re: Interpreting the D grammar

2015-08-02 Thread Jacob Carlborg via Digitalmars-d
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

Re: Interpreting the D grammar

2015-08-02 Thread Xinok via Digitalmars-d
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 AddE

Re: Interpreting the D grammar

2015-08-02 Thread MakersF via Digitalmars-d
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 AddE

Re: Interpreting the D grammar

2015-08-02 Thread cym13 via Digitalmars-d
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 AddE

Interpreting the D grammar

2015-08-02 Thread Jacob Carlborg via Digitalmars-d
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