29.04.2015 Views

Top-down Parsing (ASU Ch 4.4) Predictive Parsers (ASU 4.4 ...

Top-down Parsing (ASU Ch 4.4) Predictive Parsers (ASU 4.4 ...

Top-down Parsing (ASU Ch 4.4) Predictive Parsers (ASU 4.4 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

First and Follow Sets (<strong>ASU</strong> <strong>Ch</strong> <strong>4.4</strong>)<br />

• first(X)<br />

– if X is T first(X) is { X }<br />

– if X ¤ in P first(X) += ¤ (¤ = empty)<br />

– if X is NT and X Y 1 Y 2 Y 3 …Y n in P<br />

• first(X) += a if a in first(Y i ) and ¤ in first(Y 1 ) … first(Y i-1 )<br />

– i.e. Y 1 Y 2 Y 3 …Y i-1 ¤<br />

– if ¤ in first(Y 1 ) … first(Y k ) first(X) += ¤<br />

– first(X) += first(Y 1 ) if not Y 1 ¤<br />

– first(X) += first(Y 2 ) if Y 1 ¤ and not Y 2 ¤<br />

– and so on ...<br />

– continued on next slide<br />

8<br />

14/10/2014 DFR - CC - TDP

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!