Re: Reducing Pegged ASTs

2014-11-26 Thread Nordlöw
On Wednesday, 26 November 2014 at 06:09:12 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: IIRC there is a free function in Pegged that does it. What's the name of this function? I did not automate it, because every time I cut down severely a parse tree, I later regret it because I lost

Reducing Pegged ASTs

2014-11-25 Thread Nordlöw
Is there a way to (on the fly) reduce Pegged parse results such as C [0, 6][int, x, ;] +-C.TranslationUnit [0, 6][int, x, ;] +-C.ExternalDeclaration [0, 6][int, x, ;] +-C.Declaration [0, 6][int, x, ;] +-C.DeclarationSpecifiers [0, 4][int] | +-C.TypeSpecifier [0,

Re: Reducing Pegged ASTs

2014-11-25 Thread Nordlöw
On Tuesday, 25 November 2014 at 15:12:39 UTC, Nordlöw wrote: I guess it would reduce memory requirements by about a magnitude right? Correction: For consistency we probably want this example to be reduced to +-C.Declaration [0, 6][int, x, ;] +-C.TypeSpecifier [0, 4][int]

Re: Reducing Pegged ASTs

2014-11-25 Thread Nordlöw
On Tuesday, 25 November 2014 at 15:15:40 UTC, Nordlöw wrote: +-C.Declaration [0, 6][int, x, ;] +-C.TypeSpecifier [0, 4][int] +-C.Identifier [4, 5][x] Correction again: +-C.Declaration [0, 6][int, x, ;] +-C.TypeSpecifier [0, 4][int] +-C.Identifier [4, 5][x]

Re: Reducing Pegged ASTs

2014-11-25 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-11-25 10:12, Nordlöw wrote: Is there a way to (on the fly) reduce Pegged parse results such as I've made an asn.1 parser using pegged tree map, it's not so complex and does the reducing as well. https://github.com/globecsys/asn1.d Most of the meat is in asn1/generator/ In short,

Re: Reducing Pegged ASTs

2014-11-25 Thread Philippe Sigaud via Digitalmars-d-learn
On Tue, Nov 25, 2014 at 4:12 PM, Nordlöw digitalmars-d-learn@puremagic.com wrote: Is there a way to (on the fly) reduce Pegged parse results such as C [0, 6][int, x, ;] +-C.TranslationUnit [0, 6][int, x, ;] +-C.ExternalDeclaration [0, 6][int, x, ;] +-C.Declaration [0, 6][int, x,