Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2008

Tip: Looking for answers? Try searching our database.

Expression Parser Utility

Thread view: 
Dexter - 20 Mar 2008 21:32 GMT
This set of Java classes allows parsing mathematical expression, that
may be used from Java programs. Suitable use for this utlity include
graphing tools, calculators, etc

Download for free at  http://www.britishcomputercolleges.com/prog/java/parser2.html
Eric Sosman - 20 Mar 2008 22:30 GMT
> This set of Java classes allows parsing mathematical expression, that
> may be used from Java programs. Suitable use for this utlity include
> graphing tools, calculators, etc
>
> Download for free at  http://www.britishcomputercolleges.com/prog/java/parser2.html

    Perhaps I'm just a suspicious sort of person, but I'm not
exactly avid to dump some unknown person's precompiled classes
into my JRE ...

    FWIW, I've written a similar sort of thing.  It accepts a
wider class of expressions, but has no provision for complex
arithmetic.  Also, mine compiles the expression to class byte
codes and loads them, so they're executed directly by the JVM
and are eligible to be JIT-compiled.  If anyone's interested,
drop me a note and I'll send back the source.

Signature

Eric.Sosman@sun.com

Dexter - 20 Mar 2008 22:47 GMT
> > This set of Java classes allows parsing mathematical expression, that
> > may be used from Java programs. Suitable use for this utlity include
[quoted text clipped - 15 lines]
> --
> Eric.Sos...@sun.com

Eric! You work at Sun and I work at home mostly killing time.
The programming skill I have may be ranked in minor league

Asad
Stefan Ram - 20 Mar 2008 23:00 GMT
>arithmetic.  Also, mine compiles the expression to class byte

 With the compiler-tool classes from the JDK, Java expressions
 can be compiled at run-time. An example how to do this:

http://www.purl.org/stefan_ram/pub/evaluating-expressions-with-java
Eric Sosman - 21 Mar 2008 02:43 GMT
>> arithmetic.  Also, mine compiles the expression to class byte
>
>   With the compiler-tool classes from the JDK, Java expressions
>   can be compiled at run-time. An example how to do this:
>
> http://www.purl.org/stefan_ram/pub/evaluating-expressions-with-java

    Will those classes work if only a JRE (no JDK) is
installed?  I skimmed their documentation and it seemed
to me that a pure JRE environment would not support them;
was I wrong?  (If so, I expended some needless effort --
but I learned a good deal about bytecode along the way.)

Signature

Eric Sosman
esosman@ieee-dot-org.invalid

Stefan Ram - 21 Mar 2008 03:36 GMT
>>With the compiler-tool classes from the JDK, Java expressions
>>can be compiled at run-time. An example how to do this:
>> http://www.purl.org/stefan_ram/pub/evaluating-expressions-with-java
>Will those classes work if only a JRE (no JDK) is installed?

 IIRC, they will not work without a JDK.  That's why I wrote
 »from the JDK« as quoted above.

 This is similar to the SQL implementation.

 I am actually saddened by the omission of both features from
 the JRE. It would be great if one would be able to rely on an
 SQL implementation and a Java compiler everywhere where there
 is a JRE.

 An SQL implementation would be useful for ... (I do not need
 to explain this here).

 With a Java compiler, one could use Java for Java scripting.
 For example, in a Java editor, power users could write the
 Editor's macros in Java itself, being able to use all of Javas
 features.
Eric Sosman - 21 Mar 2008 03:40 GMT
>>> With the compiler-tool classes from the JDK, Java expressions
>>> can be compiled at run-time. An example how to do this:
[quoted text clipped - 3 lines]
>   IIRC, they will not work without a JDK.  That's why I wrote
>   »from the JDK« as quoted above.

    Thanks; that's what I thought.  I wanted a class that
would work with a "no frills" JRE, so I decided not to
rely on the Compiler machinery.

>   This is similar to the SQL implementation.
>
>   I am actually saddened by the omission of both features from
>   the JRE. It would be great if one would be able to rely on an
>   SQL implementation and a Java compiler everywhere where there
>   is a JRE.

    Yes.  I imagine it would make the Java download somewhat
larger, but if it's not *too* much larger it would be a
worthwhile addition.

Signature

Eric Sosman
esosman@ieee-dot-org.invalid

Arne Vajhøj - 22 Mar 2008 02:54 GMT
>>>> With the compiler-tool classes from the JDK, Java expressions
>>>> can be compiled at run-time. An example how to do this:
[quoted text clipped - 7 lines]
> would work with a "no frills" JRE, so I decided not to
> rely on the Compiler machinery.

Java 1.6 support the ScriptEngine with JavaScript - JavaScript
has this nice eval function and JavaScript is very inspired by
Java when it comes to math. Very easy solution !

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.