Package ptolemy.data.expr

Examples of ptolemy.data.expr.ParseTreeEvaluator


     *   not contain a parsable fixed point number.
     */
    public FixToken(String init) throws IllegalActionException {
        PtParser parser = new PtParser();
        ASTPtRootNode tree = parser.generateParseTree(init);
        Token token = (new ParseTreeEvaluator()).evaluateParseTree(tree);

        if (token instanceof FixToken) {
            _value = ((FixToken) token).fixValue();
        } else {
            throw new IllegalActionException("A FixToken cannot be"
View Full Code Here


     *   not contain a parsable 2-D complex matrix.
     */
    public ComplexMatrixToken(String init) throws IllegalActionException {
        PtParser parser = new PtParser();
        ASTPtRootNode tree = parser.generateParseTree(init);
        Token token = (new ParseTreeEvaluator()).evaluateParseTree(tree);

        if (token instanceof ComplexMatrixToken) {
            Complex[][] value = ((ComplexMatrixToken) token).complexMatrix();
            _initialize(value, DO_COPY);
        } else {
View Full Code Here

     *   not contain a parsable 2-D long matrix.
     */
    public LongMatrixToken(String init) throws IllegalActionException {
        PtParser parser = new PtParser();
        ASTPtRootNode tree = parser.generateParseTree(init);
        Token token = (new ParseTreeEvaluator()).evaluateParseTree(tree);

        if (token instanceof LongMatrixToken) {
            long[][] value = ((LongMatrixToken) token).longMatrix();
            _initialize(value, DO_COPY);
        } else {
View Full Code Here

     *   not contain a parsable 2-D int matrix.
     */
    public IntMatrixToken(String init) throws IllegalActionException {
        PtParser parser = new PtParser();
        ASTPtRootNode tree = parser.generateParseTree(init);
        Token token = (new ParseTreeEvaluator()).evaluateParseTree(tree);

        if (token instanceof IntMatrixToken) {
            int[][] value = ((IntMatrixToken) token).intMatrix();
            _initialize(value);
        } else {
View Full Code Here

     *   not contain a parsable 2-D double matrix.
     */
    public DoubleMatrixToken(String init) throws IllegalActionException {
        PtParser parser = new PtParser();
        ASTPtRootNode tree = parser.generateParseTree(init);
        Token token = (new ParseTreeEvaluator()).evaluateParseTree(tree);

        if (token instanceof DoubleMatrixToken) {
            double[][] value = ((DoubleMatrixToken) token).doubleMatrix();
            _initialize(value);
        } else {
View Full Code Here

                            "Unable to set token for name " + paramName, ex);
                }
            }
            try {
                PtParser parser = new PtParser();
                ParseTreeEvaluator _parseTreeEvaluator = new ParseTreeEvaluator();
                for (String parameterName : _parameters.keySet()) {
                    String expression = _parameters.get(parameterName);
                    if (expression == null) {
                        throw new PtalonRuntimeException(
                                "Unable to find expression label for "
                                        + "parameter " + parameterName);
                    }
                    ASTPtRootNode _parseTree = parser
                            .generateParseTree(expression);
                    Parameter parameter = (Parameter) actor
                            .getAttribute(parameterName);
                    if (parameter == null) {
                        String uniqueName = actor.uniqueName(parameterName);
                        parameter = new PtalonExpressionParameter(actor,
                                uniqueName);
                    }
                    Token result = _parseTreeEvaluator.evaluateParseTree(
                            _parseTree, _scope);
                    parameter.setToken(result);
                    // Validate the parameter to ensure that any value
                    // dependents are notified.
                    parameter.validate();
View Full Code Here

         */
        public void assignNonPtalonParameters(ComponentEntity actor)
                throws PtalonRuntimeException {
            try {
                PtParser parser = new PtParser();
                ParseTreeEvaluator _parseTreeEvaluator = new ParseTreeEvaluator();
                for (String parameterName : _parameters.keySet()) {
                    String expression = _parameters.get(parameterName);
                    if (expression == null) {
                        throw new PtalonRuntimeException(
                                "Unable to find expression label for "
                                        + "parameter " + parameterName);
                    }
                    ASTPtRootNode parseTree = parser
                            .generateParseTree(expression);
                    try {
                        Parameter parameter = (Parameter) actor
                                .getAttribute(parameterName);
                        if (parameter == null) {
                            String uniqueName = actor.uniqueName(parameterName);

                            // FIXME: Ptalon assumes that any
                            // parameter we give that is not
                            // predefined in the actor should be an
                            // instance of Parameter. This is not
                            // always the case. Ptalon syntax needs to
                            // be extended to specify new parameters
                            // of a specified class. For now, we
                            // intercept parameters with name
                            // "_location" since these are
                            // particularly useful for graphical
                            // demos.
                            if (uniqueName.equals("_location")) {
                                parameter = new LocationParameter(actor,
                                        uniqueName);
                            } else {
                                parameter = new Parameter(actor, uniqueName);
                            }
                        }
                        try {
                            Token result = _parseTreeEvaluator
                                    .evaluateParseTree(parseTree, _scope);
                            parameter.setToken(result);
                            // We have to validate the parameter so that
                            // value dependents (if any) are notified of
                            // the new value, and so that attributeChanged()
View Full Code Here

                _parseTree = parser.generateParseTree(expression
                        .getExpression());
            }

            if (_parseTreeEvaluator == null) {
                _parseTreeEvaluator = new ParseTreeEvaluator();
            }

            if (_scope == null) {
                _scope = new VariableScope();
            }
View Full Code Here

     *   a parsable complex number.
     */
    public ComplexToken(String init) throws IllegalActionException {
        PtParser parser = new PtParser();
        ASTPtRootNode tree = parser.generateParseTree(init);
        Token token = (new ParseTreeEvaluator()).evaluateParseTree(tree);

        if (token instanceof ComplexToken) {
            _value = ((ComplexToken) token).complexValue();
        } else {
            throw new IllegalActionException("A ComplexToken cannot be"
View Full Code Here

     *   not contain a parsable array.
     */
    public ArrayToken(String init) throws IllegalActionException {
        PtParser parser = new PtParser();
        ASTPtRootNode tree = parser.generateParseTree(init);
        ParseTreeEvaluator evaluator = new ParseTreeEvaluator();
        Token token = evaluator.evaluateParseTree(tree);

        if (token instanceof ArrayToken) {
            _value = ((ArrayToken) token)._value;
            _elementType = ((ArrayToken) token)._elementType;
        } else {
View Full Code Here

TOP

Related Classes of ptolemy.data.expr.ParseTreeEvaluator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.