Skip to content
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

Syntax Tree: Add validations #93

Open
7 tasks
meganindya opened this issue Nov 14, 2021 · 1 comment
Open
7 tasks

Syntax Tree: Add validations #93

meganindya opened this issue Nov 14, 2021 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers unit-syntax-tree Related to the syntax tree module
Milestone

Comments

@meganindya
Copy link
Member

Description

generateFromSnapshot function in src/syntax/tree/syntaxTree.ts generates the syntax tree from a snapshot. However, there is no construct to validate the input snapshot.

Also, attachment checking functions and attaching functions have no connections — the idea is that the connection checks will externally be performed first before the connection is made. In this way, if a connection is known to be valid, we can skip the additional cost of reverifying. However, it would be nice to optionally check connection validity before the connections, as a direct step and not a two step process in certain use cases.

Objectives

Snapshot validation

  • Add a function to validate an input snapshot
    • Validate shape of snapshot components; refer ITreeSnapshotData, ITreeSnapshotExpression, ITreeSnapshotStatement, ITreeSnapshotBlock (discuss your approach before proceeding as the interfaces listed as TypeScript specific and JavaScript doesn't have them)
    • Validate attachments — whether the snapshot describes valid instruction or argument attachments
  • Call the snapshot validation function before generating the syntax tree from it, in generateFromSnapshot

Connection validation

  • Add an optional flag to attachArgumentCheck to indicate whether to perform a validation
  • Add an optional flag to attachInstructionBelowCheck to indicate whether to perform a validation
  • Add an optional flag to attachInstructionInsideCheck to indicate whether to perform a validation

This can be done as two separate PRs.

@meganindya meganindya added enhancement New feature or request good first issue Good for newcomers unit-syntax-tree Related to the syntax tree module labels Nov 14, 2021
@impAkshat
Copy link
Contributor

attachArgumentCheck, attachInstructionBelowCheck, attachInstructionInsideCheck and _attachInstructionCheck takes NodeId of connector and connecting node, however NodeId is generated inside __generateFromSnapshotData, __generateFromSnapshotExpression, __generateFromSnapshotStatement and __generateFromSnapshotBlock functions.

So as you mentioned in the issue

the idea is that the connection checks will externally be performed first before the connection is made.

for this, it requires to refactore the attachArgumentCheck, attachInstructionBelowCheck, attachInstructionInsideCheck and _attachInstructionCheck with different parameters.

Is this the case or I am going in wrong direction @meganindya.

@meganindya meganindya added this to the Release v0.3.0 milestone Feb 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers unit-syntax-tree Related to the syntax tree module
Projects
None yet
Development

No branches or pull requests

2 participants