After the conversation below... I came to the following conclussion: $match = $souce ~~ //; should emit something like (perl 5); $match = (my $_MATCH = Perl6::Match->new(Grammar::Perl6->grammar($source))); 16/03/2006 When someone declares a grammar (which is like a package in Perl 5, right?) the rules are scoped to that Grammar. right? which is the syntax to load an external grammar and to match with some rule of that grammar? a grammar is just a class so Grammar::rule and use Grammar ; but remember that both exports are lexical and rules can be lexical my rule foo { } and rule foo is export { } hmmm ok... but if one wants to avoid the export and use it where it is Grammar::rule but only for 'our rule foo' or 'rule foo', not for 'my rule foo' but Grammar::rule is a subroutine call, isn't it? shouldn't it be Grammar.rule? ruoso: no, that invokes the class method 'rule' or the class rule 'rule' but all rules are instance methods on the match object now I'm confused okay here's how rules work in theory the domain specific language for rules is parsed into an AST defining rules which is mostly a lambda calculus ok this part I understood there are combinator rules, like +, (), and so forth ok the rule methods in perl space are perl wrappers that execute those ASTs the methods are invoked on the rule evalutor state object thing the match object which is like an interpreter env this match object contains: the current state the current match data various control structures etc and the rules-compiled-into-methods are invoked on it now, this is just at the semantic level the implementation may in fact compile the rules into a different language like PIR but at the seam it should always pretend to look like regular perl methods but... the match object isn't the return of a rule execution? that move match data around it's implied when you start a match then it constructs a new match object ah ok... and binds it to $/ the ~~ operator already starts the match and then starts executing the anonymous method right so rx:/..../ is an anonymous method this is just invoked on the $/ object $/ contains the input data too and the method will cause changes to the internal state pulling in input, accumilating oputput and backtracking so rx:/..../ will be compiled also yes it's essentially like saying 'my method { }' with no name but... now, what goes on inside is obviously different how can $/.rulexxx be invoked if rulexxx is defined in a external grammar? okay so the way this works is that all invocations on rulexxx etc are *normally* done as: rx:/ /; as a parallel to: $/.Grammar::rulexxx but i think $/.Grammar::rulexxx is not enough the API is not specced enough and there is a handwavy hole in the middle basically: do grammars inherit from Match? or does Match have a Grammar object that it internally invokes rules on? do it? this stuff isi underspecced we don't know that's what I'm hoping pX will sort out see Hierarchy.pod in docs this details all the parts I could think of that are either specced or not yet specced and is also missing parts which i couldn't think of ok... if you like, try to expand on the areas where the match/grammar lower level API can be detailed also luqui created Parse-Rule where? parse-rules is in misc somewhere, i think it's a proposition for the Match object interface that tries to make sure it can compile to many backend systems ruoso: sorry, it's in ext/ despite having just stubs nothingmuch, ok... <* ruoso> still wondering how "$match = Grammar::Perl6::grammar($source);" should look like in real perl 6 ruoso: explain I think it'll be something like my $c = Perl::Grammar::Compiler.new(); my $parse_tree = $c.parse( $rule_source ); # whatever hooks err, that's a parser, not a compiler and then it compiles depending on the backend either to Perl 6 or to PIR or to both depending on what can be done i have a billion ideas on this topic of compiling, if you want to talk about it later but i have to go now so $c.parse means "$c is the grammar object and parse is a rule" oh on that level i think you're forgettin ghtat rules need to be emitted and stuff if you have a single step parse-rule-syntax-and-execute method then there's not enough separation for later or do you mean something else? $c is the rule compiler and .parse is a method defined on the rule compiler this stuff is invoked by the Perl 6 compiler extension that handles the DSL for rules hmmm... for runtime rule compilation... ok.... but I don't have a single step but in this case, I'm using a pre-defined set of rules, that are already compiled... so... it would looks like: "$source ~~ //; $match = $/;" hmmm... better yet "$match = $source ~~ //;"