Skip to content

Commit

Permalink
Another iteration of resolving comments from the PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotes committed May 13, 2024
1 parent 31cd790 commit 25c248c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions hugo/content/docs/learn/workflow/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ flowchart TD
D(["4. Generate the AST"]);
E(["5. Resolve cross-references"]);
F(["6. Create validations"]);
G(["7. Generate your artifacts"]);
G(["7. Generate artifacts"]);
H(["Find advanced topics"]);
A --> B --> C --> D --> E --> F --> G ~~~ H;
G -- for each feature --> C;
Expand All @@ -37,7 +37,7 @@ This is the workflow we recommend for developing a language with Langium. It is
This simple introduction can be seen as three main parts:

* setting up your project environment (1.+2.): this is only done once
* specifying the language features (3.-7.): this cycle you need to reiterate for each new language feature
* specifying the language features (3.-7.): this cycle you need to reiterate for each new language feature or grammar change iteration
* everything advanced (8.): The limit of the common workflow is reached here. For specific questions you can find answers in the [recipes](/docs/recipes).

While the first part is straight-forward, the last part is about advanced topics that differ from project to project.
Expand Down Expand Up @@ -71,7 +71,7 @@ The cross-references are used to resolve references between language elements (b

From here we have a fully utilized AST. Now every input file that matches the syntax will be accepted. But we want to have more control over the input. We want to check if the input is semantically correct. This is done by creating _validations_. They are used to check the input against a set of rules. If the input does not match the rules, an error will be thrown.

### [7. Generate your artifacts](/docs/learn/workflow/generate_everything)
### [7. Generate artifacts](/docs/learn/workflow/generate_everything)

Now you have a fully working language. You can generate whatever you want from the input. This can be code, documentation, or anything else. You can use the AST to traverse the input and generate the output.

Expand Down
4 changes: 2 additions & 2 deletions hugo/content/docs/learn/workflow/generate_ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ It will create the following files (depending on your given Langium configuratio

An AST of your language is now ready to be get parsed. One important concept in Langium are _cross-references_. With them you can reference other elements in your language. For example, you can reference a variable in a function call. The AST will contain a reference to the variable. This is useful for code analysis and transformation. Technologies like ANTLR or other parser-only generators do not support this feature. For them you are forced to resolve these references in-place everytime the developer is confronted with them.

After this generation steps, cross-references are not resolved yet. This is done in the next step.
After these generation steps, cross-references are not resolved yet. This is done in the next step.

## Example

Expand Down Expand Up @@ -95,7 +95,7 @@ expect(model.persons).toHaveLength(2);
expect(model.persons[0].name).toBe("John");
expect(model.persons[1].name).toBe("Jane");
expect(model.greetings).toHaveLength(2);
//be aware of the fact that the following checks will fail, because the cross-references are not resolved yet
//be aware of the fact that the following checks will fail at this point, because the cross-references are not resolved yet
expect(model.greetings[0].person.ref?.name).toBe("John");
expect(model.greetings[1].person.ref?.name).toBe("Jane");
```
Expand Down
2 changes: 1 addition & 1 deletion hugo/content/docs/learn/workflow/generate_everything.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "7. Generate your artifacts"
title: "7. Generate artifacts"
weight: 800
url: /docs/learn/workflow/generate_everything
---
Expand Down
4 changes: 2 additions & 2 deletions hugo/content/docs/learn/workflow/resolve_cross_references.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ graph TB

## Resolution of cross-references

As already hinted, you can implement a scope provider and a scope computation. Fortunately, Langium comes with default implementations for both. But eventually as your language grows, you might want to implement your own strategy because the default is not sufficient. In the follwoing sections I will sketch how to interpret their interfaces.
As already hinted, you can implement a scope provider and a scope computation. Fortunately, Langium comes with default implementations for both. But eventually as your language grows, you might want to implement your own strategy because the default is not sufficient. In the following sections the interpretation of the involved interfaces will be sketched.

### Scope provider

Expand All @@ -96,7 +96,7 @@ A _scope_ is a collection of AST nodes that are represented by the `AstNodeDescr

The _description_ is like a (string) path through the AST of a document. It can be also seen as a tuple of document URI, JSON path, name and type of the AST node.

A _reference info_ contains the concrete AST reference (which points to nothing yet). The info also has a the parent AST node (a so-called container) of the reference and the property name under which you can find the reference under its container. In the form of this tuple (`container`, `property`, `reference`) Langium visits all cross-references using the scope providers `getScope` method.
A _reference info_ contains the concrete AST reference (which points to nothing yet). The info also has a the parent AST node (a so-called container) of the reference and the property name under which you can find the reference under its container. In the form of this tuple (`container`, `property`, `reference`) Langium visits all cross-references using the scope provider's `getScope` method.

```ts
export interface ScopeProvider {
Expand Down

0 comments on commit 25c248c

Please sign in to comment.