How does the parser work?

Hal Murray halmurray at sonic.net
Mon Dec 4 23:03:52 UTC 2023


James said:
>    The host phase of Waf build generates tablegen which in turn generates
>    keywords.h IIRC. I have no idea how the internals work.

I took a look at the code.

It looks like there are 2 tables of keywords, one in ntp_keyword.h (build by 
keyword-gen) and another in ntp_parser.y.  Because the tokens in each table 
look so similar, my brain jumped to the conclusion that they were parallel.  
Wrong.

The values of the corresponding tokens are different.  I don't know how the 
values from the keyword table get translated into parser values.

The parser table also has a few extra entries like integer and string.


keyword.h is more than just a list of keywords.  It's also table/tree of steps 
along the way of recognizing a keyword:
  S_ST( 's',    3,      675,   422 ), /*   674 tru               */
  S_ST( 't',    3,      676,     0 ), /*   675 trus              */
  S_ST( 'e',    3,      677,     0 ), /*   676 trust             */
  S_ST( 'd',    3,      678,     0 ), /*   677 truste            */
  S_ST( 'k',    3,      679,     0 ), /*   678 trusted           */
  S_ST( 'e',    3,      423,     0 ), /*   679 trustedk          */


Anyway, I think extra "keywords" in the parser table are just useless.  The 
parser will never get there because the keyword table doesn't know about them.

When we run out of better things to do, we should make a config file that uses 
all the keywords so we can make sure they work and are all useful.



-- 
These are my opinions.  I hate spam.





More information about the devel mailing list