Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有以下简单的问题:如果一种语言是 LL(0),它可以有多个单词吗?
我认为答案是否定的,因为如果有两个词,您无法通过阅读它们来判断要推导出哪个词
让我们从定义开始:
如果 LL 解析器在解析句子时使用 k 个前瞻标记,则称为 LL(k) 解析器
和前瞻的定义:
Lookahead 建立解析器可以用来决定它应该使用哪个规则的最大传入令牌。
假设您的语言是随机命令流,彼此之间没有任何依赖关系 - 那么您可以拥有任意数量的单词。
编辑 使用野牛符号:
%token A B %start single single: A | B;
所以你根本不需要前瞻,但是这个语法包括 2 个单词 A,B