Open tothtamas28 opened 7 months ago
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.
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.
This implies that if the regex terminal is mentioned, we should emit an error.
Consider the following definition:
The generated KORE symbol for
foo
is then the following:Notice how
format
is present in the input but not the output. This is becauseModuleToKORE
does not generateformat
for productions that have items other than terminals and non-terminals:https://github.com/runtimeverification/k/blob/61bd7894317815333c55964afc514c86efa1522f/kernel/src/main/java/org/kframework/backend/kore/ModuleToKORE.java#L1726
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.