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

ModuleToKORE silently absorbs format attribute #4077

Open
tothtamas28 opened this issue Mar 5, 2024 · 3 comments
Open

ModuleToKORE silently absorbs format attribute #4077

tothtamas28 opened this issue Mar 5, 2024 · 3 comments

Comments

@tothtamas28
Copy link
Contributor

Consider the following definition:

module FORMAT
    syntax Foo ::= r"foo" Bar [symbol(foo), format("%2")]
    syntax Bar ::= "bar"
endmodule

The generated KORE symbol for foo is then the following:

symbol Lblfoo{}(SortBar{}) : SortFoo{} [constructor{}(), functional{}(), injective{}(), org'Stop'kframework'Stop'attributes'Stop'Location{}("Location(2,20,2,58)"), org'Stop'kframework'Stop'attributes'Stop'Source{}("Source(/home/ttoth/git/pyk/format.k)"), symbol'Kywd'{}("foo")]

Notice how format is present in the input but not the output. This is because ModuleToKORE does not generate format for productions that have items other than terminals and non-terminals:

Does it make sense to have format only in KAST and not in KORE? If not, we should add a validation pass that emits an error if format is put on such a production.

@Baltoli
Copy link
Collaborator

Baltoli commented Mar 5, 2024

The KAST and KORE format attributes are different; the LLVM backend can't handle regex terminals in the same way as the frontend. The underlying issue is turning a regex expression into a string, but maybe we should allow the user to pass the attribute through so long as they don't mention the regex terminal.

@tothtamas28
Copy link
Contributor Author

Possibly related: there's already an error that enforces format on productions with regex terminals:

[Error] Compiler: Expected format attribute on production with regular
expression terminal.
        Source(/home/ttoth/git/pyk/format.k)
        Location(2,20,2,44)
        2 |         syntax Foo ::= r"foo" Bar [symbol(foo)]
          .                        ^~~~~~~~~~~~~~~~~~~~~~~~
[Error] Compiler: Had 1 structural errors.

@Baltoli
Copy link
Collaborator

Baltoli commented Mar 7, 2024

This implies that if the regex terminal is mentioned, we should emit an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants