mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-17 17:04:42 -04:00
added some comments
This commit is contained in:
parent
ba4df394cb
commit
b5a152d83a
@ -12,6 +12,11 @@ public class ComplexityInclNotVisitor implements ExpressionVisitor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a measure for the complexity of the examined expression
|
||||
*
|
||||
* @return the complexity
|
||||
*/
|
||||
public int getComplexity() {
|
||||
return counter;
|
||||
}
|
||||
|
@ -13,6 +13,12 @@ public class ComplexityVisitor implements ExpressionVisitor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a measure for the complexity of the examined expression
|
||||
* The Not expression does not increase this complexity measure
|
||||
*
|
||||
* @return the complexity
|
||||
*/
|
||||
public int getComplexity() {
|
||||
return counter;
|
||||
}
|
||||
|
@ -9,10 +9,22 @@ public class Variable implements Comparable<Variable>, Expression {
|
||||
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* Creates a new Variable
|
||||
*
|
||||
* @param name the variables name
|
||||
* @return the new Variable
|
||||
*/
|
||||
public static Variable v(String name) {
|
||||
return new Variable(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an array of variables
|
||||
*
|
||||
* @param n the number of varfiables to create.
|
||||
* @return variables named "A0", "A1", "A2" and so on
|
||||
*/
|
||||
public static ArrayList<Variable> vars(int n) {
|
||||
ArrayList<Variable> v = new ArrayList<Variable>();
|
||||
for (int i = 0; i < n; i++)
|
||||
@ -20,6 +32,12 @@ public class Variable implements Comparable<Variable>, Expression {
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a list of variables using the given names
|
||||
*
|
||||
* @param names the names used to create the variables
|
||||
* @return the list of variables
|
||||
*/
|
||||
public static ArrayList<Variable> vars(String... names) {
|
||||
ArrayList<Variable> v = new ArrayList<Variable>();
|
||||
for (String n : names)
|
||||
@ -27,10 +45,16 @@ public class Variable implements Comparable<Variable>, Expression {
|
||||
return v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new intsnce
|
||||
*
|
||||
* @param identifier the variables name
|
||||
*/
|
||||
public Variable(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean calculate(Context context) throws ExpressionException {
|
||||
return context.get(this);
|
||||
}
|
||||
@ -46,6 +70,9 @@ public class Variable implements Comparable<Variable>, Expression {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the variables name
|
||||
*/
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ package de.neemann.digital.analyse.expression.format;
|
||||
*
|
||||
* @author hneemann
|
||||
*/
|
||||
public class FormatterException extends Throwable {
|
||||
public class FormatterException extends Exception {
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
|
@ -6,12 +6,20 @@ import de.neemann.digital.analyse.expression.Expression;
|
||||
import de.neemann.digital.analyse.expression.ExpressionException;
|
||||
|
||||
/**
|
||||
* Creates a bool table from the given expression
|
||||
*
|
||||
* @author hneemann
|
||||
*/
|
||||
public class BoolTableExpression implements BoolTable {
|
||||
private final Expression expression;
|
||||
private final ContextFiller context;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param expression the expression
|
||||
* @param context the context to evaluate the expression
|
||||
*/
|
||||
public BoolTableExpression(Expression expression, ContextFiller context) {
|
||||
this.expression = expression;
|
||||
this.context = context;
|
||||
|
@ -6,7 +6,16 @@ package de.neemann.digital.analyse.quinemc;
|
||||
* @author hneemann
|
||||
*/
|
||||
public enum TableItem {
|
||||
/**
|
||||
* Zero of false
|
||||
*/
|
||||
zero,
|
||||
/**
|
||||
* one or true
|
||||
*/
|
||||
one,
|
||||
/**
|
||||
* var is optimized
|
||||
*/
|
||||
optimized
|
||||
}
|
||||
|
@ -4,11 +4,26 @@ package de.neemann.digital.analyse.quinemc;
|
||||
* @author hneemann
|
||||
*/
|
||||
public enum ThreeStateValue {
|
||||
/**
|
||||
* one or true
|
||||
*/
|
||||
one,
|
||||
/**
|
||||
* zero or false
|
||||
*/
|
||||
zero,
|
||||
/**
|
||||
* dont care
|
||||
*/
|
||||
dontCare;
|
||||
|
||||
|
||||
/**
|
||||
* Create a value from a bool
|
||||
*
|
||||
* @param bool the bool
|
||||
* @return the created ThreeStateValue
|
||||
*/
|
||||
public static ThreeStateValue value(boolean bool) {
|
||||
if (bool) {
|
||||
return one;
|
||||
@ -17,6 +32,13 @@ public enum ThreeStateValue {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a value from an int
|
||||
* 0 and 1 work as expected, any other value means "dont care"
|
||||
*
|
||||
* @param value the value
|
||||
* @return the created ThreeStateValue
|
||||
*/
|
||||
public static ThreeStateValue value(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user