1. To start the programm as an applet a DemoParser.class should be used as an applet (see directory "classes"). There is a corresponding "index.html" file there, that calls the applet and puts README and project proposal on the page as well 2. To start the programm as an application "parser.class" should be called 3. All source codes are in the "source_code" directory parser.java | DemoParser.java | |--LexRulesInput.java | | | | | | | Lexicon.java | | | | | | | LexiconItem.java | | |--Input.java | | | | | |--InputItem.java | |---Rules.java | |--Non_Terminals.java | |--Parsing.java |-------Row.java |-------Backtrack_row.java |-------Good_Rule.java |-------TreeCanvas.java |-------TreeNode.java |-------RuleAndNodeDontMatchException.java 1. parser.java: starts applet DemoParser as an independent application 2. DemoParser.java: an applet that initializes and starts two subapplets: LexRulesInput.java (first frame) and Parsing.java (second frame); uses CardLayout layout manager to switch between both subapplets 3. LexRulesInput.java: an applet that initializes and starts three subapplets: Lexicon.java Rules.java Input.java uses GridbagLayout layout manager; 4. Lexicon.java: an applet responsible for managing lexicon; public boolean action(Event evt, Object whatAction): checks correctness of input, places warnings, adds, edits, delete lexicon items; private boolean wordOK(): checks that wordfield is not empty private boolean chooseOK(): checks that field for choosing the part of speech is not empty private boolean partOK(): checks that field for entering the part of speech is not empty private void warn_info1() - warnings about missing information private void warn_info2() (only items with word and speechpart private void warn_info3() can be added to the lexicon) private void set_init_state(): return the lexicon input fields to the initial state private void add_new_item1(): add new item=word+speechpart (from choice list) to the lexicon private void add_new_item2(): add new item=word+speechpart (from text field) to the lexicon public LexiconItem restore_LexItem(String word_speechpart): creates LexiconItem object from a Lexicon String 5. Rules.java: an applet responsible for managing rules; public boolean action(Event evt, Object whatAction): checks correctness of input, places warnings, adds, edits, delete rules items; public boolean ruleOK(): checks the correctness of the rule's form (left part and right part) and places warnings public void set_init_state(): return the rule input fields to the initial state public boolean rightOK(): right part must be not empty and consists of letters or digits public boolean leftOK(): left part must be not empty and consists of letters or digits public String restore_left(String rule): get the left part of the rule from the string containing left and right parts and the arrow between (this is always the form of rule's items in rule list) public String restore_right(String rule): get the right part of the rule public void check_and_order_rules(): checks the wellformedness and make top-down order all rules with initial symbol (only on the left side) are found (it can be more than one) then right part of each rule is checked and ordered: for each constituent on the right part there should be constituent on the left part or an item in lexicon protected int find_and_order_init_symbol(): protected boolean check_lexicon(String curr_const): look whether the constituent is terminal (is in lexicon) 6. Input.java: an applet responsible for processing user input; public boolean action(Event evt, Object whatAction){ removes old input: clean_old_stuff() checks whter there is an input from user processes and prints input places warnings protected boolean inputOK(): are there some words in input? protected boolean process_input(): read word by word and look in the lexicon for a part of speech protected String[] look_in_lexicon(String word): finds the same word in the lexicon and gets its parts of speech protected void print_input(Panel where_panel, InputItem[] all_input_items, int how_many_items): print_input - printing processed input in the table form inside applet will be used once again to repete input table on the parsing frame -> has wider usability public void clean_old_stuff(): 7. Parsing.java: an applet that parses user input according to the rules, draws tables and tree protected void set_init_values(): public boolean action(Event evt, Object whatAction): handles the button events: changes frames (shows first frame) makes one parsing step or the whole parsing prints tables draws tree do_piece_of_parsing(): the parsing programm itself: checks variable states and chooses parsing step to do protected void expansion(): 1)expands with given rule and 2)makes new row in the parsing table protected String expand_with(): finds the rule that schould be used for expansion protected boolean recognition():1)recognizes terminal and 2)makes new row in the parsing table protected boolean recognized(): tries to find the part of speech corresponding to the due symbol protected void backtracking(): takes the alternatives from the stack for checking protected void correct_good_rules(): responsible for keeping the array of rules really used by parser finds the next rule where backtracking begins (alternative point) and remove all rules behind it (bad rules, that are rejected) protected void correct_info_and_output(): updates information in parse_info and on the screen (parse_table) protected void remove_line(String line): removes uneeded line from the table protected String substitute_in_derivation(String derivation, String found_rule): replaces the due symbol (first left symbol in derivation) with the right part of the found good rule protected String new_due_symbol(String derivation): the fatherst left symbol in new string is new due symbol protected String cut_terminal(String derivation): removes recognized terminal constituents{ protected String due_symbol_status(): checks the due_symbol type: terminal, non-terminal or empty protected boolean is_left(): check whether a due_symbol is non_terminal (is found on the left side of the rule in tules list) protected void save_result(String[][] all_results, Vector good_rules): save good parse protected void show_results(int how_many_results): manages information on the tree pnael (parse was not found or tree was constructed) protected String[] make_set_of_rules(Vector good_rules): returns array of strings with all good rules (to give it as an argument to tree drawing function protected void redraw_tree(String[] rules): draws a tree according to the parse protected void create_output(): print the found parse in working table protected void print_stack(Stack what_stack, TextArea where_area): 8. public class TreeCanvas extends Canvas: class to draw a tree private TreeNode tree; private String recogn_input; public void DrawTree(TreeNode tree, Graphics g) public int DrawTree(TreeNode tree, int whereX, int whereY, Graphics g): draws the tree in a rectangle with the left upper corner (whereX,whereY) returns the actual position of the root in the drawn tree public void DrawNode(TreeNode node, int X, int Y, Graphics g): : draws the node -----------(X,Y)-------------- | T H I S N O D E | ------------------------------ public int tree_width(TreeNode tree, Graphics g): tree-width for subtrees: the space for the tree is the sum of those for the subtrees (with inter-tree gaps) or the space needed for the root nore if it is wider public int node_width(TreeNode node, Graphics g): determines the width needed for a node of a tree public int tree_width(): find the width of the whole tree public int tree_height(): find the height of the whole tree public int tree_height(TreeNode tree, Graphics g): tree_height for subtrees how much vertical space is needed (in pixels) public TreeNode build_tree(String[] rules): public TreeNode add_sons(TreeNode startnode, String[] rules, int i) throws RuleAndNodeDontMatchException: build a tree from the rules array rules[i..length-1] recursively find a right place to add sons (which are on the right part of the rule), for all rules public TreeNode next_node_to_handle(TreeNode curr_node): find next left node which is not endnode and has no sons (where sons have to be added) assumes that non-processed decendants do exist public boolean has_non_processed_nodes(TreeNode curr_node): checks if the tree has non-processed nodes node is non-processed if it is not an endnode and it has no sons public String find_node_content(String rule): get the left part of the rule node content public TreeNode[] find_sons(String rule): get the right part of the rule find sons - make an array of TreeNode's each with known node_content (constituent from the right part of the rule) and unknown sons