a7d8fd1304
Distinguishing between signed and unsigned fixed-width integer types must still be done. Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
467 lines
7.3 KiB
Plaintext
467 lines
7.3 KiB
Plaintext
=========================
|
|
Exit Statement
|
|
=========================
|
|
control T() {
|
|
apply {
|
|
exit;
|
|
}
|
|
};
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(control_declaration
|
|
(control)
|
|
(identifier)
|
|
(parameters)
|
|
(apply_statement
|
|
(apply)
|
|
(blockStatement
|
|
(statements
|
|
(statement
|
|
(exit_statement)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
=========================
|
|
Return Statement
|
|
=========================
|
|
int fun() {
|
|
return 1;
|
|
};
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(function_declaration
|
|
(typeRef
|
|
(baseType
|
|
(int_type
|
|
(int)
|
|
)
|
|
)
|
|
)
|
|
(identifier)
|
|
(parameters)
|
|
(blockStatement
|
|
(statements
|
|
(statement
|
|
(return_statement
|
|
(expression
|
|
(simple_expression
|
|
(integer)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
=========================
|
|
Simple If Statement (No Else)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
if (true) {
|
|
}
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(conditionalStatement
|
|
(if)
|
|
(expression
|
|
(simple_expression
|
|
(booleanLiteralExpression
|
|
(true)
|
|
)
|
|
)
|
|
)
|
|
(statement
|
|
(blockStatement)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple If Statement (Else)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
if (true) {
|
|
} else {
|
|
}
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(conditionalStatement
|
|
(if)
|
|
(expression
|
|
(simple_expression
|
|
(booleanLiteralExpression
|
|
(true)
|
|
)
|
|
)
|
|
)
|
|
(statement
|
|
(blockStatement)
|
|
)
|
|
(else)
|
|
(statement
|
|
(blockStatement)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Assignment Statement (To Identifier)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
string l = "testing";
|
|
l = "five";
|
|
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)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserStatement
|
|
(assignmentStatement
|
|
(expression
|
|
(simple_expression
|
|
(identifier)
|
|
)
|
|
)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(string_literal)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Conditional Statement
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
bool x = true;
|
|
if (x) {
|
|
x = false;
|
|
}
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(bool)
|
|
)
|
|
)
|
|
(identifier)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(booleanLiteralExpression
|
|
(true)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserStatement
|
|
(conditionalStatement
|
|
(if)
|
|
(expression
|
|
(simple_expression
|
|
(identifier)
|
|
)
|
|
)
|
|
(statement
|
|
(blockStatement
|
|
(statements
|
|
(statement
|
|
(assignmentStatement
|
|
(expression
|
|
(simple_expression
|
|
(identifier)
|
|
)
|
|
)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(booleanLiteralExpression
|
|
(false)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
=========================
|
|
Simple Conditional Statement (with else)
|
|
=========================
|
|
parser simple() {
|
|
state start {
|
|
bool x = true;
|
|
int y = 0;
|
|
if (x) {
|
|
y = 1;
|
|
} else {
|
|
y = 2;
|
|
}
|
|
transition accept;
|
|
}
|
|
};
|
|
|
|
---
|
|
(p4program
|
|
(declaration
|
|
(parserDeclaration
|
|
(parserType
|
|
(parser)
|
|
(identifier)
|
|
(parameters)
|
|
)
|
|
(parserStates
|
|
(parserState
|
|
(state)
|
|
(identifier)
|
|
(parserStatements
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(bool)
|
|
)
|
|
)
|
|
(identifier)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(booleanLiteralExpression
|
|
(true)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserStatement
|
|
(variableDeclaration
|
|
(typeRef
|
|
(baseType
|
|
(int_type
|
|
(int)
|
|
)
|
|
)
|
|
)
|
|
(identifier)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(integer)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserStatement
|
|
(conditionalStatement
|
|
(if)
|
|
(expression
|
|
(simple_expression
|
|
(identifier)
|
|
)
|
|
)
|
|
(statement
|
|
(blockStatement
|
|
(statements
|
|
(statement
|
|
(assignmentStatement
|
|
(expression
|
|
(simple_expression
|
|
(identifier)
|
|
)
|
|
)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(integer)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(else)
|
|
(statement
|
|
(blockStatement
|
|
(statements
|
|
(statement
|
|
(assignmentStatement
|
|
(expression
|
|
(simple_expression
|
|
(identifier)
|
|
)
|
|
)
|
|
(assignment)
|
|
(expression
|
|
(simple_expression
|
|
(integer)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(parserTransitionStatement
|
|
(transition)
|
|
(transitionSelectionExpression
|
|
(identifier)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|