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

LAYOUT?-CF not accepted in Sdf3 Statix #78

Closed
Virtlink opened this issue Oct 6, 2021 · 6 comments
Closed

LAYOUT?-CF not accepted in Sdf3 Statix #78

Virtlink opened this issue Oct 6, 2021 · 6 comments
Labels
C-Bug Category: bug. Not working as expected

Comments

@Virtlink
Copy link
Contributor

Virtlink commented Oct 6, 2021

The Statix specification correctly rejects any optional sorts (A?) in context-free syntax. However, the LAYOUT? sort is special in kernel syntax, and I think it should be allowed:

Section-CF.Section = "section" SectionName-CF LAYOUT?-CF Definition*-CF

Optionals (A?) are not allowed in context-free syntax

Here is a project with WebDSL syntax in which this is an issue, in WebDSL-Core.sdf3, line 49:

📂 webdsl.zip

@Virtlink Virtlink added the C-Bug Category: bug. Not working as expected label Oct 6, 2021
@Gohla
Copy link
Member

Gohla commented Oct 7, 2021

If this production is in a kernel syntax section (syntax), that error will not occur. However, then you will get an error that the sort of the production is not of kind kernel. Sorts of kind kernel would be definable in a sorts section, but it seems that the sorts section is desugared into context-free sorts in SDF3, making it impossible to define kernel sorts. Maybe a quick fix would be to have -CF and -LEX symbols be of kind kernel.

@Gohla
Copy link
Member

Gohla commented Oct 7, 2021

Solved by metaborg/sdf@3579ddd. It is possible to define the production without errors as follows:

sorts

  Section SectionName Definition

syntax

  Section-CF.Section = "section" SectionName-CF LAYOUT?-CF Definition*-CF

There is no checking whether the -CF sorts are context-free sorts though.

@Gohla Gohla closed this as completed Oct 7, 2021
@Virtlink
Copy link
Contributor Author

Virtlink commented Oct 7, 2021

Okay, previously doing this would give an error because Section-CF would be a context-free kernel sort declared in a (non-context-free) kernel syntax section, requiring the section to be changed to context-free syntax.

@Gohla
Copy link
Member

Gohla commented Oct 7, 2021

There seems to be a bug where the SDF3->Stratego signature generator fails on LAYOUT?-CF in those kernel syntax productions, I will have a look at that tomorrow.

@Virtlink
Copy link
Contributor Author

Virtlink commented Oct 7, 2021

In Spoofax 3 it generates the following Stratego for it:

OpDecl("Section", FunType(
    [ ConstType(SortNoArgs("SectionName"))
    , OPT(LAYOUT(){OfSort(SORT("TYPE"))}){OfSort(SORT("TYPE"))}
    , ConstType(Sort("List", [ConstType(SortNoArgs("Definition"))]))
    ], ConstType(SortNoArgs("Section"))
))

In Spoofax 2 it seems to be:

OpDecl("Section", FunType(
    [ ConstType(SortNoArgs("SectionName"))
    , ConstType(Sort("List", [SortNoArgs("Definition")]))
    ], ConstType(SortNoArgs("Section"))
))

Spoofax 2 is correct. Apparently they are not using the same version of the signature generator?

@Gohla
Copy link
Member

Gohla commented Oct 8, 2021

Should be fixed metaborg/sdf@d88c75a (untested)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Bug Category: bug. Not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants