1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.basicexpression;
14 import java.io.PushbackReader;
15 import java.io.StringReader;
17 import org.simantics.basicexpression.analysis.DepthFirstAdapter;
18 import org.simantics.basicexpression.lexer.Lexer;
19 import org.simantics.basicexpression.node.Start;
20 import org.simantics.basicexpression.parser.Parser;
22 public class Expressions {
24 private static final boolean DEBUG = false;
26 public static void evaluate(String expression, DepthFirstAdapter evaluator) {
30 // Create a Parser instance.
34 new PushbackReader(new StringReader(expression))));
37 Start tree = p.parse();
40 tree.apply(new PrettyPrintExpressionVisitor());
42 // System.out.println("tree=" + tree.getClass().getName());
44 // Apply the translation.
45 tree.apply(evaluator);