byucc.jhdl.base.genericparser
Class exprParser
java.lang.Object
byucc.jhdl.base.genericparser.exprParser
- All Implemented Interfaces:
- exprParserConstants
- public class exprParser
- extends java.lang.Object
- implements exprParserConstants
This class provides the ability to parse a string describing a parameterized width.
There is typical order of operation support, with parenthesis, then exponentiation (**),
followed by multiplication/division (*, /), and addition/subtraction (+, -). Any
string in the expression must be a parameter bound to an integer value.
- Author:
- Brent Nelson
Fields inherited from interface byucc.jhdl.base.genericparser.exprParserConstants |
CONSTANT, DEFAULT, DIGIT, DIVIDE, EOF, EOL, EXP, ID, LETTER, MINUS, MULTIPLY, PLUS, tokenImage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
token_source
public static exprParserTokenManager token_source
token
public static Token token
jj_nt
public static Token jj_nt
lookingAhead
public static boolean lookingAhead
exprParser
public exprParser(java.io.InputStream stream)
exprParser
public exprParser(java.io.Reader stream)
exprParser
public exprParser(exprParserTokenManager tm)
computePortWidths
public static int[] computePortWidths(java.lang.String[] portwidths,
Bindings binding_values,
boolean evaluate)
- Do the port width computation. If evaluate is true, it will substitute
the integer values for bindings, and throw an exception if a binding
is not defined. If evaluate is false, the method will simply check
that the syntax is legal.
- Parameters:
portwidths
- the list of strings to evaluatebinding_values
- any bindings that are referenced in the widthsevaluate
- whether to just check syntax (false) or evaluate (true)
- Returns:
- an array of integer widths, matching the input array
- Throws:
UnboundException
- if a binding is referenced but not bound
TypeException
- if a binding is not an integer type
ParseException
- if there is a parsing problem
computePortWidth
public static int computePortWidth(java.lang.String portwidth,
Bindings binding_values)
- Do the port width computation.
- Parameters:
portwidth
- the string to evaluatebinding_values
- any bindings that are referenced in the widths
- Returns:
- an array of integer widths, matching the input array
- Throws:
UnboundException
- if a binding is referenced but not bound
TypeException
- if a binding is not an integer type
ParseException
- if there is a parsing problem
one_line
public static final void one_line()
throws ParseException
- Throws:
ParseException
sum
public static final void sum()
throws ParseException
- Throws:
ParseException
term
public static final void term()
throws ParseException
- Throws:
ParseException
exp
public static final void exp()
throws ParseException
- Throws:
ParseException
unary
public static final void unary()
throws ParseException
- Throws:
ParseException
element
public static final void element()
throws ParseException
- Throws:
ParseException
ReInit
public static void ReInit(java.io.InputStream stream)
ReInit
public static void ReInit(java.io.Reader stream)
ReInit
public void ReInit(exprParserTokenManager tm)
getNextToken
public static final Token getNextToken()
getToken
public static final Token getToken(int index)
generateParseException
public static final ParseException generateParseException()
enable_tracing
public static final void enable_tracing()
disable_tracing
public static final void disable_tracing()
Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.