What is “Greedy Token Parsing”?

夙愿已清 提交于 2019-12-04 06:53:19

Suppose you want the character "a" to immediately follow the value contained in variable $var. If you write "$vara", that's not going to work because you don't have a variable $vara. The parser is greedy--it assumes that everything following $ should be included if it's legal syntax to include it. "${var}a" prevents that.

Greedy token parsing means that if a sequence of characters includes more than one possible token, the parser will accept the token with the most characters. If you use braces, the parser will stop at the brace, since it is not a part of a token.

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