Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: How does perl's lexer and parser cooperate?

by PerlOnTheWay (Scribe)
on Dec 26, 2012 at 14:56 UTC ( #1010393=note: print w/ replies, xml ) Need Help??


in reply to Re: How does perl's lexer and parser cooperate?
in thread How does perl's lexer and parser cooperate?

Dave, nice to see you again!

It seems GRAMPROG is not the only one that's special, I tried to search other symbols like ADDOP in toke.c

but it's never defined to "+" there.

where are these terminal symbols finally defined?


Comment on Re^2: How does perl's lexer and parser cooperate?
Select or Download Code
Re^3: How does perl's lexer and parser cooperate?
by dave_the_m (Parson) on Dec 26, 2012 at 15:54 UTC
    It seems GRAMPROG is not the only one that's special, I tried to search other symbols like ADDOP in toke.c but it's never defined to "+" there. where are these terminal symbols finally defined?
    I think you're misunderstanding how this works. ADDOP (and many of the others) don't correspond to actual terminal symbols like '+'. They are just numerical constants (ADDOP is defined as 305 in perly.h). yylex returns this value for multiple "addish" operator types, such as '+', '-', '.'; with extra info in the ival field indicating what op to use (such as OP_ADD, OP_CONCAT etc).

    Dave.

      Got it, thanks again!

      But I've got another doubt, what's the difference between ival&i_tkval, pval&p_tkval in YYSTYPE?

      update

      I've just checked other symbols like GRAMBLOCK,

      it should be parsed by Perl_parse_block in toke.c, which is called as parse_block ,

      but the strange thing is : they're never ever called from anywhere.

      so when will yyparse got token GRAMBLOCK from yylex ?

        what's the difference between ival&i_tkval, pval&p_tkval
        Not a lot. It's basically a hack to make perly.y function both normally and under -Dmad.
        they're never ever called from anywhere
        GRAMBLOCK etc are part of recently added parsing API. They're not called by normal perl parsing, only if someone directly calls one of the API functions such as parse_block().

        Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (17)
As of 2014-09-18 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (120 votes), past polls