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

Add type nesting rules for extern, parser, control, and package types #1343

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions p4-16/spec/P4-16-spec.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2560,6 +2560,13 @@ arbitrary-precision integer, without a width specified.

| `list types` | error | error | error | allowed | error

| `extern types` | error | error | error | error | error

| `parser types` | error | error | error | error | error

| `control types` | error | error | error | error | error

| `package types` | error | error | error | error | error
|===

[1] An `enum` type used as a field in a `header` must specify a
Expand Down Expand Up @@ -2607,19 +2614,27 @@ The table below lists all types that may appear as base types in a

| `bool` | allowed | allowed

| enumeration types | allowed | error
| `enumeration types` | allowed | error

| `header types` | allowed | error

| `header stacks` | allowed | error

| `header unions` | allowed | error

| `struct types` | allowed | error
Comment on lines +2617 to +2625
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these should not be in backticks. The rule should be something like: if it is an actual piece of code/if it is type (possibly generic) than it is in backticks, but if it is a type "category" (like "header unions") than it should be plain text. For this second table, that was preserved in the asciidoc, but for the first one it probably got mistakenly reformated in the conversion -- compare https://p4.org/p4-spec/docs/p4-16-working-draft.html#sec-type-nesting and https://p4.org/wp-content/uploads/2024/10/P4-16-spec-v1.2.5.html#sec-type-nesting. I think the formatting in 1.2.5 is correct, while the draft is wrong in the first table.

I suggest we keep consistent in each of the tables separately in this PR and then file a follow-on PR to fix format in the first table (I can do that once this is merged).

Copy link
Contributor

Choose a reason for hiding this comment

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

My thought is we should have backticks around (only) things that literally might appear in a P4 program. So "enumueration types" is definitely wrong, but maybe should have "struct types"?

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 agree to both: (1) having a separate PR to fix the backticks consistently and (2) putting [ header types, header stacks, header unions, and struct types ].


| header types | allowed | error
| `tuple types` | allowed | error

| header stacks | allowed | error
| `list types` | allowed | error

| header unions | allowed | error
| `extern types` | allowed | error

| struct types | allowed | error
| `parser types` | allowed | error

| tuple types | allowed | error
| `control types` | allowed | error

| list types | allowed | error
| `package types` | allowed | error

| a `typedef` name | allowed | allowed [3]

Expand Down