解析prototxt文件的python庫 prototxt-parser https://github.com/yogin16/prototxt_parser https://test.pypi.org/project/prototxt-parser
1.yield讓函數執行支持分段,讓函數支持了記憶和狀態,可以讓一個函數變成狀態機,這樣一個狀態機的執行流程可能直接表達在一個函數中,讓整個處理流程更加順暢。
2.parsy的optional,Returns a parser that expects the initial parser zero or once and maps the result to None in the case of no match. optional就是在匹配不上時返回None而不是直接報錯,讓程序有機會對匹配不上進行分支處理。
3.parsy的Parser 的<<,The same as parser.skip(other_parser) - see Parser.skip().
4.parsy的Parser的parse,Attempts to parse the given string (or list). If the parse is successful and consumes the entire string the result is returned - otherwise a ParseError is raised.
5.proto3的prototxt語法定義 1https://developers.google.com/protocol-buffers/docs/reference/proto3-spec?hl=zh-CN
6.parsy能夠實現的的就是定了一些語言解析能力,能經過相似語法描述(Language Specification)方式編程,實現對特定格式文本解析,將文本按照語法描述解析成語法樹(字典)。能夠方便實現對自定義文件格式解析。python