Skip to content

Feature: Semantic validation #11

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

martin-azpillaga
Copy link

@martin-azpillaga martin-azpillaga commented Jun 7, 2023

Inspired by issue #1, this PR implements semantic validation for identifiers in the calc language.

Following the rules of most mainstream programming languages, identifiers need to be declared before usage, and cannot be declared multiple times.

In the case of calc, the editor will report errors when:

  • More than one input statements declare the same identifier
    inputs
  • An identifier used in a calculation expression has not been declared in previous lines
    calculations
  • An identifier used in an output statement has not been declared in previous lines
    outputs

Instead of an ANTLR listener or visitor, a simple parse tree walker is used to check the relevant nodes.
Additional validation tests have been added to the parsingTest file.
The features of the editor are now documented in the readme.

@martin-azpillaga martin-azpillaga changed the title Feature semantic validation Feature: Semantic validation Jun 8, 2023
@martin-azpillaga martin-azpillaga marked this pull request as ready for review June 8, 2023 15:37
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.

1 participant