Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^4: Generate the perl sequence 1, 11, 111, ....

by moritz (Cardinal)
on Oct 11, 2008 at 12:03 UTC ( #716590=note: print w/replies, xml ) Need Help??

in reply to Re^3: Generate the perl sequence 1, 11, 111, ....
in thread Generate the perl sequence 1, 11, 111, ....

Use the source, Luke.
regex prefix_circumfix_meta_operator:reduce (--> List_prefix) { $<s> = ( '[' [ | <op=infix> ']' [''|<?>] | <op=infix_prefix_meta_operator> ']' [''|<?>] | <op=infix_circumfix_meta_operator> ']' [''|<?>] | \\<op=infix> ']' [''|<?>] | \\<op=infix_prefix_meta_operator> ']' [''|<?>] | \\<op=infix_circumfix_meta_operator> ']' [''|<?>] ] ) <?before \s | '(' > ...

So [\ is really a handled specially.

Or if you're not inclined to read the source, you can examine the match tree:

$ cat test.t [\~] 1..3 $ perl5.10.0 STD5_dump_match test.t comp_unit: statementlist: statement: EXPR: left: pre: prefix_circumfix_meta_operator: [\ op: ~ ] noun: value: number: integer: 1 infix: .. right: noun: value: number: integer: 3 \n
The output in a terminal is coloured, and much better readable. Basically you see that [\ is matched as a prefix_circumfix_meta_operator with the op: ~

Replies are listed 'Best First'.
Re^5: Generate the perl sequence 1, 11, 111, ....
by TimToady (Parson) on Oct 11, 2008 at 16:32 UTC
    Note however that the main reason those are handled separately is to deal with certain limitations in the autolexer. There's no reason the underlying reductions can't share most of their code, except for the bit that decides whether to return partial results.
Re^5: Generate the perl sequence 1, 11, 111, ....
by blazar (Canon) on Oct 11, 2008 at 18:20 UTC
    Or if you're not inclined to read the source, you can examine the match tree:

    I personally believe that this would indeed better be the case. Actually, I have eventually obtained an account on feather courtesy of Juerd and I wanted to experiment there. But I'm stuck again: what package is the STD5_dump_match script supposed to be part of, and where can I find it to the point of trying it myself? I presume that it's pugs. But then I expected to find it somewhere in ~audreyt/pugs given that the pugs executable itself on that machine is a link into that directory - however that doesn't seem to be the case. Or it may be a matter of permissions; whatever: any idea?

    Sorry for being so dumb: if nothing else I hope this may help some other people out there!

    If you can't understand the incipit, then please check the IPB Campaign.

      Sorry to the OP for going so far off-topic...

      You need to grab a copy of the pugs repository. In that repo you'll find the directory src/perl6/, in which you can find and STD5_dump_match.

      (If you take somebody else's checkout of the pugs repository please copy the perl6/ folder to your home directory, because you need write accessing for the lex cache).

      In that dir, type make, then you can use perl STD5_dump_match $file to print out a match tree.

      (You need a perl 5.10.0 in /usr/local/perl to run this, along with a few modules like re::engine::TRE, JSON::XS and Moose. I'll try to install all the dependencies on feather now.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://716590]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2018-02-18 22:58 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (257 votes). Check out past polls.