Belgi
Belgi

Reputation: 15082

Can an LL(0) language have more than one word in it?

I have the following simple question: If a language is LL(0), can it have more than one word in it ?

I think that the answer is no, since if there were two words, you can't read them to tell which one to derive

Upvotes: 1

Views: 1102

Answers (1)

Dewfy
Dewfy

Reputation: 23644

Let's start from definition:

An LL parser is called an LL(k) parser if it uses k tokens of lookahead when parsing a sentence

and definition of lookahead:

Lookahead establishes the maximum incoming tokens that a parser can use to decide which rule it should use.

Assume that your language is flow of random commands without any dependency between each other - then you can have as many words as you want.

EDITED Using bison notation:

%token A B
%start single

single: A | B;

So you don't need to lookahead at all, but this grammar includes 2 words A,B

Upvotes: 3

Related Questions