Sunday, May 28, 2006

May 28th, 2006 -- MiniPerl6 Finished Again

Continue on yesterday's work, I finished converting MiniPerl6 module so that it now work happily with ratchet.

The problem is that I used \w+ to match variable names but I should use [<alpha>|_]\w* instead (since the variables named with numbers are numbered captures, a special category). Another problem was hidden, or bypassed, by changing the order of alternations after I fixed the rule-using problem. It happened to be that the named capture parsing code in Pugs::Emitter::Rule::Perl5::Ratchet used a reference of boolean value in an "if" statement. I have to add another pair of ${} around it, at least before switching to Perl 6.

7 Comments:

Anonymous Anonymous said...

scw++ # congrats on SoC!!

I came up with a token for variable names that I was pretty happy with.

I can't use the named character class syntax in this example because the angle braces are parsed as illegal html tags (pre and code aren't allowed either =\ ). I'll use [alpha], but I really mean the one that goes < and then alpha and then >.

It is

token name {
[ [alpha] | _ ]+ [ [alpha] | \d | _ ]+ }

Feel free to look at src/Pugs/Parser/[Signature|Capture].pg if you're curious about other matching strategies I used.

Good luck,
/au

5/30/2006 10:51 PM  
Blogger Shu-Chun Weng said...

aufrank++

New rule committed!

5/30/2006 11:28 PM  
Anonymous Anonymous said...

Why the two '+'s? The first is harmless, of course, since anything it ate after the first character could just as well be eaten by the second... But the second methinks should be a '*', or else a token like 'a' is too short.

5/31/2006 4:38 PM  
Anonymous Anonymous said...

(summary:

token name {
[ [alpha] | _ ] [ [alpha] | \d | _ ]+*}

would make sense to me)

5/31/2006 4:41 PM  
Blogger Shu-Chun Weng said...

Yes, that's exactly what I used.

5/31/2006 4:42 PM  
Anonymous Anonymous said...

i am covered in embarrassment. i could swear i'd taken out that second '+', and didn't bother to preview. now you all get the benefit of my second and third thoughts, hurrah!

(summary:

token name {
[ [alpha] | _ ] [ [alpha] | \d | _ ]*}

would make sense to me)

5/31/2006 4:47 PM  
Anonymous Anonymous said...

all right, that anonymous was me of course, i'm done, i should stop posting at quarter to five in the morning.

5/31/2006 4:50 PM  

Post a Comment

<< Home