meta data for this page
  •  

This is an old revision of the document!


An expansion's first set is simply the set of all tokens that can begin the expansion.

The most trivial example imaginable is any expansion that begins with a single token. Thus, the first set of:

    "foo" "bar" "baz"

is simply a set with one element, “foo”.

The first set of

    ("foo" | "bar") "baz"

has two elements, “foo” and “bar”. The above expansion can only begin with one of those two tokens.

For example, if the production

and the production Foobar is:

    Foobar : "foo" | "bar";

then the first set of the expansion:

     [ Foobar ] "baz"

contains the three tokens, “foo”, “bar” , and “baz. To say that a grammar is LL(1) is equivalent to saying that, at any choice point the expansion's first set is enough to decide whether or not to enter the expansion.

then the expansion F