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

ISLE: improve syntax BNF #9903

Merged
merged 2 commits into from
Dec 27, 2024
Merged

ISLE: improve syntax BNF #9903

merged 2 commits into from
Dec 27, 2024

Conversation

eagr
Copy link
Contributor

@eagr eagr commented Dec 26, 2024

  • correct <pattern-arg> syntax(?)
  • re-org items in order to improve readability

@eagr eagr requested a review from a team as a code owner December 26, 2024 08:35
@eagr eagr requested review from fitzgen and removed request for a team December 26, 2024 08:35
@@ -1442,12 +1442,14 @@ The grammar accepted by the parser is as follows:
| "\t"
| "\n"
| "\r"
| "\b"
| "\f"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sake of completeness. I suppose they're also ignored by the parser?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no -- the full list of whitespace characters is here. The original list was correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have double checked first, sorry about that.

@@ -1458,45 +1460,43 @@ The grammar accepted by the parser is as follows:
<ISLE> ::= <def>*

<def> ::= "(" "pragma" <pragma> ")"
| "(" "type" <typedecl> ")"
| "(" "type" <type> ")"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's just use the dumbest mapping :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, there is a reason I had chosen typedecl -- type is too close to ty (the latter reads as an abbreviation of the former with no semantic difference), the existing nonterminal for type expressions, and there is a semantic difference between uses of a type and the form that declares them. Let's stick with typedecl.

<pragma> ::= <ident>

<typedecl> ::= <ident> [ "extern" | "nodebug" ] <typevalue>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically not a value, could be confusing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, here I would disagree again. You can call it a "type expression" if you want, but it's a value in the universe of types. It is definitely not a typedef: typedef is, in my mind, another name for the whole form that defines a new type (like a typedef in C/C++ for example). Perhaps "type body" if you want to distinguish the semantic place this occupies -- an expanded form that can be named in a type declaration form's right-hand side but not in-line wherever types are given.

Copy link
Contributor Author

@eagr eagr Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, typedef is worse than typevalue.. I did mean something like "type body". How about

<typedef> ::= <ident> [ "extern" | "nodebug" ] <type-body>

to set it apart from <decl>?


<enumvariant> ::= <ident>
| "(" <ident> <enumfield>* ")"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically it's a field of the variant

@@ -1508,7 +1508,7 @@ The grammar accepted by the parser is as follows:
| "(" <ident> <pattern-arg>* ")"

<pattern-arg> ::= <pattern>
| "<" <expr> ;; in-argument to an extractor
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be very wrong about this. But having this kind of infix operator defined in S-expression feels weird and I couldn't find it in the extractor parser, so I think this is a typo?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outdated syntax, sorry -- we removed argument polarity a while ago. The whole <expr> case needs to go away and you can inline <pattern> for <pattern-arg> since we don't have the distinction anymore.

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language labels Dec 26, 2024
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "isle"

Thus the following users have been cc'd because of the following labels:

  • cfallin: isle
  • fitzgen: isle

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Unfortunately this introduces some inaccuracies and I have a lot of comments -- see below.

@@ -1442,12 +1442,14 @@ The grammar accepted by the parser is as follows:
| "\t"
| "\n"
| "\r"
| "\b"
| "\f"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no -- the full list of whitespace characters is here. The original list was correct.

@@ -1458,45 +1460,43 @@ The grammar accepted by the parser is as follows:
<ISLE> ::= <def>*

<def> ::= "(" "pragma" <pragma> ")"
| "(" "type" <typedecl> ")"
| "(" "type" <type> ")"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, there is a reason I had chosen typedecl -- type is too close to ty (the latter reads as an abbreviation of the former with no semantic difference), the existing nonterminal for type expressions, and there is a semantic difference between uses of a type and the form that declares them. Let's stick with typedecl.

<pragma> ::= <ident>

<typedecl> ::= <ident> [ "extern" | "nodebug" ] <typevalue>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, here I would disagree again. You can call it a "type expression" if you want, but it's a value in the universe of types. It is definitely not a typedef: typedef is, in my mind, another name for the whole form that defines a new type (like a typedef in C/C++ for example). Perhaps "type body" if you want to distinguish the semantic place this occupies -- an expanded form that can be named in a type declaration form's right-hand side but not in-line wherever types are given.

@@ -1508,7 +1508,7 @@ The grammar accepted by the parser is as follows:
| "(" <ident> <pattern-arg>* ")"

<pattern-arg> ::= <pattern>
| "<" <expr> ;; in-argument to an extractor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outdated syntax, sorry -- we removed argument polarity a while ago. The whole <expr> case needs to go away and you can inline <pattern> for <pattern-arg> since we don't have the distinction anymore.

@eagr
Copy link
Contributor Author

eagr commented Dec 27, 2024

Out of curiosity, is there a reason for convert instead of convertor, given the extractor?

@cfallin cfallin added this pull request to the merge queue Dec 27, 2024
@cfallin
Copy link
Member

cfallin commented Dec 27, 2024

Out of curiosity, is there a reason for convert instead of convertor, given the extractor?

Locally it made sense as "convert T to U using foo"; one could debate the many options further but we already had that discussion three(?) years ago and it's unlikely to change now absent good reason.

Merged via the queue into bytecodealliance:main with commit af5a789 Dec 27, 2024
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants