fcb3b4e304
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
438 lines
6.2 KiB
Plaintext
438 lines
6.2 KiB
Plaintext
=========================
|
|
Simple Declaration
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
bool l;
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(bool)
|
|
)
|
|
)
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Declaration (int)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
int l;
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(int)
|
|
)
|
|
)
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Declaration (string)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
string l;
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(string)
|
|
)
|
|
)
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Declaration (string with initial value)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
string l = "testing";
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(string)
|
|
)
|
|
)
|
|
(identifier)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(string_literal)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Non Basic Type Declaration (No Initial Value)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
header_t header;
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(type_identifier)
|
|
)
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Struct Type Declaration
|
|
=========================
|
|
struct Testing {
|
|
string fieldA;
|
|
};
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(type_declaration
|
|
(struct_declaration
|
|
(struct)
|
|
(identifier)
|
|
(struct_declaration_fields
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(string)
|
|
)
|
|
)
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Function Declaration
|
|
=========================
|
|
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
|
|
(typeRef
|
|
(baseType
|
|
(bool)
|
|
)
|
|
)
|
|
(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
|
|
(statements
|
|
(statement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(string)
|
|
)
|
|
)
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|