Need a program that reads in a description of a context free grammar, then outputs the FIRST sets for all non-terminals in the grammar

Need a program that reads in a description of a context free grammar, then outputs the FIRST sets for all non-terminals in the grammar

Need a program that reads in a description of a context free grammar, then outputs the FIRST sets for all non-terminals in the gramma

Write, in Java (Lab2.java), a program that reads in a description of a context free grammar, then outputs the FIRST sets for all non-terminals in the grammar.
The input grammar will be given on input file (line argument passed), and your program
should output to standard output (console / stdout).
Grammar Description
 All grammar symbols are case-sensitive and whitespace-separated.
 The first line of the input file lists all the non-terminals of the grammar.
 The first non-terminal in the list is the start symbol of the grammar.
 Symbols that appear in the grammar other than non-terminals are terminals.
 Production rules are seperated by the newline symbol \n. (One rule per one line.)
 A production rule starts with a non-terminal symbol (the left-hand side) followed
by ->, then followed by a sequence of zero of more terminals and non-terminals,
which represent the right-hand side.
 If the right-hand side of a rule is empty, then this represents a rule of X ! .
Input File Example
program stmt_list stmt expr term_tail term …
program -> stmt_list $$
stmt_list -> stmt stmt_list
stmt_list ->
stmt -> id := expr
stmt -> read id
stmt -> write expr

Output
Use eps as the meaning of the empty string
FIRST(program)={eps,id,read,write}
FIRST(stmt_list)={eps,id,read,write}
FIRST(stmt)={id,read,write}

[Extra credits] Write, in Python in python 2.7 (Lab2.py), a program that reads in a description
of a context free grammar, then outputs the FIRST sets for all non-terminals
in the grammar. The input grammar will be given on input file (line argument passed),
and your program should output to standard output (console / stdout).

Remark
 You may assume the test input file is error-free.
 You may refer the algorithm in Figure 2.24 of the text book. However, you are required
to add eps into FIRST(X) if EPS(X) is true.
USE a console argument to pass an input file, i.e. argv[1], instead of user input.

File #1
File #2
program stmt_list stmt expr term term_tail factor factor_tail add_op multi_op
program -> stmt_list $$
stmt_list -> stmt stmt_list
stmt_list ->
stmt -> id := expr
stmt -> read id
stmt -> write expr
expr -> term term_tail
term_tail -> add_op term term_tail
term_tail ->
term -> factor factor_tail
factor_tail -> multi_op factor factor_tail
factor_tail ->
factor -> ( expr )
factor -> id
factor -> number
add_op -> +
add_op -> –
multi_op -> *
multi_op -> /

Order from us and get better grades. We are the service you have been looking for.