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

Allow reuse of typenames as normal names in the parser, as long as it… #97

Merged
merged 2 commits into from
Oct 4, 2016

Conversation

ChrisDodd
Copy link
Contributor

… does not lead to ambiguities

This revealed an error check that wasn't being done (relying on a syntax error to catch the error).

I'm not certain, but I think that some updates are needed to the ProgramStructure object to properly track names that are redefined as non-types, as it tries to maintain a separate data structure rather than using the program's symbol table.

@mihaibudiu
Copy link
Contributor

ProgramStructure is only used for P4-14 programs.

@ChrisDodd
Copy link
Contributor Author

Naming confusion here -- there's a P4V1::ProgramStructure (used for P4-14
programs) and an (unrelated) Util::ProgramStructure, used to track whether
identifiers should be TYPE, NAMESPACE or simple IDENTIFIER tokens. I was
referring to the latter.

On Mon, Oct 3, 2016 at 1:00 PM, mbudiu-vmw notifications@github.com wrote:

ProgramStructure is only used for P4-14 programs.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#97 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AD4c8UYrUjAslFfY3w2MJNvojcnEze9Lks5qwV7WgaJpZM4KM9Go
.

@mihaibudiu
Copy link
Contributor

I will need to write a few test cases to figure out whether this works.

@mihaibudiu
Copy link
Contributor

By reading the code in p4-parse.ypp, it looks like named namespaces are never used.
The code was designed to accommodate a namespace X { } construct, which is not implemented (or part of the spec).
The p4-parse file creates namespaces in two places only, and they all have an empty string name, only while parsing method arguments.
So I don't think that ProgramStructure can ever return NAMESPACE as the syntax is today. It certainly does not for any of our test cases.
So I believe this patch can be merged.
There's a secondary question whether we want to simplify the grammar and ProgramStructure.

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

Successfully merging this pull request may close these issues.

3 participants