-------------------------------------------------------------------- -- a4types.ads -- This file is the specification file for the types -- and functions used in the DFA simulation -- of Assignment 4. -------------------------------------------------------------------- with TEXT_IO; use TEXT_IO; package a4types is -- These are the record types and access types -- used by the test program type terminal is private; type nonterminal is private; type rule_ptr is private; type dfa_ptr is private; type grammar_ptr is private; -- These are the procedures and functions used -- in the test program -- These functions substitute for constructors, giving -- a little more control over the initialization, etc. -- The first function creates an empty grammar. -- The second and third create representations of -- rules of a nonregular grammar given a nonterminal -- for the left-hand side, a terminal for the right-hand -- side, and perhaps a nonterminal for the right-hand -- side. -- The fourth creates a representation of a DFA given -- a pointer to a regular grammar. -- The last two functions convert strings to nonterminals -- and characters to terminals respectively. function make_grammar return grammar_ptr; function make_rule(l:nonterminal; t:terminal) return rule_ptr; function make_rule(l:nonterminal; t:terminal; r:nonterminal) return rule_ptr; function build_DFA(g:grammar_ptr) return dfa_ptr; function make_nonterminal(s:string) return nonterminal; function make_terminal(c:character) return terminal; -- This is the only mutator used in the test program. -- It adds a rule to a given grammar. procedure add_rule(g:grammar_ptr; rr:rule_ptr); -- And this is the procedure to test a DFA on a given string. -- Note that it is not a function. procedure test_string_and_print(d:dfa_ptr; inp:string); private -- your type definitions go here -- (and your other definitions go into an *.adb file) end a4types;