Skip to content

Semantic Analysis #4

Description

@lazzy-cipher

With parsing done and tested, it is time to implement semantic analysis.

First, all language rules must be defined. A language rule is syntax that is not allowed in the language, but is allowed in the grammar.

For instance, declaring the same variable twice within the same scope is illegal, but will not be caught by the grammar.

Note: language rules only check for illegal syntax. For instance, "an undeclared variable can be declared" is not a valid language rule for the purpose of semantic analysis, it must be a forbidden action.

After all the rules are defined, the AST should be walked (in one or two passes) along with symbol tables and check every rule.

Semantic analysis should not fail as soon as it enters an error, but instead should report a clear error message to the end user.

After semantic analysis is done, a boolean reporting whether it was successful or not should be returned, indicating whether it can be interpreted by the upcoming VM.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions