On Sat, Jun 08, 2002 at 09:59:10AM -0700, Larry Wall wrote: > On Fri, 7 Jun 2002, Peschko, Edward wrote: > : Let me get this straight. the grammar of Perl is reprogrammable, > : and expressed in perl6. And a script is parsed using this grammar, > : on the fly, hence portions of scripts could have different grammars > : than other parts. > > Where have you been for the last two years? This is not news.
ok, ok, s/Perl/regex/. I was always assuming the regular expression parser and the perl parser would be different beasts. Guess not. And anyways, its much more disconcerting when you actually *see* the grammar being reparsable as opposed to hearing it in the abstract. I guess it just shows how old school I am - I was sort of assuming a yacc/script distinction. > No, the standard parser will be distributed as Parrot machine code. > This is a conventional language bootstrap on an unconventional machine. Ok, fair enough. The parrot bytecode compiler compiles the script using the standard parser. Doing this, hooks inside the standard parser pick up any 'grammar' objects inside a given { . . . } block, and then re-interpret the code inside the { . . . } block to be parsed in a different way. My question(s): The parsing of perl 6 is the application of a huge, compiled, regex, correct? In order to parse the new syntax, perl6 is going to have to compile the new rule, and stick it in the place of the old one, for the duration of the scope, right? Now what happens to the parser at large if you have dependencies on what has changed - ex: if you change the rule for brackets, say so that all '[' are now actually '[[' and all ']' are now ']]'. Won't the whole regex for parsing perl need to be recompiled for the duration of the block, or at least the dependencies on the things that you changed? And won't *that* be slow and/or memory intensive? And if the rules are somehow abstracted in the perl6 parser/parrot/regex engine ,so that each 'rule' is in essence a pointer to the real code corresponding to interpreting that rule (so it can be replaced easily by user defined ones) - well won't that abstraction hurt the performance of parsing regular perl? And finally, if the regular expressions are in bytecode to get this flexibility as opposed to native machine code, what sort of overhead will this impose on the regex engine? I know the above might be a bit simplistic, and since its an implementation question I'm posting to perl6-internals instead, but the post is more for the point of clarification about what's going on than anything else. I'd love to see this happen, would use it all the time.. Ed