compiler, runtime: Control Declarations Have Apply Statements

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-04-20 03:35:55 -04:00
parent 1847df7fab
commit c6f086f67f
5 changed files with 70 additions and 4 deletions
+13 -1
View File
@@ -37,6 +37,8 @@ import P4Lang
true: exact;
}
}
apply {
}
};
"""
let x = { (tipe: P4Type) -> Bool in
@@ -61,6 +63,8 @@ import P4Lang
true: exact;
}
}
apply {
}
};
control complex() {
action b() {
@@ -70,6 +74,8 @@ import P4Lang
true: exact;
}
}
apply {
}
};
"""
@@ -94,6 +100,8 @@ import P4Lang
y: exact;
}
}
apply {
}
};
"""
#expect(#RequireOkResult(Program.Compile(simple_parser_declaration)))
@@ -111,6 +119,8 @@ import P4Lang
y: exact;
}
}
apply {
}
};
"""
#expect(#RequireOkResult(Program.Compile(simple_parser_declaration)))
@@ -128,13 +138,15 @@ import P4Lang
y: exact;
}
}
apply {
}
};
"""
#expect(
#RequireErrorResult(
Error(
withMessage:
"{51, 20}: Failed to parse a statement element: {57, 10}: Failed to parse a statement element: {57, 1}: Cannot assign value with type Boolean to identifier z with type Int"
"{57, 10}: Failed to parse a statement element: {57, 1}: Cannot assign value with type Boolean to identifier z with type Int"
),
Program.Compile(simple_parser_declaration))
)