使用 lex 和 yacc 解析配置文件
global{
verb
test
rl0
rand (or) rand =0 [Two cases]
}
thread{
frac_value = (0.2,(0.1,0.5))
random_thread
}
输出应该是这样的:
如果我将上述输入提供给 lex 和 yacc,基于 [ rand (or) rand=0 ] 的检查,
- 如果它是“rand”,那么它应该打印为“ verb test rl0 rand frac_value:L =0.1 frac_value:H=0.5"
- 如果是 "rand=0",那么它应该打印为 " verb test rl0 rand=0压裂值=0.2”。
为此,有人可以告诉我如何编写 lex 和 yacc 程序。
global{
verb
test
rl0
rand (or) rand =0 [Two cases]
}
thread{
frac_value = (0.2,(0.1,0.5))
random_thread
}
OUTPUT should be this:
If i give the above input to lex and yacc, based upon the checking of [ rand (or) rand=0 ]
- if it is "rand", then it should print as " verb test rl0 rand frac_value:L=0.1 frac_value:H=0.5"
- if it is "rand=0", then it should print as " verb test rl0 rand=0 frac_value=0.2".
For this could someone please tell me how to write a lex and yacc program.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您会问:“为此,有人可以告诉我如何编写 lex 和 yacc 程序吗?”
这是一个相当广泛的主题,太大了,无法在 Stack Overflow 上用几段文字来涵盖。我建议阅读一本关于 lex 和 yacc 的书,例如:http://shop.oreilly。 com/product/9781565920002.do
You ask: "For this could someone please tell me how to write a lex and yacc program"
This is a pretty broad topic, far too large to be covered in a few paragraphs on Stack Overflow. I suggest reading a book on lex and yacc, such as this one: http://shop.oreilly.com/product/9781565920002.do