Monday, June 05, 2006

June 5th, 2006 -- Named Captures

Someone in another open source project I joined made some mistake and since the system is online, it corrupted many users config files which took me a lot of time help fixing it. (The error report is still growing..)

I added a rule to Pugs::Grammar::Rule so that it accepts more named capture syntax. It accepted only $<var> := (pattern). The parentheses was necessary. Now more general $<var> := [pattern] and $<var> := <subrule> are also valid.
Since when dealing with Perl 5 ratchet emitter, I've hacked the named capture emitting routine and made sure that it still work with the extended syntax. What made me surprised is, even the non-ratchet emitter works fine with the newly acceptable syntax. However, I'm still suspecting that the positional capture is not correctly generated. When $<var> := (pattern) is used, the (pattern) should NOT be listed in the positional captures.

Any way, the tests in ratchet shows that Pugs::Emitter::Rule::Perl5::Ratchet works correctly. And I'll add tests for the non-ratchet one if possible.

On the other hand, the Pugs::Emitter::Rule::Parsec plan has been in my brain for a while and there IS a Perl module for it now -- in my working copy and has a lot of functions with empty body. As soon as it has some basic construction, I will check it in and begin our Parser/*.hs replacement.

Saturday, June 03, 2006

June 3rd, 2006 -- Well formatted grammar

Still not begin writing Pugs::Emitter::Rule::Parsec. Still dealing with MiniPerl6. Aufrank++ and spinclad++ gave some great comments about my variable matching rule. And the post I sent to perl.perl6.language, which was NOT sent to the list since I posted it dirctly by group.google, was replied by pmichaud++, my mentor :)

The thread is here (http://0rz.net/7b1pZ). Following his comments, I changed the matching rule of <ws> and changed some rules into tokens. The grammar file is not so hateful now.

Update: Audrey++ confirmed that the PGE-way of <ws> is correct and has updated S05.

Thursday, June 01, 2006

June 1st, 2006 -- A new month, a new stage

Since the MiniPerl6 is finished, and it seems that there will not be big changes, I am planning moving on next stage, Pugs::Emitter::Rule::Parsec. There is no progress yet but I spent some time exploring papers on monads (most of them are published 10+ years ago) mostly for my current researching topic but also that Parsec is a monadic parser and I haven't totally understood monad.

On the other hand, I don't really like (pronounce "hate") the current MiniPerl6.grammar. It was well-formatted before :sigspace was implemented in Pugs::Compiler::Rule. But after the default-on option was implemented, I could not put extra spaces to format it well anymore. I concluded two reasons why it happened and posted a suggestion on perl.perl6.language but no one replied yet.

The two reasons (or, suggestion of changes) are:
  1. Spaces at beginning and end of rule blocks should be ignored since space before and after current rule are most likely be defined in rules using current one. (The spaces around the rule-level alternative could also be ignored).
  2. I am not sure the default rule of , I couldn't found it in S05. Currently the engine use :P5/\s+/ but I would like it to be :P5/\s*/ when it's before or after non-words and remains the same (\s+) otherwise.
I think these will help me formatting the grammar file better.