Skip to content

Declaring nodes when they're used #1615

Answered by msujew
stutrek asked this question in Q&A
Jul 30, 2024 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Hey @stutrek,

We had to solve a very similar issue in our Langium based implementation of SQL. Generally, Langium uses the name property as a convention to make an element available for referencing. However, it doesn't actually have to be the name property explicitly, you can use any property to make an element visible, even a self reference.

For your use case, this requires essentially three parts:

  1. Adjust the grammar to make elements of type InitialConnection and SecondConnection referencable:
Node:
    name=ID ('[' (settings+=Setting)* ']')? ('{' Newline* (children+=Node*)+ '}')? Newline+;

InitialConnection:
    (nodes+=[RefItem:ID] ','?) connectionType=ConnectionToken (to+=SecondCon…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@stutrek
Comment options

Answer selected by stutrek
Comment options

You must be logged in to vote
1 reply
@msujew
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants