Commit 4d5ae5bc authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Add initial support for CVC3 file generation in java.

Parse the hierarchy for the tables to generate the necessary bits of CVC3
code.  It generates equivalent code for CVC3 now to what matlab would.  Some
excess brackets are removed, making things neater.

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_javization@10650 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 62f90c24
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.tablularexpression;

/**
 *
 * @author Matthew Dawson <matthew@mjdsystems.ca>
 */
public class Cell {
    Cell() {}
    Cell(String initialContents) {
        m_contents = initialContents;
    }
    
    public void setContents(String contents) {
        m_contents = contents;
    }
    
    public String contents() {
        return m_contents;
    }
    
    private String m_contents;
}
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 Matthew Dawson <matthew@mjdsystems.ca>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ca.mcmaster.cas.tablularexpression;

/**
 *
 * @author Matthew Dawson <matthew@mjdsystems.ca>
 */
public interface HierarchcialGridCheckerGenerator {
    void descendIntoGridFromCell(Cell cell);
    void ascendFromGrid();
    
    void handleLeafCell(Cell cell);
    void handleEdgeCell(Cell cell);
    
    String getFinalString();
}
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2013 Matthew Dawson <matthew@mjdsystems.ca>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ca.mcmaster.cas.tablularexpression;

import java.util.List;
import java.util.ListIterator;

/**
 *
 * @author Matthew Dawson <matthew@mjdsystems.ca>
 */
public class HierarchcialGridCheckerWalkerGenerator {
    
    private static void HandleGrid(SubHierarchyFetcher grid, HierarchcialGridCheckerGenerator generator) {
        List<HierarchicalCell> cells = grid.getSubHiearchy();
        for (int i = 0; i < cells.size(); ++i) {
            HierarchicalCell cell = cells.get(i);
            
            if (cell.getSubHiearchy().isEmpty()) {
                generator.handleLeafCell(cell);
            } else {
                generator.handleEdgeCell(cell);
            }
        }
        
        for (int i = 0; i < cells.size(); ++i) {
            HierarchicalCell cell = cells.get(i);
            
            if (!cell.getSubHiearchy().isEmpty()) {
                generator.descendIntoGridFromCell(cell);
                HandleGrid(cell, generator);
                generator.ascendFromGrid();
            }
        }
    }
    
    public static String GenerateCheckerFromGrid(HierarchicalGrid grid, HierarchcialGridCheckerGenerator generator) {
        HandleGrid(grid, generator);
        return generator.getFinalString();
    }
}
+26 −0
Original line number Diff line number Diff line
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.tablularexpression;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Matthew Dawson <matthew@mjdsystems.ca>
 */
public class HierarchicalCell extends Cell implements SubHierarchyFetcher {
    public HierarchicalCell() {}
    public HierarchicalCell(String initialContents) {
        super(initialContents);
    }

    @Override
    public List<HierarchicalCell> getSubHiearchy() {
        return m_subHiearchy;
    }
    
    private List<HierarchicalCell> m_subHiearchy = new ArrayList<HierarchicalCell>();
}
+21 −0
Original line number Diff line number Diff line
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ca.mcmaster.cas.tablularexpression;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Matthew Dawson <matthew@mjdsystems.ca>
 */
public class HierarchicalGrid implements SubHierarchyFetcher {
    @Override
    public List<HierarchicalCell> getSubHiearchy() {
        return m_subHiearchy;
    }
    
    private List<HierarchicalCell> m_subHiearchy = new ArrayList<HierarchicalCell>();
}
Loading