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.
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:
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
aufrank++
New rule committed!
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.
(summary:
token name {
[ [alpha] | _ ] [ [alpha] | \d | _ ]+*}
would make sense to me)
Yes, that's exactly what I used.
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)
all right, that anonymous was me of course, i'm done, i should stop posting at quarter to five in the morning.
Post a Comment
<< Home