@@ -19,4 +19,4 @@ import Common
|
||||
|
||||
public struct Instantiation {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ public class ParserState: Equatable, CustomStringConvertible, Comparable {
|
||||
public private(set) var next_state: ParserState?
|
||||
|
||||
public static func < (lhs: ParserState, rhs: ParserState) -> Bool {
|
||||
// If lhs transitions to rhs, then return true. Otherwise, return false.
|
||||
// If lhs transitions to rhs, then return true. Otherwise, return false.
|
||||
|
||||
// TODO!!
|
||||
return false
|
||||
@@ -141,7 +141,7 @@ public class ParserState: Equatable, CustomStringConvertible, Comparable {
|
||||
|
||||
public func semantic_check(states: ParserStates) -> Bool {
|
||||
guard let transition = transition else {
|
||||
return self == accept || self == reject
|
||||
return self == accept || self == reject
|
||||
}
|
||||
|
||||
if let next_state_name = transition.next_state_name,
|
||||
@@ -226,7 +226,6 @@ public struct ParserStates {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct Parser: P4Type {
|
||||
public var states: ParserStates
|
||||
|
||||
|
||||
@@ -22,26 +22,26 @@ public struct ExpressionStatement {
|
||||
}
|
||||
|
||||
public struct Program {
|
||||
public var types: [P4Type] = Array()
|
||||
public var types: [P4Type] = Array()
|
||||
|
||||
/// Find the program's main parser
|
||||
///
|
||||
/// Note: For now, the main parser is expected to be named main_parser.
|
||||
public func starting_parser() -> Result<Parser> {
|
||||
return self.find_parser(withName: Identifier(name: "main_parser"))
|
||||
/// Find the program's main parser
|
||||
///
|
||||
/// Note: For now, the main parser is expected to be named main_parser.
|
||||
public func starting_parser() -> Result<Parser> {
|
||||
return self.find_parser(withName: Identifier(name: "main_parser"))
|
||||
}
|
||||
|
||||
public func find_parser(withName name: Identifier) -> Result<Parser> {
|
||||
for type in self.types {
|
||||
guard let parser = type as? Parser else {
|
||||
continue
|
||||
}
|
||||
if parser.name == name {
|
||||
return .Ok(parser)
|
||||
}
|
||||
}
|
||||
return .Error(Error(withMessage: "Could not find parser named \(name)"))
|
||||
}
|
||||
|
||||
public func find_parser(withName name: Identifier) -> Result<Parser> {
|
||||
for type in self.types {
|
||||
guard let parser = type as? Parser else {
|
||||
continue
|
||||
}
|
||||
if parser.name == name {
|
||||
return .Ok(parser)
|
||||
}
|
||||
}
|
||||
return .Error(Error(withMessage: "Could not find parser named \(name)"))
|
||||
}
|
||||
|
||||
public init() {}
|
||||
}
|
||||
public init() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user