Find the follow sets
Perl, 257 bytes

Includes +4 for -0p

Give grammar on STDIN (without trailing spaces. Make sure to remove the extra space in the second example). Assumes non-terminal names only contain letters, digits and _. Uses # instead of $ to indicate end of input. Can handle literals containing spaces

perl -M5.010 follow.pl
E T e
e '+' T e
e
T F t
t '*' F t
t
F '(' E ')'
F 'id'
^D


Outputs the follow sets as a list of non-terminal literal in no particular order. For the example above it outputs:

F ')'
F #
t ')'
t #
T ')'
T #
F '+'
t '+'
T '+'
F '*'
e ')'
e #
E ')'
E #


follow.pl:

#!/usr/bin/perl -0n
s/'.*?'/~$&amp;/eg;s% (?=(\w.*\n))%$_.="&gt;$1"%reg;/\s/;$_.="&gt;$` #\n";s%^((\w+)\K ?\S*).*%$s{$1}++||"\$a.=s/ $2\\b/$&amp;/rg"%eemgr,s%^(\w+ ).*?(\w+)$%"\$a.=s/&gt;$1/&gt;$2 /rg"%eermg,$_.=$a,s%&gt;.*\xd8\K .*%%g,s%.+\n%$&amp;x!/\n$&amp;/g%eg until$$_++;s/\xd8.*?\xd8/~$&amp;/eg;say/&gt;(\w+ \W\S*\n)/g


Works as shown, but replace \xd8 and \n by their literal versions to get the claimed score. 

It should be possible to improve this since converting the first sets to the follow sets is currently very awkward.