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

Validation of AST #25

Closed
Tracked by #5
Gashmob opened this issue Aug 22, 2024 · 0 comments · Fixed by #26
Closed
Tracked by #5

Validation of AST #25

Gashmob opened this issue Aug 22, 2024 · 0 comments · Fixed by #26
Labels
enhancement New feature or request
Milestone

Comments

@Gashmob
Copy link
Member

Gashmob commented Aug 22, 2024

User code cannot be fully trusted as good, it can contains error and they should be catched. So the AST must be validated. Using the previously created visitor structure we can check the whole structure.

@Gashmob Gashmob mentioned this issue Aug 22, 2024
11 tasks
@Gashmob Gashmob added the enhancement New feature or request label Aug 22, 2024
@Gashmob Gashmob added this to the v0.1.0 milestone Aug 22, 2024
Gashmob added a commit that referenced this issue Aug 23, 2024
Part of #25

This validator does nothing for now, it just throw for each expression.
@Gashmob Gashmob linked a pull request Aug 23, 2024 that will close this issue
Gashmob added a commit that referenced this issue Aug 23, 2024
Part of #25

This validator does nothing for now, it just throw for each expression.
Gashmob added a commit that referenced this issue Aug 28, 2024
Part of #25

It will be used to store context of ValidationVisitor easily. Instead of
creating a new member each time, just store it directly in the context.

The stack/unstack allow to have a different context if we need it
Gashmob added a commit that referenced this issue Sep 1, 2024
Part of #25

It will help to show understandable message
Gashmob added a commit that referenced this issue Sep 1, 2024
Part of #25

It helps to format message shown to user
Gashmob added a commit that referenced this issue Sep 1, 2024
Part of #25

Show a warning if value not used
Gashmob added a commit that referenced this issue Sep 1, 2024
Part of #25

Instead of using a pointer to parent, use std::stack of map.

There is at least one map in the stack (unstack cannot pop last map).
Gashmob added a commit that referenced this issue Sep 8, 2024
Part of #25

It set type of expressions (just literals for now) and check that last
expression is an int (return type of program)
Gashmob added a commit that referenced this issue Sep 12, 2024
Part of #25

- Check constant has a value
- Check declared type (if exists)
- Check assigned value (if exists)
  - Check assigned value == declared type (if exists)
- Check existence of at least type or value
Gashmob added a commit that referenced this issue Sep 14, 2024
Part of #25

- check name exists
Gashmob added a commit that referenced this issue Sep 15, 2024
Part of #25

- check name exists
- check it's not a constant
- check type equality
Gashmob added a commit that referenced this issue Sep 19, 2024
Part of #25

- check left operand
- check right operand
- check calcul can be done between types

Also add early return when type given by sub-expression is nullptr: it
means there is an error, so no need to go further in this expression
Gashmob added a commit that referenced this issue Sep 19, 2024
Part of #25

It ease the dump of types when it's aliased types
Gashmob added a commit that referenced this issue Sep 22, 2024
Part of #25

All cases are covered (at least all I can think of)
Gashmob added a commit that referenced this issue Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant