swift-parser-generator 是试验性的 Swift 解析器生成器。
swift parser generator 的代码包括尝试使用 Swift 制作类似 Scala 解析器关系选择器,部分可以成功制作简单的解析器,但是还未实现 Packrat 样式解析器。
支持以下操作符解析:
// "a" followed by "b" let rule = "a" ~ "b" // "a" or "b" let rule = "a" | "b" // "a" followed by something other than "b" let rule = "a" ~ !"b" // "a" followed by one or more "b" let rule = "a" ~ "b"+ // "a" followed by zero or more "b" let rule = "a" ~ "b"* // "a" followed by a numeric digit let rule = "a" ~ ("0"-"9") // "a" followed by the rule named "blah" let rule = "a" ~ ^"blah" // "a" optionally follewd by "b" let rule = "a" ~ "b"/~ // "a" followed by the end of input let rule = "a"*!*