What is the meaning of yytext[0]?

十年热恋 提交于 2019-12-07 10:33:11

问题


What is the meaning of yytext[0]? And why should we use in the lex and yacc program? I'm learner so don't mind if it is a silly question.


回答1:


yytext holds the text matched by the current token. So yytext[0] holds the first character of the text matched by the current token. Sometimes you have a rule which can match different texts so you need to get the real text matched like for variable names or you have a rule to match all arithmetic operations.

A good source is the Flex manual.

For beginners the best starting point is trying the sample projects.



来源:https://stackoverflow.com/questions/33842818/what-is-the-meaning-of-yytext0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!