Conversation
Lex a name that starts with a cell reference and then a period, as one token. `CH4.as.CO2e` lexed as the range `CH4` followed by an unknown `.as.CO2e`, so `parse` refused the formula. Dotted sheet names broke similarly: `TS1.5!B7` and `EO9904.2!mthend` (both in `benchmark/formulas.json`) lexed as `range` `unknown` `context` `!` `range`. A period after a range is one of two things: - it opens a trim operator (`.:`, `.:.`), and the range still ends; - it continues a name, and that must overrule the lexing of a range -- but only where that range text plus a period is valid as a name (Or it may dereference a field of linked data in that cell. But that syntax is not supported yet, and anyway Excel's parser may well lex it as a name.) New helper function `periodContinuesName` checks this when that period is hit: - the period must not be followed by a `:` - the period must be preceded by a run of `[A-Za-z0-9]` ... which starts with a letter ... and is not itself preceded by `$` or `[` or `]` (the characters that are valid in a range and not in a name). That check is enough, because it is reached only within `lexRange`, so we know the preceding characters are valid in a range token.
The comment said Excel writes the reference unquoted. That is what the formula bar shows; the file gets 'TS1.5'!B7. Measured on Excel for Mac, typed in and hand-written into <f> alike, and on both sides of the resave. The test is unaffected: Excel accepts the unquoted spelling as input, which is why the lexer has to read it.
Owner
|
I have made a simpler fix to this in #70. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lex a name that starts with a cell reference and then a period, as one token.
CH4.as.CO2elexed as the rangeCH4followed by an unknown.as.CO2e, soparserefused the formula.Dotted sheet names broke similarly:
TS1.5!B7andEO9904.2!mthend(both inbenchmark/formulas.json) lexed asrangeunknowncontext!range.A period after a range is one of two things:
.:,.:.), and the range still ends;(Or it may dereference a field of linked data in that cell. But that syntax is not supported yet, and anyway Excel's parser may well lex it as a name.)
New helper function
periodContinuesNamechecks this when that period is hit:the period must not be followed by a
:the period must be preceded by a run of
[A-Za-z0-9]... which starts with a letter
... and is not itself preceded by
$or[or](the characters that are valid in a range and not in a name)That check is enough, because it is reached only within
lexRange, so we know the preceding characters are valid in a range token.