yytext [0]是什么意思? [英] What is the meaning of yytext[0]?

查看:303
本文介绍了yytext [0]是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

yytext [0]是什么意思?以及为什么要在lex和yacc程序中使用?我是学习者,所以不要介意这是一个愚蠢的问题.

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.

推荐答案

yytext保存与当前标记匹配的文本.因此yytext [0]保留了与当前标记匹配的文本的第一个字符.有时,您有一条规则可以匹配不同的文本,因此您需要像匹配变量名一样获得匹配的真实文本,或者有一条规则可以匹配所有算术运算.

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.

Flex手册是一个很好的来源.

对于初学者来说,最好的起点是尝试示例项目.

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

这篇关于yytext [0]是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆