Hi
What is the best way to handle pre-processor directives with PetitParser without polluting the parsing too much? Any suggestions? unit forms; interface {$IFDEF WINDOWS} uses bla; {$ENDIF} {$IFDEF LINUX} uses bla2; {$ENDIF} Diego & Stephan _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Maybe you can use a -completely separate- pre-parser? :)
It takes the input with the pre processor directives, and answers a new processed string which the original parser will handle?. Guille On Thu, Sep 13, 2012 at 3:22 PM, Stephan Eggermont <[hidden email]> wrote: Hi _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
You can use PetitPreprocessor:
Gofer new
squeaksource3: 'PetitPreprocessor'; package: 'PetitPreprocessor'; load Now it's just transform a matching regex to a substitution String (MyParser preProcess: ('toPreprocess' asRegex) into: 'preProcessed' ) but I plan to improve it by providing a PParser to detect a matching and apply its transformation block (myParser preProcessor: (matchingParser ==> [:m | ..... ])). 2012/9/13 Guillermo Polito <[hidden email]> Maybe you can use a -completely separate- pre-parser? :) Guillaume Larcheveque _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
In reply to this post by Stephan Eggermont-3
Guillaume wrote:
>You can use PetitPreprocessor: >Gofer new > squeaksource3: 'PetitPreprocessor'; > package: 'PetitPreprocessor'; > load > >Now it's just transform a matching regex to a substitution String (MyParser >preProcess: ('toPreprocess' asRegex) into: 'preProcessed' ) but I plan to >improve it by providing a PParser to detect a matching and apply its >transformation block (myParser preProcessor: (matchingParser ==> [:m | >..... ])). Thank you. Will try that first Stephan _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
In reply to this post by Stephan Eggermont-3
Guillermo wrote:
>Maybe you can use a -completely separate- pre-parser? :) > >It takes the input with the pre processor directives, and answers a new >processed string which the original parser will handle?. Yes, I guess so. I'm fighting a bit with PetitParser, wondering if the traditional style of building parsers wouldn't be faster. But that might be just about trying something new. I like the tests, the separate lexicon, syntax and semantics subclassing not so much better than preprocessing, scanning, parsing. I definitely don't like having 80 productions in a class (growing to 300, not sure how to grow over the max nr of instVars ). Is there an array or dictionary based PPCompositeParser? Stephan _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
On 9/14/12, Stephan Eggermont <[hidden email]> wrote:
> Guillermo wrote: >>Maybe you can use a -completely separate- pre-parser? :) >> >>It takes the input with the pre processor directives, and answers a new >>processed string which the original parser will handle?. > > Yes, I guess so. I'm fighting a bit with PetitParser, wondering if the > traditional > style of building parsers wouldn't be faster. But that might be just about > trying > something new. I like the tests, the separate lexicon, syntax and semantics > > subclassing not so much better than preprocessing, scanning, parsing. > I definitely don't like having 80 productions in a class I put them into into method categories and that works very fine for me. (growing to 300, > not > sure how to grow over the max nr of instVars ). I assume it is not possible to have more than 255 rules in a class but I have not tried this limit yet. But you can start combining parser as I understand. I have not done this either, so I would appreciate to be pointed to an example. --Hannes Is there an array or > dictionary > based PPCompositeParser? > > Stephan > _______________________________________________ > Moose-dev mailing list > [hidden email] > https://www.iam.unibe.ch/mailman/listinfo/moose-dev > _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Am 14.09.2012 um 14:35 schrieb H. Hirzel <[hidden email]>: > On 9/14/12, Stephan Eggermont <[hidden email]> wrote: >> Guillermo wrote: >>> Maybe you can use a -completely separate- pre-parser? :) >>> >>> It takes the input with the pre processor directives, and answers a new >>> processed string which the original parser will handle?. >> >> Yes, I guess so. I'm fighting a bit with PetitParser, wondering if the >> traditional >> style of building parsers wouldn't be faster. But that might be just about >> trying >> something new. I like the tests, the separate lexicon, syntax and semantics >> >> subclassing not so much better than preprocessing, scanning, parsing. >> I definitely don't like having 80 productions in a class > > I put them into into method categories and that works very fine for me. > > (growing to 300, >> not >> sure how to grow over the max nr of instVars ). > > I assume it is not possible to have more than 255 rules in a class but > I have not tried this limit yet. > > But you can start combining parser as I understand. I have not done > this either, so I would appreciate to be pointed to an example In order to combine parsers you need separate grammar parts that can be combined with a single rule. I think this can be a heavy task if you have a huge grammar and you like to split it into parts. I tried something by having delegating parsers. Meaning putting productions in separate classes and delegate to the parsers inside a production rule. After a while I started to dislike the approach and got rid of the separate classes again. Instead I compacted the rules a bit. Rules that were really close to each other I have combined in one method having the individual rules in temporary variables. Until now I didn't find any better approach. If the project is huge and a lot of extra complexity is ok then using Lukas' approach in Helvetia would be feasible. By introducing a separate smalltalk parser the accesses to instance variables are mapped onto a dictionary. This way the limit isn't there. Norbert > --Hannes > > Is there an array or >> dictionary >> based PPCompositeParser? >> >> Stephan >> _______________________________________________ >> Moose-dev mailing list >> [hidden email] >> https://www.iam.unibe.ch/mailman/listinfo/moose-dev >> > _______________________________________________ > Moose-dev mailing list > [hidden email] > https://www.iam.unibe.ch/mailman/listinfo/moose-dev _______________________________________________ Moose-dev mailing list [hidden email] https://www.iam.unibe.ch/mailman/listinfo/moose-dev |
Free forum by Nabble | Edit this page |