Hi Eike, that's a lot of useful information!

On Thu, 24 Feb 2005 13:33:10 +0100, Eike Rathke <[EMAIL PROTECTED]> wrote:
> Hi Kohei,
> 
> On Wed, Feb 23, 2005 at 10:42:14 -0500, Kohei Yoshida wrote:
> 
> > You're right on!  This helps tremendously.  :-)  This mechanism is
> > still a bit complicated, but I will try to understand it slowly but
> > surely.
> 
> I'd do it differently in a new implementation, but I don't think it
> would be less complicated ;-)

:-)

> 
> > Ultimately, I'd like to see how a given string of formula, say,
> > "=B5*2+(C2/D10)" gets transformed into an array of ScToken's for later
> > processing of that formula.
> 
> If you want to dive into it: compile sc/source/core/tool/compiler.cxx
> with debug and set breakpoints at ScCompiler::CompileString() and
> ScCompiler::CompileTokenArray(). If you enter a formula cell, first
> CompileString() is called that transforms the string into tokens, then
> CompileTokenArray() is called that creates the RPN array in its final
> form.

Thanks for this info. :-) This is what I was trying to find through
reading the source.

> 
> > My goal is to create a similar
> > functionality in my UNO component so that I can transform an arbitrary
> > formula string into a standard form of linear or polynomial equation.
> > This way I can apply all kinds of mathematical algorithms to that
> > equation to do some fun stuff. ;-)
> >
> > Or, could this functionality (i.e. tokenization of a formula string)
> > be somehow exported via the API?  Is that technically achievable?
> > What would be the difficulty level?
> 
> It can't be exported via API, as the compiler and the resulting token
> array would need access to internal document structures. I suggest you
> take a look at Boost's Spirit parser framework, see
> http://boost.org/libs/spirit/index.html

Looks very nice.  I should definitely look into this.  I may just be
able to use this for my purpose.

> and/or search the web for recursive-descent parser, with or without RPN.
> There are many sample sources. For more complex grammars, tools like
> lex/flex and yacc/bison may be helpful.

Thanks.  Will take a look.

Thanks again for the useful information!

Kohei

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to