Hi all,

there exists a tutorial in the Wiki, how to implement new functions. It might be helpful for changes on an existing function as well.

https://wiki.openoffice.org/wiki/Calc/Implementation/Spreadsheet_Functions

Kind regards,
Regina

[email protected] schrieb am 19.01.2024 um 16:35:
https://bz.apache.org/ooo/show_bug.cgi?id=128585

--- Comment #2 from [email protected] ---
Formula parsing seems to work in stages:

In main/sc/source/ui/view/viewfunc.cxx, method ScViewFunc::EnterData() calls
ScCompiler::CompileString(), which lexes "=IF(TRUE;)" (the 2nd line in my
original post) into:
[ocIf, ocOpen, ocPush, ocSep, ocClose]

This is then passed to ScCompiler::CompileTokenArray() which is implemented in
its parent class, FormulaCompiler::CompileTokenArray(), in file
main/formula/source/core/api/FormulaCompiler.cxx. This then parses the lexed
tokens into the correct structure for the formulas.

Eventually that somehow arrives in ScInterpreter::ScIfJump() from file
main/sc/source/core/tool/interpr1.cxx for actual execution.

The problem happens in FormulaCompiler::Factor(),
in the "else if (eOp == ocIf || eOp == ocChose)" case,
where it expects to find an expression for the 2nd parameter, but gets ocSep
(";") instead. This generates an error during the call to Expression().

So the lexing is definitely correct, but we need to patch the parsing and
possibly the execution.


Reply via email to