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

Handle first run of matlab parsing.

The system can now sucessfully parse simple matlab expressions.  It has appropriate
tests for these expressions.  Next is integration.


git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_javization@9650 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent daf5a559
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ public class App
{
    public static void main( String[] args )
    {
        String[] args2 = {"ca.mcmaster.cas.matlab2smt.Matlab", "statement", "-tree"};
        String[] args2 = {"ca.mcmaster.cas.matlab2smt.MatlabParser", "expression", "-tree"};
        try {
            TestRig.main(args2);
        } catch (Exception ex) {
+8 −0
Original line number Diff line number Diff line
@@ -15,6 +15,14 @@ final class MatlabExpressionOperation implements MatlabExpression {
        m_op = op;
    }
    
    void setLHS(MatlabExpression expr) {
        m_lhs = expr;
    }
    
    void setRHS(MatlabExpression expr) {
        m_rhs = expr;
    }

    @Override
    public VariableType type() {
        VariableType lhs_type = m_lhs.type();
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ package ca.mcmaster.cas.matlab2smt;
 *
 * @author matthew
 */
public final class MatlabLiteral implements MatlabExpression {
public final class MatlabLiteral implements MatlabExpression, MatlabExpressionValue {

    public MatlabLiteral(String value) {
        m_value = value;
+12 −1
Original line number Diff line number Diff line
@@ -9,7 +9,18 @@ package ca.mcmaster.cas.matlab2smt;
 * @author matthew
 */
enum MatlabOperation {
    Addition("+");
    Addition("+"),
    GreaterThen(">");

    static MatlabOperation getOpForSymbol(String text) {
        if(text.equals("+")) {
                return Addition;
        } else if(text.equals(">")) {
                return GreaterThen;
        } else {
                throw new IllegalArgumentException("No such matlab operation defined!");
        }
    }

    MatlabOperation(String CVC3Version){
        m_CVC3Version = CVC3Version;
+7 −3
Original line number Diff line number Diff line
grammar Matlab;
grammar MatlabParser;

/*

@@ -386,14 +386,18 @@ unary_expression

base_expression
	: id_plus_indexers
	| INT
	| FLOAT
	| literal_number
	| STRING
	| anon_func_handle
	| cell
	| matrix
	;

literal_number
        : INT
        | FLOAT
        ;

/*
XXX ANONYMOUS EXPRESSION AMBIGUITIES

Loading