[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Expression parser

Expression parser

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Pages: 1  2  3  4  5 

Posted by Georgios   (1 post)  [Biography] bio
Date Reply #60 on Wed 03 Nov 2010 08:03 PM (UTC)
Message
Hello Nick

As I can read from your comments and forum messages your expression parser is what I am looking for. The only problem is that I have to use it in a micro controller (ATMEL AVR) in C language.
A post from Jorick at 7th August 2007 has a similar situation (to change from c++ to c).
Have you the code in c ? Or any suggestion to port your code in c ?

Best regards
Georgios
[Go to top] top

Posted by Nick Gammon   Australia  (23,042 posts)  [Biography] bio   Forum Administrator
Date Reply #61 on Wed 03 Nov 2010 08:39 PM (UTC)
Message
The whole design is based on the way C++ works (like, getting variables by reference). To do it for C would be a rewrite.

Would the controller support Lua? That compiles in C. However I believe some micro chips have a different architecture that doesn't work with Lua.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Thierry   (5 posts)  [Biography] bio
Date Reply #62 on Fri 07 Sep 2012 08:53 PM (UTC)
Message
Hello

Suppose a user enters an expression like this: (TT_123 * 10)/PT_870

How can I list the two parameters (TT_123 and PT_870) before evaluation to add the assignment
p[TT_123] = 100.0; (for example)
p[PT_870] = 0.56; (for example)

Thanks for your help

Thierry
[Go to top] top

Posted by Nick Gammon   Australia  (23,042 posts)  [Biography] bio   Forum Administrator
Date Reply #63 on Fri 07 Sep 2012 11:50 PM (UTC)

Amended on Sat 08 Sep 2012 07:51 AM (UTC) by Nick Gammon

Message
It's not designed to do that right now. I gather you want to have it "query" for a variable value at runtime, is that right?

Non-defined variables currently default to zero. In particular around line 509:


      // not a function? must be a symbol in the symbol table
      double & v = symbols_ [word]; // get REFERENCE to symbol table entry


This creates the symbol if it doesn't exist, and it will default to zero. You would need to alter that line to do a lookup to see if the symbol exists, and if not have some way of obtaining it (eg. a callback function).

What might work could be to parse twice. First time you get zeroes for each symbol. Then look at the symbol table list to see what symbols get added. Change their values, and re-parse.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Thierry   (5 posts)  [Biography] bio
Date Reply #64 on Sat 08 Sep 2012 07:03 AM (UTC)
Message
Hello

Yes, I need to get the information at run time. I scan the symbols map, update the values and call Evaluate a second time .... Working fine !!!

Thanks for that great class ... It will be used in the next release of a freeware called Genesis (www.tgmdev.be), an OPC data acquisition utility for people involved in process automation.

Thierry
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


208,520 views.

This is page 5, subject is 5 pages long:  [Previous page]  1  2  3  4  5 

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]