[Parrot-users] A few questions about grammar generated by create_language.pl

Hugo Arts hugo.yoshi at gmail.com
Sun Feb 28 09:15:16 UTC 2010


Hi,

I've been looking at the Grammar.pm file generated by
create_language.pl for a while now, read synopsis 5, and I can mostly
make sense of it now. There's a few details, however, that I would
like to have some clarity on:

1) The <EXPR> subrule is used a few times, but I'm not clear on
exactly what it means. I assume it somehow incorporates the "token
term" as well as the circumfix/infix/etc. operator tokens, but I'm not
sure exactly how this works.

2) token quote:sym<"> { <?["]> <quote_EXPR ':qq'> }
If I'm correct, the first part of that rule is simply a zero-width
assertion that the first character is a double quote. The quote_EXPR,
I assume, is a rule that actually parses a quoted string. Why is the
assertion included? Doesn't quote_EXPR assert the expression is within
quotes anyway?

3) the <integer> subrule seems to parse decimal, binary, and hex
numbers. What about octal? I've tried prefixing with 0, o, and 0o
prefixes, but those all throw syntax errors.

4) What exactly is the definition of <ident>? It is mentioned many
times in the perl 6 synopse, but I seem to have missed its definition.
My experiments lead me to believe it's something like: token ident { [
<alpha> | '_' ] \w* } (that would be consistent with what an
identifier is in most languages)

5) token circumfix:<( )> { '(' <.ws> <EXPR> ')' }
is this the same as { '(' ~ ')' [ <.ws> <EXPR> ] } ? If not, what is
the difference? And another question, why is there no <.ws> after
<EXPR>? Does the <EXPR> rule take care of that?

6) Grammar.O(':prec<u>, :assoc<left>', '%multiplicative')
what does the prec<u> mean? I assume it's something to do with
precedence, but what the 'u' argument means is not clear to me.

Thanks in advance,
Hugo


More information about the Parrot-users mailing list