Re: Grammar First Set
- From: "Michael J. Fromberger" <Michael.J.Fromberger@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 10 Oct 2007 15:22:17 -0400
In article <1192037246.070904.264340@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
_nabuchodonozor <kkocemba@xxxxxxxxxxxxxx> wrote:
E' -> E $
E -> T N
N -> + T N | - T N |
T -> F M
M -> * F M | / F M |
F -> id | ( E )
Using the following grammar I have to compute the First(*FM).
I did sth like this but I think It is wrong:/
First(*FM) = First(*) U FIrst(F) U (First(M) - { })
= {*} U {id, ( } U ({*,/, } - { })
= {*, id, ( , / }
I read a lot of examples about it but I cannot understand this
subject:/ Could you tell me what I did wrong?
Please help me.
Sorry if it is a quastion not to this group
The FIRST set for a sequence <S> of grammar symbols is the set of
terminals that can appear as the first element of some string derived by
zero or more reductions from <S>. Any string derived from *FM, given
your grammar, must begin with *, since that is a terminal symbol.
On the other hand, if your sequence is FM, then since F is not nullable,
your first set would be ID and "(".
Taking the set union does not make sense in this example; you cannot
proceed past a symbol in the computation of first sets unless that
symbol derives the empty string.
Cheers,
-M
--
Michael J. Fromberger | Lecturer, Dept. of Computer Science
http://www.dartmouth.edu/~sting/ | Dartmouth College, Hanover, NH, USA
.
- References:
- Grammar First Set
- From: _nabuchodonozor
- Grammar First Set
- Prev by Date: Grammar First Set
- Next by Date: I'm confused: Turing machine model vs. interactivity
- Previous by thread: Grammar First Set
- Next by thread: I'm confused: Turing machine model vs. interactivity
- Index(es):
Relevant Pages
|