Skip to content

Treat : as infix operator

Bitbucket Importer requested to merge topic/default/bitbucket-pr-345 into branch/2.6

Created originally on Bitbucket by piti118 (Piti Ongmongkolkul)

Currently the cell that is of the form function:range function:function range:function are not correctly parsed.

For example, =SUM(OFFSET(A1,1,1):C3) is parsed as

[
('SUM(', 'FUNC', 'OPEN'),
('OFFSET(', 'FUNC', 'OPEN'),
('A1', 'OPERAND', 'RANGE'),
(',', 'SEP', 'ARG'),
('1', 'OPERAND', 'NUMBER'),
(',', 'SEP', 'ARG'),
('1', 'OPERAND', 'NUMBER'),
(')', 'FUNC', 'CLOSE'),
(':C3', 'OPERAND', 'RANGE'), # note the colon
(')', 'FUNC', 'CLOSE')
]

This PR fix it such that it is parsed to

[
('SUM(', 'FUNC', 'OPEN'),
('OFFSET(', 'FUNC', 'OPEN'),
('A1', 'OPERAND', 'RANGE'),
(',', 'SEP', 'ARG'),
('1', 'OPERAND', 'NUMBER'),
(',', 'SEP', 'ARG'),
('1', 'OPERAND', 'NUMBER'),
(')', 'FUNC', 'CLOSE'),
(':', OP_IN, ''), # notice : is now treated as OP_IN
('C3', 'OPERAND', 'RANGE'),
(')', 'FUNC', 'CLOSE')
]

This PR also maintain backward compatibility of how the parser treat constant range such as A1:A2 or A1:3 as a single range.

This issue affect library such as pycel which the PR for the said library will be submitted shortly.

https://github.com/dgorissen/pycel/issues/17

Merge request reports

Loading