becoming-a-compiler-engineer icon indicating copy to clipboard operation
becoming-a-compiler-engineer copied to clipboard

设计一个RE和FA 来识别程序中代码的两段不连续的双引号

Open Levinethan opened this issue 3 years ago • 2 comments

在PL/I中,通过在一行连续写两个引号,可以向字符串中插入一个引号字符。因而下诉字符串 The code, " , should be typed 在PL/I中将写作 "The code," ",should be typed"

这道题是《编译设计》中第二章的一道题,我应该怎样设计RE和FA来识别?假定字符串以引号开始和结束,只包含取字字母表集中的符号。

Levinethan avatar Dec 29 '20 00:12 Levinethan

https://ftp.bmp.ovh/imgs/2020/12/a763d3fe8d238471.png 总觉得有些问题,不知道对不对 https://ftp.bmp.ovh/imgs/2020/12/0cd98cbb8eedcfaf.png

Levinethan avatar Dec 29 '20 01:12 Levinethan

如果是要在词法识别的时候识别引号字符串,那么在FA上也需要吃进去(吧)?

可以用 flex 写几行测试下。

另外如果是确定的 '' 根据程序的要求有可能有更简单的方法直接匹配字面量。

lazyparser avatar Dec 29 '20 23:12 lazyparser