Grammar: parameter_list: Refactor and Add Tests

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-13 04:58:43 -04:00
parent b687454389
commit fcb3b4e304
2 changed files with 134 additions and 1 deletions
+133
View File
@@ -272,6 +272,43 @@ bool functionb() {
string fieldA;
};
---
(p4program
(declaration
(function_declaration
(typeRef
(baseType
(bool)
)
)
(identifier)
(parameters)
(statement
(blockStatement
(statements
(statement
(variableDeclaration
(typeRef
(baseType
(string)
)
)
(identifier)
)
)
)
)
)
)
)
)
=========================
Function Declaration With Parameters
=========================
bool functionb(bool a, int b) {
string fieldA;
};
---
(p4program
(declaration
(function_declaration
@@ -282,6 +319,102 @@ bool functionb() {
)
(identifier)
(parameters
(parameter_list
(parameter_list
(parameter
(typeRef
(baseType
(bool)
)
)
(identifier)
)
)
(parameter
(typeRef
(baseType
(int)
)
)
(identifier)
)
)
)
(statement
(blockStatement
(statements
(statement
(variableDeclaration
(typeRef
(baseType
(string)
)
)
(identifier)
)
)
)
)
)
)
)
)
=========================
Function Declaration With Parameters And Directions
=========================
bool functionb(in bool a, out int b, inout string c) {
string fieldA;
};
---
(p4program
(declaration
(function_declaration
(typeRef
(baseType
(bool)
)
)
(identifier)
(parameters
(parameter_list
(parameter_list
(parameter_list
(parameter
(direction
(in)
)
(typeRef
(baseType
(bool)
)
)
(identifier)
)
)
(parameter
(direction
(out)
)
(typeRef
(baseType
(int)
)
)
(identifier)
)
)
(parameter
(direction
(inout)
)
(typeRef
(baseType
(string)
)
)
(identifier)
)
)
)
(statement
(blockStatement