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

Document ... in the K User Manual #4021

Open
tothtamas28 opened this issue Feb 21, 2024 · 2 comments
Open

Document ... in the K User Manual #4021

tothtamas28 opened this issue Feb 21, 2024 · 2 comments

Comments

@tothtamas28
Copy link
Contributor

The symbol ... is syntactic sugar for a few different things that are mentioned in certain parts of the K Tutorial.

In the K User Manual, there's only a single mention:

framing `...` to indicate the missing cells, they will receive the default

It'd be nice to have a dedicated section in the K User Manual that describes all uses of ... in one place as a reference for the feature.

Documented uses of ...

In a <k> cell:

Here we have placed the symbol `...` immediately prior to the `</k>` which ends

In a cell containing other cells:

second is that we have introduced the concept of `...` once again. When a cell

In a cell containing a Map:

Finally, we have used the `...` syntax on a cell containing a Map. In this

In a cell containing a List:

The `...` syntax is allowed on cells containing lists as well. In this case,

In a cell containing a Set:

Like `Map`, the `...` syntax on a set is syntactic sugar for an anonymous

Questions

  • Is the above list of uses complete?
  • From the list above, are all uses distinct cases of the feature? (I.e. is some of them a special case of some other?)
@Baltoli
Copy link
Collaborator

Baltoli commented Feb 21, 2024

There's a better reference directly in kast.md: https://github.com/runtimeverification/k/blob/14e33b62c6de8889c7d64e636d5183f31c361005/k-distribution/include/kframework/builtin/kast.md#syntax-of-cells

There is also the implementation of the compiler pass that turns dots into correct variables: https://github.com/runtimeverification/k/blob/14e33b62c6de8889c7d64e636d5183f31c361005/kernel/src/main/java/org/kframework/compile/CloseCells.java

And the full cell concretization process: https://github.com/runtimeverification/k/blob/14e33b62c6de8889c7d64e636d5183f31c361005/kernel/src/main/java/org/kframework/compile/ConcretizeCells.java

The semantics of closing cells is specified by the assoc / comm attributes:

class LabelInfoFromModule(module: Module) extends LabelInfo {

You can pretty easily get the compiler to accept dotted cells over your own sorts by giving the appropriate productions assoc and unit attributes as appropriate; we could perhaps document this in the user manual. Cell productions are just one instance of this working.

@Baltoli
Copy link
Collaborator

Baltoli commented Feb 22, 2024

@dwightguth cautions that this part of the compiler is probably the oldest remaining part of the K frontend and may be a bit janky.

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