Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Perl 6 and Perl 5 parsing

by moritz (Cardinal)
on Jan 14, 2011 at 18:37 UTC ( [id://882387]=note: print w/replies, xml ) Need Help??


in reply to Perl 6 and Perl 5 parsing

So how exactly is this done?

Perl 6 named regexes are basically just methods in classes, which we call "grammars".

A grammar modification creates a "slang" (short for sub language). The grammar modification is encapsulated in a role, and the process of modifying the grammar is "just" mixing the role into the current grammar object.

That's the technical side. The user-facing side is that a Perl 6 grammar is indeed mutable, but the mutations are always well declared, and always contained to a lexical scope.

Such a declaration usually looks like use SomeModule; or macro ... or augment slang ...

I mean to say willn't it suffer from the same problem.

Which problem exactly are you referring to? The fact that you can't parse Perl without running it?

If yes, the bad news is that that's indeed still true, and the good news is that it's easier to know if an attempt to statically parse a Perl 6 source file has been successful, or has been foiled by grammar modifications.

I can't take the bytecode alone and run it, I will always need the parser along with it

That's only the case if you call eval(). As masak already explained, parsing happens at compile time, and running the code at run time. So while you need a run time environment for parsing, you don't need the parser at run time. Once the code is parsed, it will never be reparsed in a different way.

In fact rakudo already demonstrates that today: you can compile a source file to various intermediate formats, and then run these files (including executables) without the parser being called.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://882387]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-25 20:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found