Hello Guys!
I would like to know how to implement in smalltalk expression parser. Something like Avi used in his DabbleDB for expressions in data cells. In ruby i can write something like that: Sheet.eval("expression goes there") and define method method_missing to parse calls to sheet cells. Can somebody say me how to make such things work in smalltalk? Cheers, Oleg _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> In ruby i can write something like that: Sheet.eval("expression goes
> there") and > define method method_missing to parse calls to sheet cells. Compiler evaluate: 'expression goes there' > Can somebody say me how to make such things work in smalltalk? The inspector (WAInspector) in the Halos also demonstrates it. Don't use this for strings you receive from unknown sources through the web. This is dangerous and people can do nasty things to your image and machine ... Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Oleg,
as Lukas said it is dangerous to evaluate any expression that a user may enter in an input field. I can suggest two approaches that may help you: 1. If the expressions are simple, you can use a regular expression matcher to make sure the input matches some predefined set of valid expressions (In VW there is the regex11 parcel). 2. Use something like SmaCC to generate a parser and "objectify" the expression. Then you can be confident that the expression is well formed and you can just send it a message like #eval. HTH, Andrés Lukas Renggli escribió: >> In ruby i can write something like that: Sheet.eval("expression goes >> there") and >> define method method_missing to parse calls to sheet cells. > > Compiler evaluate: 'expression goes there' > >> Can somebody say me how to make such things work in smalltalk? > > The inspector (WAInspector) in the Halos also demonstrates it. > > Don't use this for strings you receive from unknown sources through > the web. This is dangerous and people can do nasty things to your > image and machine ... > > Lukas > Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Oleg Richards
On 8/23/07, Oleg Richards <[hidden email]> wrote:
> Hello Guys! > > I would like to know how to implement in smalltalk expression parser. > Something like Avi used in his DabbleDB for expressions in data cells. Actually, in Dabble DB we are very careful not to expose anything that looks like code to the user (where code is defined as "anything that could have a syntax error"). Expressions are built up interactively through menus that show you the possible methods and arguments. Cheers, Avi _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Oleg Richards
Thanks..
I understand the way, Avi used in his DabbleDB. But there is a question. How did he stored expressions in his objects? I understand that you can create them, using menus.. But what should be done, when i choose operation and operand in menu? How to store it in my objects? And how to use this information later? Cheers, Oleg _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On 8/23/07, Oleg Richards <[hidden email]> wrote:
> Thanks.. > > I understand the way, Avi used in his DabbleDB. But there is a > question. How did he stored expressions in his objects? > I understand that you can create them, using menus.. But what should > be done, when i choose operation and operand in menu? > How to store it in my objects? And how to use this information later? The Interpreter Pattern in the "Design Patterns" book is a good first place to read. Avi _______________________________________________ Seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |