I know this may seems like a overkill, but I just want it to be clear to at least myself
- A tuple contains two elements:
- a
string
representing the name of the nonterminal - a
list
of all productions of that nonterminal (alist
also)
- a
- Example:
- For TT -> ao T TT | epsilon, the
symbol_productions
would be:("TT", [["ao"; "T"; "TT"]; []])
- For TT -> ao T TT | epsilon, the
- A
list
ofsymbol_productions
- (string * string list list) list
- Consists of
symbol_productions
for all of the nonterminals
- (string * (string list * string list) list) list
- A
list
of tuples containing two things:- A
string
representing the name of the nonterminal - Another
list
of tuples containing: - A
list
ofstring
representing the PREDICT set of the nonterminal - A
list
ofstring
representing the corresponding rhs of the production
- A
A parse_table example
[
("P", [(["id";"read";"write";"$$"],["SL";"$$"])]);
("SL", [(["id";"read";"write"], ["S";"SL"]);
("$$",[])]);
("S", [(["id"],["id";":=";"E"]);
(["read"],["read";"id"]);
(["write"],["write";"E"])]);
...
]
- (string * string list) list
- A
list
of tuples containing:- A
string
representing a nonterminal (context) - A
list
ofstring
representing the FOLLOW set
- A
- type used in
get_right_context
function as a return type, more details are explained in the description ofget_right_context
- A 4-element tuple:
- nonterminal :
string
- nullable? :
bool
- FIRST set :
string list
- FOLLOW set :
string list
- nonterminal :
- Example:
- for nonterminal P, the
symbol_knowledge
would be:("P", false, ["$$"; "id"; "read"; "write"], [])
- for nonterminal SL, the
symbol_knowledge
would be:("SL", true, ["id"; "read"; "write"], ["$$"])
- for nonterminal P, the
- A list of
symbol_knowledge
- A parse tree structure
- PT_nt | PT_term | PT_id | PT_num | PT_err
- For an example, please see parse_tree_example.txt
- either a
int
or astring
- PS_end :
int
- PS_sym :
string
- PS_end :
- The extended version of the grammar
to be done by tomorrow...