Improve Parsing of P4 Parsers And Continue Runtime Implementation

1. Parsing of P4 Parsers was broken: Multiple local elements and
statements were not allowed.
2. Support more functionality on scopes.
3. Refactor variable/identifier.
4. Add more tests.

Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
Will Hawkins
2026-01-30 08:31:42 -05:00
parent 9b307bcd66
commit 1203c0c90a
8 changed files with 410 additions and 281 deletions
+20 -1
View File
@@ -15,15 +15,34 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
public enum ValueType: CustomStringConvertible {
public enum ValueType: CustomStringConvertible, Equatable {
case Boolean(Bool)
case Int(Int)
case String(String)
public var description: String {
switch self {
case ValueType.Boolean(let b):
return "\(b) of Boolean"
case ValueType.Int(let i):
return "\(i) of Int"
case ValueType.String(let s):
return "\(s) of String"
}
}
public static func==(lhs: ValueType, rhs: ValueType) -> Bool {
switch (lhs,rhs) {
case (ValueType.Boolean(let lhsb), ValueType.Boolean(let rhsb)):
return lhsb == rhsb
case (ValueType.String(let lhsb), ValueType.String(let rhsb)):
return lhsb == rhsb
case (ValueType.Int(let lhsb), ValueType.Int(let rhsb)):
return lhsb == rhsb
default: return false
}
}
}
public struct Value: CustomStringConvertible {