Own parser necessary? #440
Replies: 5 comments
-
Hello, That's an interesting approach. Very clever use of JS features. But doesn't that mean that you have to evaluate the whole workbook each time a change is made? By keeping the dependency tree we wanted to cut the workload, we can limit it to the dependants of a changed cell. Relative references help us handle CRUD and copy/cut/paste operations. Thanks to them we can update the relative references and keep the absolute ones. We can also perform some optimizations for ranges and memory footprint. Even batch some of them and calculate later, when the result is actually needed. All of that would not be possible or a lot harder to achieve with an eval. You can read more about the architecture in our docs: https://handsontable.github.io/hyperformula/guide/key-concepts.html If you have more questions, shoot. I'll be happy to answer. |
Beta Was this translation helpful? Give feedback.
-
I can keep also the dependency tree. Getting the cell references out of the cell formulas I use simple regex. No special parser. I can get absolute Cells, relative cells and also cross references to other sheets. I don't have copy/paste functions. Hyperformula has much more features. I am not sure if I would have boundaries on some features with my approach. |
Beta Was this translation helpful? Give feedback.
-
Then your architecture is not that different. We're using regex'es as well. They are just encapsulated as a parser module. Later they are stored as an internal structure and evaluated with an interpreter. My guess, you have to parse and store the references somewhere, your interpreter is JS eval. It's hard to do it differently. Do you have your project anywhere online, GitHub maybe? I would love to take a look. |
Beta Was this translation helpful? Give feedback.
-
It's not open source for now because it isn't even in alpha. I think about replacing it with hyperformula. Just wanted to give inspiration to another approach. Writing an own interpreter is much work. Therefore I used js which is also very fast. |
Beta Was this translation helpful? Give feedback.
-
I think we may close this discussion for now. Thanks for your input 👍 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
This should be just an inspiration and no critics. I think there is no need for an additional parser because javascript is a parser itself (and also very fast)?
I develop my own xls2js library right now based on the old formulajs project. I use javascript itself as a parser and my only implementation logic is to get the cell references and create (a lot) js code.
My approach is that I use javascript's eval function to execute the cell code so that no additional parser is necessary(?).
I evaluate a cell recursively and create code backwards. It creates a lot code lines but is executed very fast by javascript. Example:
evaluate a cell
getCellValue("B2")
would be translated to following js:
Beta Was this translation helpful? Give feedback.
All reactions