Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Open season on official Perl 6 grammar

by zejames (Hermit)
on Dec 21, 2004 at 16:03 UTC ( #416510=note: print w/replies, xml ) Need Help??

in reply to Open season on official Perl 6 grammar

Dear monks,

I think that is great, as the more work there is on Perl 6, the sooner we'll be able to have a precise view of what it will be, and the broader audience it will reach.

However, I've got a basic question for all the compiler and grammar experts out there : how can the Perl 6 grammar be written in Perl 6 ? Is this just a first try, that will be converted to another tool later ? Will it be generated from a cpan Perl6 module ? It seems like it is an hen and egg problem...

Anyone to enlight the ignorant monks like me ?

  • Comment on Re: Open season on official Perl 6 grammar

Replies are listed 'Best First'.
Re^2: Open season on official Perl 6 grammar
by duff (Parson) on Dec 21, 2004 at 16:16 UTC

    The first-cut grammar engine is written in C to parse a subset of Perl6 rules (some of the advanced features have been left out). This grammar engine will be used to parse the Perl6 grammar and do something useful (like output code for the perl6 compiler (which will, oddly enough, contain a perl6 rules parser :-)).

Re^2: Open season on official Perl 6 grammar
by Anonymous Monk on Dec 21, 2004 at 16:27 UTC
    how can the Perl 6 grammar be written in Perl 6 ?
    C compilers are written in C, there are Java compilers written in Java, there are Scheme compilers written in Scheme, there are Pascal compilers written in Pascal.

    Why wouldn't it be be written in Perl6?

      That is true, except for the first C, Java or Scheme compiler. And in our case, this is the first Perl6 compiler.

        Actually you'd be wrong.

        The first interpreter that I know of for the first interpreted language (a dialect of Lisp) was first written in itself. And then that program was hand-translated to assembly. (The person who wrote the interpreter did not intend to see it ever run!)

        Likewise C compilers like gcc are frequently written in C. To develop a compiler for a new hardware platform you modify an existing compiler to understand the necessary assembly language, then you compile a C compiler for the new platform.

        The Squeak interpreter (Squeak is a type of Smalltalk) demonstrates an interesting variation of this strategy. Squeak is written in Squeak. But it comes with a program that can compile itself to a C++ program which, when run, recreates the original Squeak image.

        As all of these examples show, it is often nice to write a language in the language that you're writing. Once you have it written, actually making it run requires some bootstrapping, but the bootstrapping process is usually much easier than writing your full program from scratch.

        This is doubly true if you want to wind up with a language (like Perl 6) where you want to end up with a lot of hooks within the language to be able to manipulate the language behaviour. If you bootstrap then you don't have to draw so many fairly arbitrary internal distinctions between when you're looking at user-changed behaviour and native built-in behaviour.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2022-11-26 08:45 GMT
Find Nodes?
    Voting Booth?