@@ -0,0 +1,1991 @@
+package mohsen;%0A%0A%0Aimport java.util.ArrayList;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0Apublic class CYK %7B%0A    Grammar grammar;%0A%0A%0A    public CYK(Grammar grammar) %7B%0A        this.grammar = grammar;%0A    %7D%0A%0A    public Result canGenerate(String statement) %7B%0A        HashSet%5B%5D%5B%5D matrix = new HashSet%5Bstatement.length()%5D%5Bstatement.length()%5D;%0A        char%5B%5D statementArray = statement.toCharArray();%0A%0A        /**%0A         * Initializes the matrix sets%0A         */%0A        for (int i = 0; i %3C statement.length(); i++)%0A            for (int j = 0; j %3C statement.length(); j++)%0A                matrix%5Bi%5D%5Bj%5D = new HashSet();%0A%0A        //%0A        for (int i = 0; i %3C statement.length(); i++) %7B%0A            ArrayList%3CString%3E gens = grammar.getGenerators(statementArray%5Bi%5D + %22%22);%0A            if (gens != null)%0A                for (String s : gens)%0A                    matrix%5Bi%5D%5Bi%5D.add(s);%0A        %7D%0A%0A        for (int step = 1; step %3C statement.length(); step++) %7B%0A            int i = 0;%0A            for (int j = step; j %3C statement.length(); j++) %7B%0A                for (int k = i; k %3C j; k++) %7B%0A                    Set%3CString%3E muls = multiplySets(matrix%5Bi%5D%5Bk%5D,matrix%5Bk+1%5D%5Bj%5D);%0A                    for (String s : muls)%7B%0A                        ArrayList%3CString%3E gens = grammar.getGenerators(s);%0A                        if(gens != null)%0A                            for (String s2 : gens) %7B%0A                                matrix%5Bi%5D%5Bj%5D.add(s2);%0A                            %7D%0A                    %7D%0A                %7D%0A                i++;%0A            %7D%0A        %7D%0A%0A%0A        boolean status = matrix%5B0%5D%5Bstatement.length() - 1%5D.contains(grammar.getFirstState());%0A        return new Result(matrix,status);%0A    %7D%0A%0A    private HashSet%3CString%3E multiplySets(HashSet%3CString%3E first, HashSet%3CString%3E second)%7B%0A        HashSet%3CString%3E result = new HashSet%3CString%3E();%0A        for (Object s1 : first)%0A            for (Object s2 : second)%0A                result.add((String)s1 + (String)s2);%0A        return result;%0A    %7D%0A%7D%0A

Create CYK.java