Grammar: parameter_list: Refactor and Add Tests
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user