Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2013-08-08 Thread Tom Compton
On Sunday, 11 March 2012 at 12:40:34 UTC, Alex Rønne Petersen wrote: Question: Are the generated parsers, AST nodes, etc classes or structs? Why is this important?

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2013-08-07 Thread Elie Morisse
Hi Philippe, I wrote a Kate(the official text editor of KDE, also used in KDevelop) syntax highlighting file for Pegged: http://www.homo-nebulus.fr/dlang/pegged.xml Screenshot: http://imgur.com/sb3jFqs.png Of course for the syntax highlighting to work the grammar must be in a separate file

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-22 Thread Martin Nowak
On Sun, 11 Mar 2012 00:28:42 +0100, Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG: http://en.wikipedia.org/wiki

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-15 Thread Timon Gehr
On 03/15/2012 12:09 AM, Jay Norwood wrote: On Saturday, 10 March 2012 at 23:28:42 UTC, Philippe Sigaud wrote: * Grammars can be dumped in a file to create a D module. In reading the D spec I've seen a few instance where there are infered items such as auto for variables and various parameter

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-14 Thread Jay Norwood
On Saturday, 10 March 2012 at 23:28:42 UTC, Philippe Sigaud wrote: * Grammars can be dumped in a file to create a D module. In reading the D spec I've seen a few instance where there are infered items such as auto for variables and various parameters in templates. I presume your D grammar

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-13 Thread Tobias Pankrath
I am impressed. That's a really nice showcase for the D compile time features. Can I use PEG to parse languages like python and haskell where indention matters without preprocessing? Will you make it work with input ranges of dchar? So that I can easily plug in some preprocessing steps?

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-12 Thread Jay Norwood
On Tuesday, 13 March 2012 at 05:25:38 UTC, Jay Norwood wrote: Admittedly I have not heard of PEGs before, so I'm curious: Is this powerful enough to parse a language such as C? I've just read a few articles referenced from this page, and the second link was by someone who had done java 1

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-12 Thread Jay Norwood
Admittedly I have not heard of PEGs before, so I'm curious: Is this powerful enough to parse a language such as C? I've just read a few articles referenced from this page, and the second link was by someone who had done java 1.5, the second link http://bford.info/packrat/ http://www.roma

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 12-03-2012 02:27, Alex Rønne Petersen wrote: On 11-03-2012 00:28, Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 00:28, Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG: http://en.wikipedia.org/wiki

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Andrei Alexandrescu
On 3/11/12 3:02 AM, Philippe Sigaud wrote: There is an operator to drop unnecessary nodes (':'). Good. Apart from that, a Pegged grammar is a self-contained entity: it automatically cuts nodes coming from other grammars, to simplify the tree (it keeps the matcheds substrings, of course). I pl

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 18:17, Philippe Sigaud wrote: > By the way, bootstrap.d seems to fail to build at the moment: > > ../pegged/utils/bootstrap.d(1433): found ':' when expecting ')' following template argument list > ../pegged/utils/bootstrap.d(1433): members expected > ../pegged/utils/bootstrap.d

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 18:19, Philippe Sigaud wrote: > Hm, I don't *think* C has such ambiguities but I could well be wrong. In any case, if it can handle the non-ambiguous case, that's enough for me. I wanted to tackle D this week, but I might as well begin with C :) Do you happen to have any handy an

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Philippe Sigaud
> Hm, I don't *think* C has such ambiguities but I could well be wrong. In any case, if it can handle the non-ambiguous case, that's enough for me. I wanted to tackle D this week, but I might as well begin with C :) Do you happen to have any handy and readable EBNF grammar for C? At least for D,

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Philippe Sigaud
> By the way, bootstrap.d seems to fail to build at the moment: > > ../pegged/utils/bootstrap.d(1433): found ':' when expecting ')' following template argument list > ../pegged/utils/bootstrap.d(1433): members expected > ../pegged/utils/bootstrap.d(1433): { } expected following aggregate declaratio

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 18:06, Philippe Sigaud wrote: >> On Sun, Mar 11, 2012 at 00:34, Alex Rønne Petersenmailto:xtzgzo...@gmail.com>> wrote: [Parsing C?] >> I think so. But you'd have to do add some semantic action to deal with >> typedefs and macros. > > > Oh, I should have mentioned I only mean

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Philippe Sigaud
> Also, I have sent a pull request to fix the build on 64-bit: https://github.com/PhilippeSigaud/Pegged/pull/1 Merged, thanks!

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Philippe Sigaud
> Quick question, you mention the ability to opt-out of the space-insensitivity, where might one find this? Yes, undocumented. Use the '>' operator. You know, I introduced space-insensitivity recently, to simplify some rules and it keeps biting me back. For example Line <- (!EOL .)* EOL The ca

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Philippe Sigaud
alex: > Question: Are the generated parsers, AST nodes, etc classes or structs? They are structs. See: https://github.com/PhilippeSigaud/Pegged/wiki/Parse-Trees

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Philippe Sigaud
>> On Sun, Mar 11, 2012 at 00:34, Alex Rønne Petersen wrote: [Parsing C?] >> I think so. But you'd have to do add some semantic action to deal with >> typedefs and macros. > > > Oh, I should have mentioned I only meant the actual language (ignoring the preprocessor). OK. I admit I downloaded the

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 16:02, Alex Rønne Petersen wrote: On 11-03-2012 00:28, Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 00:28, Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG: http://en.wikipedia.org/wiki

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread kraybourne
On 3/11/12 24:28 , Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. Philippe Very cool! Quick question, you mention the ability to opt-out of the space-insensitivity, where might one find this? Thanks!

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 00:28, Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG: http://en.wikipedia.org/wiki

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Alex Rønne Petersen
On 11-03-2012 08:22, Philippe Sigaud wrote: On Sun, Mar 11, 2012 at 00:34, Alex Rønne Petersen wrote: Admittedly I have not heard of PEGs before, so I'm curious: Is this powerful enough to parse a language such as C? I think so. But you'd have to do add some semantic action to deal with type

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-11 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 08:51, Andrei Alexandrescu wrote: > I was thinking of ANTLR-style operators in which you say where the root > should be and you get to drop unnecessary nodes. > > (Post on 2012/02/29 10:19AM GMT-0600.) Get it, thanks for the ref! There is an operator to drop unnecessary

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 08:53, Philippe Sigaud wrote: > Anyway, the separating if done on the rule definitions  (Identifier <- ...) Aw, I meant, the separation is done on rule definitions. Damn children climbing on me to get more breakfast :-)

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Andrei Alexandrescu
On 3/11/12 1:38 AM, Philippe Sigaud wrote: On Sun, Mar 11, 2012 at 08:26, Andrei Alexandrescu wrote: Any chance you consider adding AST generator actions as discussed in the main forum a while ago? The AST is automatically produced, and there are already AST actions to simplify / guide its

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 08:47, Andrei Alexandrescu wrote: > Great! I think you'd be wise to add the ";", otherwise it's impossible to > split complex rules on more than one line. Alternatively you could have the > complement, a line continuation thingie. Complex rules can be multi-line, I'll put

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 08:46, Jonathan M Davis wrote: >> Is there an EBNF grammar for D somewhere, I mean outside the dlang docs? > Someone may have been trying to write one, but I don't believe that there's an > official one, and I recall someone complaining the the BNF grammar was > inaccurat

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Andrei Alexandrescu
On 3/11/12 1:35 AM, Philippe Sigaud wrote: On Sun, Mar 11, 2012 at 08:26, Andrei Alexandrescu wrote: Splitting on ";" is trivial and makes client code considerably easier to play with. It's already implemented! No need for ';' Great! I think you'd be wise to add the ";", otherwise it's imp

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Jonathan M Davis
On Sunday, March 11, 2012 08:39:47 Philippe Sigaud wrote: > On Sun, Mar 11, 2012 at 08:30, Jonathan M Davis wrote: > > On Sunday, March 11, 2012 00:28:42 Philippe Sigaud wrote: > >> Hello, > >> > >> I created a new Github project, Pegged, a Parsing Expressi

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 08:30, Jonathan M Davis wrote: > On Sunday, March 11, 2012 00:28:42 Philippe Sigaud wrote: >> Hello, >> >> I created a new Github project, Pegged, a Parsing Expression >> Grammar (PEG) generator in D. > > Cool! PEGs aren't us

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 08:26, Andrei Alexandrescu wrote: > Any chance you consider adding AST generator actions as discussed in the > main forum a while ago? The AST is automatically produced, and there are already AST actions to simplify / guide its creation. There already is an 'ignore that n

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 08:26, Andrei Alexandrescu wrote: > I, too, think this is very significant work! Suggestion for Philippe: > instead of this: > > > enum PEGCode = grammarCode!( >     "Grammar <- S Definition+ EOI" >    ,"Definition <- RuleName Arrow Expression" >    ,"RuleName   <- Identifi

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Jonathan M Davis
On Sunday, March 11, 2012 00:28:42 Philippe Sigaud wrote: > Hello, > > I created a new Github project, Pegged, a Parsing Expression > Grammar (PEG) generator in D. Cool! PEGs aren't used all that much for language grammars - primarily because BNF and EBNF are more traditio

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Andrei Alexandrescu
On 3/11/12 1:22 AM, Philippe Sigaud wrote: On Sun, Mar 11, 2012 at 00:34, Alex Rønne Petersen wrote: Admittedly I have not heard of PEGs before, so I'm curious: Is this powerful enough to parse a language such as C? I think so. But you'd have to do add some semantic action to deal with typed

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Andrei Alexandrescu
On 3/10/12 5:56 PM, Andrej Mitrovic wrote: I see you are not the only one who started writing string array literals like this: enum PEGCode = grammarCode!( "Grammar<- S Definition+ EOI" ,"Definition<- RuleName Arrow Expression" ,"RuleName<- Identifier>(ParamList?)" ,"Express

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 00:56, Andrej Mitrovic wrote: > I see you are not the only one who started writing string array > literals like this: > > enum PEGCode = grammarCode!( >     "Grammar <- S Definition+ EOI" >    ,"Definition <- RuleName Arrow Expression" >    ,"RuleName   <- Identifier>(Param

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
On Sun, Mar 11, 2012 at 00:34, Alex Rønne Petersen wrote: > Admittedly I have not heard of PEGs before, so I'm curious: Is this powerful > enough to parse a language such as C? I think so. But you'd have to do add some semantic action to deal with typedefs and macros. People parsed Java and Jav

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread bearophile
Andrej Mitrovic: > IOW comma on the left side. I know it's not a style preference but > actually a (unfortunate but needed) technique for avoiding bugs. :) To avoid that bug: http://d.puremagic.com/issues/show_bug.cgi?id=3827 Bye, bearophile

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Andrej Mitrovic
I see you are not the only one who started writing string array literals like this: enum PEGCode = grammarCode!( "Grammar <- S Definition+ EOI" ,"Definition <- RuleName Arrow Expression" ,"RuleName <- Identifier>(ParamList?)" ,"Expression <- Sequence (OR Sequence)*" ); IOW comm

Re: Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Alex Rønne Petersen
On 11-03-2012 00:28, Philippe Sigaud wrote: Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG: http://en.wikipedia.org/wiki

Pegged, a Parsing Expression Grammar (PEG) generator in D

2012-03-10 Thread Philippe Sigaud
Hello, I created a new Github project, Pegged, a Parsing Expression Grammar (PEG) generator in D. https://github.com/PhilippeSigaud/Pegged docs: https://github.com/PhilippeSigaud/Pegged/wiki PEG: http://en.wikipedia.org/wiki/Parsing_expression_grammar The idea is to give the generator a