001package jmri.jmrit.logixng.util.parser;
002
003import jmri.JmriException;
004import jmri.jmrit.logixng.SymbolTable;
005
006/**
007 * A parsed expression
008 */
009public interface ExpressionNode {
010
011    /**
012     * Calculate the expression
013     * @param symbolTable the symbol table
014     * @return the result
015     * @throws JmriException if an error occurs
016     */
017    Object calculate(SymbolTable symbolTable) throws JmriException;
018    
019    /**
020     * Can this expression be assigned a value?
021     * @return true if it's possible to assign a value to this expression,
022     *         false otherwise
023     */
024    default boolean canBeAssigned() {
025        return false;
026    }
027    
028    /**
029     * Assign a value to this expression
030     * @param symbolTable the symbol table
031     * @param value the value to assign
032     * @throws jmri.JmriException if an error occurs
033     */
034    default void assignValue(SymbolTable symbolTable, Object value) throws JmriException {
035        throw new UnsupportedOperationException("This expression can't be assigned");
036    }
037    
038    /**
039     * Get a String that defines this expression node.
040     * @return the string
041     */
042    String getDefinitionString();
043    
044}