-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jk/preserve unparsable input #227
Conversation
const vertex = buildMatrixVertex(parseResult.ast as ProcedureAst, address) | ||
dependencies.set(vertex, absolutizeDependencies(parseResult.dependencies, address)) | ||
this.dependencyGraph.addMatrixVertex(address, vertex) | ||
if (parseResult.errors.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of such checks, couldn't we make this.parser.parse(...)
return some object representing the result of parsing? Something like if (parseResult.isCorrectlyParsed())
would be nicer
@@ -941,7 +943,13 @@ export class HyperFormula { | |||
if (!(parsedCellContent instanceof CellContent.Formula)) { | |||
return [false, exampleTemporaryFormulaAddress] | |||
} | |||
const {ast} = this.parser.parse(parsedCellContent.formula, exampleTemporaryFormulaAddress) | |||
|
|||
const { ast, errors } = this.parser.parse(parsedCellContent.formula, exampleTemporaryFormulaAddress) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -60,6 +63,10 @@ import { | |||
WhiteSpace, | |||
} from './LexerConfig' | |||
|
|||
export interface FormulaParserResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be a lot simpler if we would have two different result classes? One having ONLY ast and one having ONLY errors? Because now we have to do all these ErrorAst sheningans just to have the Ast
, but we don't need Ast
anymore, as we don't store unparsable formulas in FormulaVertex
(which needed an Ast), but in ParserErrorVertex
instead. Do I think correctly?
} | ||
const {ast, hasVolatileFunction, hasStructuralChangeFunction, relativeDependencies} = cacheResult | ||
|
||
return {ast, hasVolatileFunction, hasStructuralChangeFunction, dependencies: relativeDependencies} | ||
return {ast, errors: [], hasVolatileFunction, hasStructuralChangeFunction, dependencies: relativeDependencies} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for having separate field for that
Co-Authored-By: Wojciech Czerniak <wojciech.czerniak@gmail.com>
Context
Introduces new vertex type
ParsingErrorVertex
which stores original user input.FormulaCellVertex
is not constructed if parsing error occures.Instead of returning
ErrorType.NAME
, parsing errors are represented asErrorType.ERROR
which corresponds to generic#ERROR!
.How has this been tested?
Types of changes
Related issue(s):
Checklist: