Thread: [Mathlib-commitlog] SF.net SVN: mathlib:[561] JMathLib/trunk/src/jmathlib/core/interpreter
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2008-12-26 18:52:31
|
Revision: 561
http://mathlib.svn.sourceforge.net/mathlib/?rev=561&view=rev
Author: st_mueller
Date: 2008-12-26 18:52:29 +0000 (Fri, 26 Dec 2008)
Log Message:
-----------
added "format" property for formatting numbers
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2008-12-26 18:48:04 UTC (rev 560)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2008-12-26 18:52:29 UTC (rev 561)
@@ -1,9 +1,12 @@
package jmathlib.core.interpreter;
import java.io.*;
+import java.util.Locale;
import java.applet.Applet;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
-//import MathLib.Tokens.*;
import jmathlib.core.interpreter.Interpreter;
/**This class contains the global variables, which are accessible throughout the program.
@@ -40,6 +43,9 @@
/**sets whether to write debug lines to console and log files*/
static transient private boolean debug = true;
+ /**stores the number format for displaying the number*/
+ public transient static NumberFormat numFormat = new DecimalFormat("0.0000", new DecimalFormatSymbols(Locale.ENGLISH));
+
/**Initialises the global values
@param _interpreter = the Interpreter object
@param _runningStandalone = true if this was run from an application*/
@@ -154,5 +160,23 @@
{
debug= _debug;
}
+
+ /**
+ * returns the number format for displaying numbers
+ * @return format type
+ */
+ public NumberFormat getNumberFormat()
+ {
+ return numFormat;
+ }
+ /**
+ * sets the number format for displaying numbers
+ * @param _numFormat format type
+ */
+ public void setNumberFormat(NumberFormat _numFormat)
+ {
+ numFormat = _numFormat;
+ }
+
}
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java 2008-12-26 18:48:04 UTC (rev 560)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java 2008-12-26 18:52:29 UTC (rev 561)
@@ -1,11 +1,13 @@
package jmathlib.core.interpreter;
import java.io.*;
+import java.text.NumberFormat;
import java.applet.Applet;
import jmathlib.core.interpreter.Interpreter;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.functions.FunctionManager;
+
/**This universal the base class for all class define by MathLib.
It defines Global values as class variables and also defines functions for creating and accessing the working environment.*/
abstract public class RootObject implements java.io.Serializable,
@@ -184,4 +186,22 @@
globals.setDebug(_debug);
}
+ /**
+ * returns the number format for displaying numbers
+ * @return format type
+ */
+ public NumberFormat getNumberFormat()
+ {
+ return globals.getNumberFormat();
+ }
+
+ /**
+ * sets the number format for displaying numbers
+ * @param _numFormat format type
+ */
+ public void setNumberFormat(NumberFormat numFormat)
+ {
+ globals.setNumberFormat(numFormat);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-01-09 19:22:36
|
Revision: 661
http://mathlib.svn.sourceforge.net/mathlib/?rev=661&view=rev
Author: st_mueller
Date: 2009-01-09 19:22:29 +0000 (Fri, 09 Jan 2009)
Log Message:
-----------
changed Parser, now parsing of cd somedirectory is possible. Also cd("somedirectory") still works.
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java
JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java 2009-01-09 19:20:18 UTC (rev 660)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java 2009-01-09 19:22:29 UTC (rev 661)
@@ -64,12 +64,10 @@
/**default constructor - creates the lexical analyser object with an empty string*/
public LexicalAnalyser()
{
- reservedWords = " break do exit try catch continue ";
- reservedWords += " for help history hold if load more return ";
- reservedWords += " load dir ls save set show who whos ";
- reservedWords += " cd chdir clear diary echo format ";
- reservedWords += " type global isglobal ";
- reservedWords += " save switch while "; // trailing " " is very important !!
+ reservedWords = " break catch continue ";
+ reservedWords += " for foreach global if ";
+ reservedWords += " persistent return switch try while ";
+ reservedWords += " global isglobal "; // trailing " " is very important !!
delimiterWords = " end endif else elseif endfunction endwhile endfor ";
delimiterWords += " case default otherwise endswitch ";
delimiterChars = ",()[];{}\n";
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java 2009-01-09 19:20:18 UTC (rev 660)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java 2009-01-09 19:22:29 UTC (rev 661)
@@ -177,7 +177,7 @@
OperandToken retToken = null; // holds token to be returned
Token peekToken = peekNextToken(deliTyp); // holds next (actual) token
-
+
if (peekToken == null)
{
// No more tokens available
@@ -241,6 +241,9 @@
{
// variables (e.g. aaa or b)
retToken = (OperandToken)getNextToken(deliTyp);
+
+ ErrorLogger.debugLine("Parser parseSingle ppp "+retToken.toString());
+
// check if the variable is followed by a dot operator
if (peekNextToken(deliTyp) instanceof DotOperatorToken)
@@ -267,6 +270,44 @@
retToken = parseFunctionAndParameters( new FunctionToken(name), null );
}
}
+ else if ( (peekNextToken(deliTyp) instanceof VariableToken) ||
+ (peekNextToken(deliTyp) instanceof CharToken) )
+ {
+ // parse something like disp hello instead of disp("hello")
+ // parse something like disp "hello" instead of disp("hello")
+ // convert arguments into char arrays
+
+ String name = ((VariableToken)retToken).getName();
+ FunctionToken func = new FunctionToken(name);
+
+ Token next = null ;
+ while(true)
+ {
+ next = peekNextToken();
+ if (next==null)
+ break;
+
+ //ErrorLogger.debugLine("Parser: var var "+next.toString());
+
+ if (next instanceof DelimiterToken)
+ {
+ break;
+ }
+ else if ( (next instanceof VariableToken) ||
+ (next instanceof CharToken) )
+ {
+ String s = next.toString();
+ ErrorLogger.debugLine("Parser: var var variable "+next.toString());
+ getNextToken();
+ func.setOperands(new OperandToken[] {(OperandToken)new CharToken(s)});
+ }
+ else
+ Errors.throwMathLibException("Parser: var var");
+ }
+
+ return func;
+
+ }
else
ErrorLogger.debugLine("Parser: VariableToken: " + retToken.toString());
}
@@ -931,7 +972,7 @@
FunctionToken func = (FunctionToken)nextToken;
// check if it is a special function e.g. "global a b c"
- if (func.getName().equals("global") || func.getName().equals("isglobal"))
+ if ( func.getName().equals("global") || func.getName().equals("isglobal"))
{
ErrorLogger.debugLine("Parser: found global");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-01-25 22:19:01
|
Revision: 780
http://mathlib.svn.sourceforge.net/mathlib/?rev=780&view=rev
Author: st_mueller
Date: 2009-01-25 22:18:57 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
changed signature of evaluate(Token[] operands)
to
evaluate(Token[] operands, GlobalValues globals)
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-25 21:03:22 UTC (rev 779)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-25 22:18:57 UTC (rev 780)
@@ -54,6 +54,8 @@
// all expressions for access to function manager, variable lists, contexts,...
globals = new GlobalValues(this, runningStandalone, _applet);;
+ // set output panel to NULL
+ // ?? needed? outputPanel is initialized with NULl anyway (see above)
outputPanel = null;
// read preferences from a file on the disc or on the web
@@ -111,9 +113,7 @@
// if required rehash m-files
if(runningStandalone)
- {
globals.getFunctionManager().checkAndRehashTimeStamps();
- }
try
{
@@ -167,6 +167,7 @@
var.assign(new CharToken(answer));
}
+ ErrorLogger.debugLine("Interpreter: done");
return answer;
}
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java 2009-01-25 21:03:22 UTC (rev 779)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java 2009-01-25 22:18:57 UTC (rev 780)
@@ -5,16 +5,16 @@
/**class for binding a variable name to some data*/
public class Variable extends RootObject
{
- /**The variable name*/
+ /**variable name*/
private String name;
- /**Variable data*/
+ /**variable data*/
private OperandToken data;
- // local or global context
+ /** local or global context */
private boolean globalB = false;
- /**Default constructor*/
+ /**default constructor*/
public Variable()
{
super();
@@ -22,7 +22,8 @@
data = null;
}
- /**constructor containing a variable name*/
+ /**constructor containing a variable name
+ * @param _name*/
public Variable(String _name)
{
super();
@@ -30,7 +31,9 @@
data = null;
}
- /**constructor containing the variables name and data*/
+ /**constructor containing the variables name and data
+ * @param _name
+ * @param _data*/
public Variable(String _name, OperandToken _data)
{
super();
@@ -51,8 +54,10 @@
//}
}
- /**Assign a new value to the variable*/
- //public OperandToken assign(Token _data)
+ /**Assign a new value to the variable
+ * @param _data
+ * @return
+ */
public OperandToken assign(OperandToken _data)
{
if (_data!=null)
@@ -86,9 +91,12 @@
return equal;
}
- /**Converts the variable to a string.*/
+ /**Converts the variable to a string.
+ * @return
+ */
public String toString()
{
+ //Errors.throwMathLibException("Variable");
if(data == null)
return null;
else
@@ -107,7 +115,9 @@
return name;
}
- /**Returns the variables data*/
+ /**Returns the variables data
+ * @return
+ */
public OperandToken getData()
{
return data;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-01-26 19:49:22
|
Revision: 783
http://mathlib.svn.sourceforge.net/mathlib/?rev=783&view=rev
Author: st_mueller
Date: 2009-01-26 19:49:18 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
added more comments
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/Context.java
JMathLib/trunk/src/jmathlib/core/interpreter/ContextList.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Context.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Context.java 2009-01-26 19:47:27 UTC (rev 782)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Context.java 2009-01-26 19:49:18 UTC (rev 783)
@@ -1,6 +1,14 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2002-2009
+ */
+
package jmathlib.core.interpreter;
-//import MathLib.Tokens.*;
/**A context object contains the variables and code for the executing function*/
public class Context implements java.io.Serializable
@@ -11,8 +19,6 @@
/**Reference to the contexts calling context*/
private Context parent;
- /**The name of the function that defined this context, used for diagnostics*/
- //private String functionName;
/**Create a Context with an empty variable list, used to construct the global context*/
public Context()
@@ -22,8 +28,9 @@
}
/**Create a Context with the supplied values
- @param _variables = the variable list of the new context
- @param _parent = the calling context*/
+ * @param _variables = the variable list of the new context
+ * @param _parent = the calling context
+ */
public Context(VariableList _variables, Context _parent)
{
variables = _variables;
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/ContextList.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/ContextList.java 2009-01-26 19:47:27 UTC (rev 782)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/ContextList.java 2009-01-26 19:49:18 UTC (rev 783)
@@ -1,3 +1,12 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2002-2009
+ */
+
package jmathlib.core.interpreter;
import jmathlib.core.tokens.OperandToken;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-01-26 19:52:04
|
Revision: 784
http://mathlib.svn.sourceforge.net/mathlib/?rev=784&view=rev
Author: st_mueller
Date: 2009-01-26 19:52:01 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
renamed MathLibException into JMathLibException
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/Errors.java
JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java
Added Paths:
-----------
JMathLib/trunk/src/jmathlib/core/interpreter/JMathLibException.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Errors.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Errors.java 2009-01-26 19:49:18 UTC (rev 783)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Errors.java 2009-01-26 19:52:01 UTC (rev 784)
@@ -26,7 +26,7 @@
public static void throwMathLibException(int errorCode)
{
String text = getErrorText(errorCode);
- throw (new MathLibException(text));
+ throw (new JMathLibException(text));
}
@@ -36,7 +36,7 @@
@param errorCode = the error message*/
public static void throwMathLibException(String errorMessage)
{
- throw (new MathLibException("ERROR: "+errorMessage));
+ throw (new JMathLibException("ERROR: "+errorMessage));
}
/**
@@ -46,7 +46,7 @@
*/
public static void throwParserException(String errorMessage)
{
- throw (new MathLibException("PARSER: "+errorMessage));
+ throw (new JMathLibException("PARSER: "+errorMessage));
}
@@ -57,7 +57,7 @@
*/
public static void throwUsageException(String errorMessage)
{
- throw (new MathLibException("USAGE: "+errorMessage));
+ throw (new JMathLibException("USAGE: "+errorMessage));
}
/**returns the localised error string for a specific code,
@@ -68,7 +68,7 @@
public static String getErrorText(int errorCode, Object[] params)
{
String text = "";
- ResourceBundle bundle = ResourceBundle.getBundle("MathLib.ResourceBundles.ErrorBundle");
+ ResourceBundle bundle = ResourceBundle.getBundle("jmathlib.resourcebundles.ErrorBundle");
text = MessageFormat.format(bundle.getString(Integer.toString(errorCode)), params);
return text;
@@ -81,7 +81,7 @@
public static void throwMathLibException(int errorCode, Object[] params)
{
String text = getErrorText(errorCode, params);
- throw (new MathLibException(text));
+ throw (new JMathLibException(text));
}
}
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-26 19:49:18 UTC (rev 783)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-26 19:52:01 UTC (rev 784)
@@ -132,7 +132,7 @@
//getVariables().listVariables();
}
- catch(MathLibException e)
+ catch(JMathLibException e)
{
answer = e.getMessage();
Copied: JMathLib/trunk/src/jmathlib/core/interpreter/JMathLibException.java (from rev 413, JMathLib/trunk/src/jmathlib/core/interpreter/MathLibException.java)
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/JMathLibException.java (rev 0)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/JMathLibException.java 2009-01-26 19:52:01 UTC (rev 784)
@@ -0,0 +1,31 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2002-2009
+ */
+
+
+package jmathlib.core.interpreter;
+
+/**MathLib specific exception */
+public class JMathLibException extends ArithmeticException
+{
+ /**Create a new exception object*/
+ public JMathLibException()
+ {
+
+ }
+
+ /**Set the message text
+ * @param text = the text to display
+ */
+ public JMathLibException(String text)
+ {
+ super(text);
+ }
+
+
+}
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java 2009-01-26 19:49:18 UTC (rev 783)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java 2009-01-26 19:52:01 UTC (rev 784)
@@ -220,7 +220,7 @@
For each character it calls a series of functions until it
finds one that can handle the character
@return the next token contained within the expression string */
- private boolean scanNextToken() throws MathLibException
+ private boolean scanNextToken() throws JMathLibException
{
negative = false; // reset sign indicator
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-01-30 19:04:30
|
Revision: 798
http://mathlib.svn.sourceforge.net/mathlib/?rev=798&view=rev
Author: st_mueller
Date: 2009-01-30 19:04:24 +0000 (Fri, 30 Jan 2009)
Log Message:
-----------
changed handling of preferences/properties
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
Removed Paths:
-------------
JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2009-01-30 19:03:54 UTC (rev 797)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2009-01-30 19:04:24 UTC (rev 798)
@@ -11,6 +11,7 @@
import java.io.*;
import java.util.Locale;
+import java.util.Properties;
import java.applet.Applet;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
@@ -47,6 +48,9 @@
/**stores the number format for displaying the number*/
public NumberFormat numFormat = new DecimalFormat("0.0000", new DecimalFormatSymbols(Locale.ENGLISH));
+ /** global properties */
+ private static Properties props = new Properties();
+
/**Initialises the global values
* @param _interpreter = the Interpreter object
* @param _runningStandalone = true if this was run from an application
@@ -204,4 +208,71 @@
numFormat = _numFormat;
}
+ /**
+ *
+ *
+ */
+ public void loadPropertiesFromFile()
+ {
+
+ // load global properties from disc
+ try
+ {
+ props.load(new FileInputStream(new File("JMathLib.properties")));
+ }
+ catch (Exception e)
+ {
+ System.out.println("Properties global error");
+ }
+ //System.out.println("Properties loaded");
+
+ // display properties
+ //Enumeration propnames = props.propertyNames();
+ //while (globalPropnames.hasMoreElements())
+ //{
+ // String propname = (String)globalPropnames.nextElement();
+ // System.out.println("Property: "+propname+" = "+globalProps.getProperty(propname));
+ //}
+
+
+ }
+
+ /**
+ *
+ */
+ public void storePropertiesToFile()
+ {
+
+ // store properties back to file
+ try
+ {
+ props.store(new FileOutputStream(new File("JMathLib.properties")),
+ "JMathLib property file" );
+ }
+ catch (Exception e)
+ {
+ System.out.println("Property: Error");
+ }
+ }
+
+ /**
+ *
+ * @param property
+ * @return
+ */
+ public String getProperty(String property)
+ {
+ return props.getProperty(property);
+ }
+
+ /**
+ *
+ * @param property
+ * @param value
+ */
+ public void setProperty(String property, String value)
+ {
+ props.setProperty(property, value);
+ }
+
}
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-30 19:03:54 UTC (rev 797)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-01-30 19:04:24 UTC (rev 798)
@@ -30,9 +30,6 @@
/**for testing purposes additional throwing of errors can be enables */
public boolean throwErrorsB = false;
- /** list of preferences */
- public Preferences prefs = new Preferences();
-
/**Constructs the interpreter and sets the constants
* @param _runningStandalone = true if this is being used from an application
*/
@@ -59,7 +56,7 @@
outputPanel = null;
// read preferences from a file on the disc or on the web
- prefs.loadPropertiesFromFile();
+ globals.loadPropertiesFromFile();
}
@@ -98,7 +95,7 @@
executeExpression("finish");
// store current properties to file
- prefs.storeLocalPropertiesToFile();
+ globals.storePropertiesToFile();
}
}
Deleted: JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java 2009-01-30 19:03:54 UTC (rev 797)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Preferences.java 2009-01-30 19:04:24 UTC (rev 798)
@@ -1,123 +0,0 @@
-package jmathlib.core.interpreter;
-
-//import MathLib.Tokens.*;
-import java.util.*;
-import java.io.*;
-
-/**
- *
- */
-public class Preferences
-{
-
- Properties globalProps = new Properties(); // global properties
- Properties localProps = new Properties(); // local properties
-
- //SwingUI KEYS
- public static final String MFUNCTION_FILE_HISTORY = "MathLib.UI.Swing.MFunctionFileHistory";
- /**
- *
- */
- public Preferences()
- {
- }
-
- /**
- *
- *
- */
- public void loadPropertiesFromFile()
- {
-
- // load globa properties from disc
- try
- {
- globalProps.load(new FileInputStream(new File("JMathLib.properties")));
- }
- catch (Exception e)
- {
- System.out.println("Properties error");
- }
- //System.out.println("Properties loaded");
-
- // display properties
- Enumeration globalPropnames = globalProps.propertyNames();
- //while (globalPropnames.hasMoreElements())
- //{
- // String propname = (String)globalPropnames.nextElement();
- // System.out.println("Property: "+propname+" = "+globalProps.getProperty(propname));
- //}
-
-
- // load local properties from disc
- try
- {
- localProps.load(new FileInputStream(new File("JMathLib.local.properties")));
- }
- catch (Exception e)
- {
- System.out.println("Properties local error");
- }
-
- // display properties
- Enumeration localPropnames = localProps.propertyNames();
- //while (localPropnames.hasMoreElements())
- //{
- // String propname = (String)localPropnames.nextElement();
- // System.out.println("Property (local): "+propname+" = "+localProps.getProperty(propname));
- //}
-
- // check if all global properties are also set in local properties
- // -> in case global property not available in local property, copy global to local property
- globalPropnames = globalProps.propertyNames();
- while (globalPropnames.hasMoreElements())
- {
- String propname = (String)globalPropnames.nextElement();
- if (localProps.getProperty(propname)== null)
- {
- System.out.println("global Property: "+propname+" not local yet");
- localProps.setProperty(propname, (String)globalProps.getProperty(propname));
- }
- }
-
- }
-
- /**
- *
- */
- public void storeLocalPropertiesToFile()
- {
-
- // only store local properties back to file
- try
- {
- localProps.store(new FileOutputStream(new File("JMathLib.local.properties")),
- "JMathLib local property file" );
- }
- catch (Exception e)
- {
- System.out.println("Property: Error");
- }
- }
-
- public String getGlobalProperty(String property)
- {
- return globalProps.getProperty(property);
- }
-
- public void setGlobalProperty(String property, String value)
- {
- globalProps.setProperty(property, value);
- }
-
- public String getLocalProperty(String property)
- {
- return localProps.getProperty(property);
- }
-
- public void setLocalProperty(String property, String value)
- {
- localProps.setProperty(property, value);
- }
-
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-02-05 22:29:14
|
Revision: 832
http://mathlib.svn.sourceforge.net/mathlib/?rev=832&view=rev
Author: st_mueller
Date: 2009-02-05 21:39:14 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/ControlException.java
JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/ControlException.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/ControlException.java 2009-02-04 19:52:35 UTC (rev 831)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/ControlException.java 2009-02-05 21:39:14 UTC (rev 832)
@@ -1,3 +1,11 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2002-2009
+ */
package jmathlib.core.interpreter;
import jmathlib.core.tokens.OperandToken;
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java 2009-02-04 19:52:35 UTC (rev 831)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/ErrorLogger.java 2009-02-05 21:39:14 UTC (rev 832)
@@ -1,3 +1,11 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2002-2009
+ */
package jmathlib.core.interpreter;
import java.io.*;
@@ -20,15 +28,19 @@
return debugB;
}
- /**sets the debug flag
- @param _debug = should debug information be displayed*/
+ /**
+ * sets the debug flag
+ * @param _debug = should debug information be displayed
+ */
public static void setDebug(boolean _debug)
{
debugB = _debug;
}
- /**display a debug line to the standard output and the file MathLib.log
- @param text = the text to display*/
+ /**
+ * display a debug line to the standard output and the file MathLib.log
+ * @param text = the text to display
+ */
public static void debugLine(String text)
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-02-08 17:04:23
|
Revision: 835
http://mathlib.svn.sourceforge.net/mathlib/?rev=835&view=rev
Author: st_mueller
Date: 2009-02-08 17:04:20 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
removed applet-parameter from Interpreter-constructor
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2009-02-08 16:46:13 UTC (rev 834)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/GlobalValues.java 2009-02-08 17:04:20 UTC (rev 835)
@@ -10,10 +10,8 @@
package jmathlib.core.interpreter;
import java.io.*;
-import java.net.URL;
import java.util.Locale;
import java.util.Properties;
-import java.applet.Applet;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
@@ -34,12 +32,12 @@
/**A list of contexts*/
private ContextList contextList;
+ /** flag to indicate if JMathLib is running standalone or as applet,servlet */
+ private boolean runningStandalone = false;
+
/**Object to control function usage*/
private jmathlib.core.functions.FunctionManager functionManager;
- /** global pointer to applet */
- private Applet applet = null;
-
/**A pointer to the interpreter itself*/
private Interpreter interpreter;
@@ -59,16 +57,17 @@
* @param _interpreter = the Interpreter object
* @param _runningStandalone = true if this was run from an application
*/
- public GlobalValues(Interpreter _interpreter, boolean _runningStandalone, Applet _applet)
+ public GlobalValues(Interpreter _interpreter, boolean _runningStandalone)
{
+
+ // flag for stand alone or applet,servlet,...
+ runningStandalone = _runningStandalone;
+
// the list of contexts
contextList = new ContextList();
- // pointer to applet
- applet = _applet;
-
// the function manager for loading m-files class-files
- functionManager = new jmathlib.core.functions.FunctionManager(_runningStandalone, applet);
+ functionManager = new jmathlib.core.functions.FunctionManager(_runningStandalone);
// the graphics manager for plotting functions
graphicsManager = new jmathlib.core.graphics.GraphicsManager();
@@ -235,13 +234,14 @@
// load global properties from disc
try
{
- // check if JMathLib is running is applet or application
- if (applet != null)
+ // check if JMathLib is running as applet or application
+ if (!runningStandalone)
{
// running as applet
//System.out.println("properties applet " + getWorkingDirectory());
- URL url = new URL(applet.getCodeBase(), "JMathLib.properties");
- props.load( url.openStream() );
+ //URL url = new URL(applet.getCodeBase(), "JMathLib.properties");
+ InputStream in = GlobalValues.class.getResourceAsStream("../../../JMathLib.properties");
+ props.load( in); //url.openStream() );
}
else
{
@@ -280,7 +280,7 @@
public void storePropertiesToFile()
{
// do not try to store properties is an applet
- if (applet!=null)
+ if (!runningStandalone)
return;
// store properties back to file
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-02-08 16:46:13 UTC (rev 834)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-02-08 17:04:20 UTC (rev 835)
@@ -12,7 +12,6 @@
import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
import jmathlib.core.interfaces.MathLibOutput;
-import java.applet.Applet;
/**This is the main interface for the program. Any interface to the MathLib program would access
it through the functions exposed by this class.*/
@@ -30,26 +29,20 @@
/**for testing purposes additional throwing of errors can be enables */
public boolean throwErrorsB = false;
- /**Constructs the interpreter and sets the constants
- * @param _runningStandalone = true if this is being used from an application
- */
- public Interpreter(boolean _runningStandalone)
- {
- this(_runningStandalone, null);
- }
-
- /**Constructs the interpreter and sets the constants
+ /**
+ * Constructs the interpreter and sets the constants
* @param _runningStandalone = true if this is being used from an application
- * @param _applet pointer to applet structure if this is an applet and not an
- * application
*/
- public Interpreter(boolean _runningStandalone, Applet _applet)
+ public Interpreter(boolean _runningStandalone)
{
- runningStandalone = _runningStandalone;
+ // indicator if this is a stand alone application or
+ // if JMathLib is running as an applet or servlet or ... without
+ // direct access to the file system
+ runningStandalone = _runningStandalone;
// initialize global pointers, this pointer will be passed to
// all expressions for access to function manager, variable lists, contexts,...
- globals = new GlobalValues(this, runningStandalone, _applet);;
+ globals = new GlobalValues(this, runningStandalone);
// set output panel to NULL
// ?? needed? outputPanel is initialized with NULl anyway (see above)
@@ -60,7 +53,8 @@
}
- /**sets the panel to write any text to
+ /**
+ * sets the panel to write any text to
* @param _outputPanel = the panel to write to, must implement the
* MathLibOutput interface
*/
@@ -69,7 +63,8 @@
outputPanel = _outputPanel;
}
- /**returns the panel to write any text to
+ /**
+ * returns the panel to write any text to
* @return outputPanel = the panel to write to
*/
public MathLibOutput getOutputPanel()
@@ -77,7 +72,8 @@
return outputPanel;
}
- /**displays a string to the outputPanel
+ /**
+ * displays a string to the outputPanel
* @param text = the text to display
*/
public void displayText(String text)
@@ -86,7 +82,8 @@
outputPanel.displayText(text);
}
- /**saves the variable list
+ /**
+ * saves the variable list
*/
public void save()
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-02-12 21:13:19
|
Revision: 845
http://mathlib.svn.sourceforge.net/mathlib/?rev=845&view=rev
Author: st_mueller
Date: 2009-02-12 21:13:15 +0000 (Thu, 12 Feb 2009)
Log Message:
-----------
added some comments
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java
JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java
JMathLib/trunk/src/jmathlib/core/interpreter/VariableList.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java 2009-02-12 21:12:38 UTC (rev 844)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/RootObject.java 2009-02-12 21:13:15 UTC (rev 845)
@@ -1,3 +1,11 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2005-2009
+ */
package jmathlib.core.interpreter;
import java.io.*;
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java 2009-02-12 21:12:38 UTC (rev 844)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Variable.java 2009-02-12 21:13:15 UTC (rev 845)
@@ -1,3 +1,11 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2005-2009
+ */
package jmathlib.core.interpreter;
import jmathlib.core.tokens.*;
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/VariableList.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/VariableList.java 2009-02-12 21:12:38 UTC (rev 844)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/VariableList.java 2009-02-12 21:13:15 UTC (rev 845)
@@ -1,3 +1,11 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2005-2009
+ */
package jmathlib.core.interpreter;
import jmathlib.core.tokens.*;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <st_...@us...> - 2009-02-21 17:50:05
|
Revision: 861
http://mathlib.svn.sourceforge.net/mathlib/?rev=861&view=rev
Author: st_mueller
Date: 2009-02-21 17:49:55 +0000 (Sat, 21 Feb 2009)
Log Message:
-----------
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java
JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-02-21 17:49:12 UTC (rev 860)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Interpreter.java 2009-02-21 17:49:55 UTC (rev 861)
@@ -11,7 +11,7 @@
import jmathlib.core.tokens.*;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;
-import jmathlib.core.interfaces.MathLibOutput;
+import jmathlib.core.interfaces.JMathLibOutput;
/**This is the main interface for the program. Any interface to the MathLib program would access
it through the functions exposed by this class.*/
@@ -21,7 +21,7 @@
boolean runningStandalone;
/**panel used for displaying text*/
- private MathLibOutput outputPanel;
+ private JMathLibOutput outputPanel = null;
/**global pointers and values */
public GlobalValues globals = null;
@@ -44,10 +44,6 @@
// all expressions for access to function manager, variable lists, contexts,...
globals = new GlobalValues(this, runningStandalone);
- // set output panel to NULL
- // ?? needed? outputPanel is initialized with NULl anyway (see above)
- outputPanel = null;
-
// read preferences from a file on the disc or on the web
globals.loadPropertiesFromFile();
@@ -58,7 +54,7 @@
* @param _outputPanel = the panel to write to, must implement the
* MathLibOutput interface
*/
- public void setOutputPanel(MathLibOutput _outputPanel)
+ public void setOutputPanel(JMathLibOutput _outputPanel)
{
outputPanel = _outputPanel;
}
@@ -67,12 +63,23 @@
* returns the panel to write any text to
* @return outputPanel = the panel to write to
*/
- public MathLibOutput getOutputPanel()
+ public JMathLibOutput getOutputPanel()
{
return outputPanel;
}
+
/**
+ * write status message to GUI
+ * @param _status
+ */
+ public void setStatusText(String _status)
+ {
+ outputPanel.setStatusText(_status);
+ }
+
+
+ /**
* displays a string to the outputPanel
* @param text = the text to display
*/
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java 2009-02-21 17:49:12 UTC (rev 860)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/LexicalAnalyser.java 2009-02-21 17:49:55 UTC (rev 861)
@@ -1,3 +1,11 @@
+/*
+ * This file is part or JMathLib
+ *
+ * Check it out at http://www.jmathlib.de
+ *
+ * Author:
+ * (c) 2005-2009
+ */
package jmathlib.core.interpreter;
import jmathlib.core.tokens.*;
@@ -694,6 +702,7 @@
else
negative = false; // e.g. +4444
+ int numberOfSigns = 1;
// +++++-+-+-8
while (inspectNextChar()=='-' || inspectNextChar()=='+')
@@ -704,11 +713,26 @@
advance();
+ numberOfSigns++;
+
if (EOChars())
Errors.throwMathLibException("end of chars");
}
-
+ // looking for ++asdfasdf --asdfasdf
+ if ( ((nextChar=='+') && !negative && (numberOfSigns==2)) ||
+ ((nextChar=='-') && negative && (numberOfSigns==2)) )
+ {
+ // found ++ or --
+ if ( textChars.indexOf(inspectNextChar()) != -1 )
+ {
+ // found something like ++asdfasdf... oer --qweqwer..
+ ErrorLogger.debugLine("LexAna: ++asdf --sdfg "+nextChar);
+ nextToken = new UnaryOperatorToken(nextChar);
+ }
+
+ }
+
// e.g. if other than number return sign (plus/minus)
// e.g. -* -hello +foo +(3+4)
if (numberChars.indexOf(inspectNextChar())==-1 )
@@ -727,7 +751,7 @@
{
//++ or --
advance();
- //ErrorLogger.debugLine("LexAna: Increment/Decrement "+nextChar);
+ ErrorLogger.debugLine("LexAna: Increment/Decrement "+nextChar);
nextToken = new UnaryOperatorToken(nextChar); //, bracketLevel);
}
else
Modified: JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java
===================================================================
--- JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java 2009-02-21 17:49:12 UTC (rev 860)
+++ JMathLib/trunk/src/jmathlib/core/interpreter/Parser.java 2009-02-21 17:49:55 UTC (rev 861)
@@ -41,7 +41,7 @@
public OperandToken parseExpression(String expression)
{
// show indention for every logging message
- ErrorLogger.setDisplayIndent(true);
+ //ErrorLogger.setDisplayIndent(true);
lex.analyseExpression(expression);
//endOfTokens = false;
@@ -49,7 +49,7 @@
// parse ALL available Tokens
OperandToken expr = parseCommandList();
- ErrorLogger.setDisplayIndent(false);
+ //ErrorLogger.setDisplayIndent(false);
return expr;
}
@@ -59,12 +59,12 @@
public void setExpression(String expression)
{
// display indention while parsing
- ErrorLogger.setDisplayIndent(true);
+ //ErrorLogger.setDisplayIndent(true);
lex.analyseExpression(expression);
//endOfTokens = false;
- ErrorLogger.setDisplayIndent(false);
+ //ErrorLogger.setDisplayIndent(false);
}
/** parse remaining tokens of a m-function file or m-script file
@@ -72,12 +72,12 @@
public OperandToken parseRemainingExpression()
{
// display indention while parsing
- ErrorLogger.setDisplayIndent(true);
+ //ErrorLogger.setDisplayIndent(true);
// parse ALL available Tokens
OperandToken expr = parseCommandList();
- ErrorLogger.setDisplayIndent(false);
+ //ErrorLogger.setDisplayIndent(false);
return expr;
}
@@ -163,19 +163,7 @@
ErrorLogger.increaseIndent();
- // parsing is not useful if the next token will be a closing ")"
- // (e.g. who() or a.getColor() )
- //if ( isExpectedDelimiter(peekNextToken(), "elseif") ||
- // isExpectedDelimiter(peekNextToken(), "else") ||
- // isExpectedDelimiter(peekNextToken(), "end") )
- //{
- // ErrorLogger.decreaseIndent();
- // ErrorLogger.debugLine("Parser deli return");
- // return null;
- //}
-
-
- OperandToken retToken = null; // holds token to be returned
+ OperandToken retToken = null; // holds token to be returned
Token peekToken = peekNextToken(deliTyp); // holds next (actual) token
if (peekToken == null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|