X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.basicexpression%2Fsrc%2Forg%2Fsimantics%2Fbasicexpression%2FExpressions.java;h=ae28f399b707cd9b02070a5a17b46665e9a27e90;hb=refs%2Fchanges%2F38%2F238%2F2;hp=a3e4ff5690e6499239432f564dad4df181c1c444;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.basicexpression/src/org/simantics/basicexpression/Expressions.java b/bundles/org.simantics.basicexpression/src/org/simantics/basicexpression/Expressions.java index a3e4ff569..ae28f399b 100644 --- a/bundles/org.simantics.basicexpression/src/org/simantics/basicexpression/Expressions.java +++ b/bundles/org.simantics.basicexpression/src/org/simantics/basicexpression/Expressions.java @@ -1,56 +1,56 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.basicexpression; - -import java.io.PushbackReader; -import java.io.StringReader; - -import org.simantics.basicexpression.analysis.DepthFirstAdapter; -import org.simantics.basicexpression.lexer.Lexer; -import org.simantics.basicexpression.node.Start; -import org.simantics.basicexpression.parser.Parser; - -public class Expressions { - - private static final boolean DEBUG = false; - - public static void evaluate(String expression, DepthFirstAdapter evaluator) { - - try - { - // Create a Parser instance. - Parser p = - new Parser( - new Lexer( - new PushbackReader(new StringReader(expression)))); - - // Parse the input. - Start tree = p.parse(); - - if(DEBUG) - tree.apply(new PrettyPrintExpressionVisitor()); - -// System.out.println("tree=" + tree.getClass().getName()); - - // Apply the translation. - tree.apply(evaluator); - - } - catch(Exception e) - { - e.printStackTrace(); - evaluator.except(e); - } - - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.basicexpression; + +import java.io.PushbackReader; +import java.io.StringReader; + +import org.simantics.basicexpression.analysis.DepthFirstAdapter; +import org.simantics.basicexpression.lexer.Lexer; +import org.simantics.basicexpression.node.Start; +import org.simantics.basicexpression.parser.Parser; + +public class Expressions { + + private static final boolean DEBUG = false; + + public static void evaluate(String expression, DepthFirstAdapter evaluator) { + + try + { + // Create a Parser instance. + Parser p = + new Parser( + new Lexer( + new PushbackReader(new StringReader(expression)))); + + // Parse the input. + Start tree = p.parse(); + + if(DEBUG) + tree.apply(new PrettyPrintExpressionVisitor()); + +// System.out.println("tree=" + tree.getClass().getName()); + + // Apply the translation. + tree.apply(evaluator); + + } + catch(Exception e) + { + e.printStackTrace(); + evaluator.except(e); + } + + } + +}