Skip to content

Conversation

@johannesboyne
Copy link
Contributor

Some Excel users start formulas always with a =+ and thus, being able to have an option to keep even noop prefixes would be nice. E.g., in a formula like =+SUM(H8:H11)+-H12+(-H13).

@psalaets
Copy link
Owner

Thanks for contributing. I am reviewing your changes.

Are prefix operators expected to be kept everywhere or only at the front of the formula?

Example:

tokenize('SUM(1, +2)', {keepPrefixOperators: true})

returns

[
  { value: 'SUM', type: 'function', subtype: 'start' },
  { value: '1', type: 'operand', subtype: 'number' },
  { value: ',', type: 'argument', subtype: '' },
  // A
  { value: '2', type: 'operand', subtype: 'number' },
  { value: '', type: 'function', subtype: 'stop' }
]

Expected a token for the + prefix operator at A

@johannesboyne
Copy link
Contributor Author

Happy to contribute!
From our perspective, we would always require all tokens the user used in the formula. Even if they are unused or not necessary. For example, the following would make a lot of sense to us:

tokenize('=+SUM(1, +2)', {keepPrefixOperators: true})
/* (somewhat pseudo return)
[
  { value: '=', type: 'operand', required_for_calculation: false},
  { value: 'SUM', type: 'function', subtype: 'start', required_for_calculation: true },
  { value: '1', type: 'operand', subtype: 'number', required_for_calculation: true },
  { value: ',', type: 'argument', subtype: '', required_for_calculation: true },
  { value: '+', type: 'operand', required_for_calculation: false},
  { value: '2', type: 'operand', subtype: 'number', required_for_calculation: true  },
  { value: '', type: 'function', subtype: 'stop', required_for_calculation: true  }
]
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants