2 Replies - 611 Views - Last Post: 17 October 2016 - 07:20 AM

#1 zerocool18  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 186
  • Joined: 12-October 12

first and the follow (compilers)

Posted 17 October 2016 - 04:09 AM

hopefully soone can help me with this lol , this grammar im looking at is kinda tricy and i feel like theres something im missing. im trying to find the first and follow of the below grammar
S -> [] | [S] | SS


For the first I got:
First(S) = [


and
follow(S) = $,[


something doesnt feel right , like i know theres something with the last production (SS) that im missing.

This post has been edited by Skydiver: 17 October 2016 - 07:19 AM
Reason for edit:: Put grammar in code tags to protect the square brackets.


Is This A Good Question/Topic? 0
  • +

Replies To: first and the follow (compilers)

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2504
  • View blog
  • Posts: 3,956
  • Joined: 21-June 11

Re: first and the follow (compilers)

Posted 17 October 2016 - 07:15 AM

Your First is right. [ definitely appears at the beginning and ] never does. There's also no empty production. So [ is the only that belongs in the First set, as you wrote.

For your Follow set you did miss something, but not in SS. Consider instead the production S -> [S]. What's following S here?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5824
  • View blog
  • Posts: 19,835
  • Joined: 05-May 12

Re: first and the follow (compilers)

Posted 17 October 2016 - 07:20 AM

As a quick aside, please make sure to put your grammar in [code] tags so that any of square brackets that you maybe using will be protected, and not interpreted by the forum software as BB codes.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1