Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Better use of the visitor design pattern #6

Merged
merged 2 commits into from
Jan 4, 2024
Merged

Better use of the visitor design pattern #6

merged 2 commits into from
Jan 4, 2024

Conversation

LFLCH
Copy link
Owner

@LFLCH LFLCH commented Jan 3, 2024

So far we did not use the accept method of the visitor design pattern in the child classes of the visitor (i.e interpreterVisitor)
It was because we had to use the children AST classes, written in the visitor.ts file, but those classes had a problem dealing with the "Abstract" AST nodes ("Expression", "RobotSymbol" and "Statement").
It was impossible to extend them, given that they are not generated as Interfaces from the current grammar.

In these modifications, we provide a modified version of the ast.ts file, that represents those abstract nodes as Interfaces.
It allow to correctly use the visitor design pattern in its child classes, and so, have a better code.

The best solution is still to modify the grammar, but given the remaining time, I think it is an acceptable solution.
It only requires to use a slightly modified version of the ast.ts file.

…re elegantly.

However this requires the use of a customized ast
@LFLCH
Copy link
Owner Author

LFLCH commented Jan 4, 2024

The ast file and the other files related (grammar.ts, module.ts) are now located in the folder src/language/representation.
The folder that contains the automatically generated files from the grammar file src/language/generated is not used anymore in imports.

@LFLCH LFLCH merged commit ed031ed into main Jan 4, 2024
@LFLCH LFLCH mentioned this pull request Jan 4, 2024
@LFLCH LFLCH deleted the visitor branch January 4, 2024 18:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant