Closed kaarthikalagappan closed 3 years ago
Commit d6b8df2 changes how PRAGMA and END_PRAGMA tokens are defined. Rather than as PreprocessorTag enum values, they are not defined as regular language tags/tokens in P4Tag.java. This also doesn't require us to modify Syntax.java
Pull request should have been to add superp4
P4 grammar specifies that a pragma statement needs a token to specify the beginning (PRAGMA) and end of a pragma statement (END_PRAGMA). P4's lexer creates the PRAGMA token when it encounters the "@pragma" symbol and changes the lexer state to indicate it's inside a pragma statement. The END_PRAGMA token is created when the lexer is in the pragma state and encounters a new line. Following is the extracted code block that I translated from P4's lexer file to SuperP4's p4lexer file where both the tokens are created (to be copied to P4Lexer.java):
And to create the respective tags (to be copied to P4Tag.java):
I incorrectly assumed that pragma was a preprocessor statement, hence I specified PRAGMA and END_PRAGMA to be a PreprocessorTag. Specifying it as part of the PreprocessorTag made me add those two values as part of the PreprocessorTag enum in Syntax.java:
Since pragmas are not preprocessor statements, it wouldn't be appropriate to add them under PreprocessorTag, so working to find an alternative way that doesn't require them to be added to the PreprocessorTag enum