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

getAllReachableRules should return implicit ID rule #1151

Open
cdietrich opened this issue Aug 15, 2023 · 1 comment · May be fixed by #1152
Open

getAllReachableRules should return implicit ID rule #1151

cdietrich opened this issue Aug 15, 2023 · 1 comment · May be fixed by #1152
Labels
bug Something isn't working

Comments

@cdietrich
Copy link
Contributor

cdietrich commented Aug 15, 2023

getAllReachableRules should return implicit ID rule but currently does not.
this leads to error initializing a parser based on a imported grammar
that only uses rules that call ID implicitely

grammar-util.test.ts

test('ID implicit called should be returned by getAllReachableRules', async () => {
        // [A] is short for [A:ID] thus the ID rule is needed by the parser and getAllReachableRules should return it
        const input = `
            grammar HelloWorld

            entry Model: A|B;
            A: name=STRING;
            B: ref=[A];
            terminal ID: /[_a-zA-Z][\w_]*/;
            terminal STRING: /"(\\.|[^"\\])*"|'(\\.|[^'\\])*'/;
        `;
        const output = await parse(input);

        // act
        const reachableRules = [...getAllReachableRules(output.parseResult.value, true)].map(r => r.name);

        // assert
        expect(reachableRules).toContain('ID');
        // currently fails with AssertionError: expected [ 'Model', 'A', 'B', 'STRING' ] to include 'ID'
    });
@cdietrich cdietrich added the bug Something isn't working label Aug 15, 2023
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 15, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 15, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 15, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 15, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 15, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 16, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 16, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 16, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
cdietrich added a commit to cdietrich/langium that referenced this issue Aug 16, 2023
Fixes eclipse-langium#1151

Signed-off-by: Christian Dietrich <christian.dietrich.opensource@gmail.com>
@spoenemann
Copy link
Contributor

As mentioned in #1152, there is no magic/implicit usage of the ID rule. In the given example, Langium uses the STRING rule because that's what is assigned to the name property. I propose to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants