de.upb.hni.vmagic.expression.parser
Class ExpressionParser

java.lang.Object
  extended by de.upb.hni.vmagic.expression.parser.ExpressionParser

public class ExpressionParser
extends java.lang.Object

VHDL expression parser. The expression parser is a versatile utility to easily create complex VHDL expressions. Without it you would need to create an expression by manually creating a hierarchy of meta class objects. The expression parser simplifies this task by providing a printf like interface for creating expressions.

The expression template is a VHDL expression with placeholdes, which get replaced by the objects in the paramter list. The syntax of the placeholders is %i, where i is the index of the object that should be inserted at the placeholdes position. The index of the first paramter is 1.

Examples:

Using the ExpressionParser to create a simple Expression:

VHDL Output: (10 + 20) * 30
 Expression e = ExpressionParser.parse("(10 + 20) * 30");
 

Creating a more complex expression using placeholders:

VHDL Output: (s1 AND "01100100") OR (s1 xor s2)
 Signal s1 = new Signal("s1", StdLogic1164.STD_LOGIC_VECTOR(8));
 Signal s2 = new Signal("s2", StdLogic1164.STD_LOGIC_VECTOR(8));
 Expression e = ExpressionParser.parse("(%1 and \"01100100\") or (%1 xor %2)", s1, s2);
 


Method Summary
static Expression parse(java.lang.String template, Expression... parameters)
          Parses the expression template.
static Expression parse(java.lang.String template, java.util.List<Expression> parameters)
          Parses the expression template.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parse

public static Expression parse(java.lang.String template,
                               Expression... parameters)
Parses the expression template. The given parameters are inserted at the position of the placeholders in the template string.

Parameters:
template - the template
parameters - a list of expressions used as parameters
Returns:
the generated expression

parse

public static Expression parse(java.lang.String template,
                               java.util.List<Expression> parameters)
Parses the expression template. The given parameters are inserted at the position of the placeholders in the template string.

Parameters:
template - the template
parameters - a list of expressions used as parameters
Returns:
the generated expression