module

Noir::ThriftIdl

Reads the parts of an Apache Thrift IDL document that describe an RPC surface: include headers and service definitions with their functions. Structs, enums, consts and typedefs are skipped.

The parser works on tokens rather than lines because Thrift is whitespace-free: a function may span several lines, fields may be separated by ,, ; or nothing at all, and annotations ((key = "value")) can follow a type, a field, a function or a service.

Constants

FUNCTION_QUALIFIERS = Set {"oneway", "readonly", "idempotent"}

Words that may precede a function's return type. oneway is Apache Thrift; readonly and idempotent are fbthrift qualifiers.

SEPARATORS = Set {",", ";"}

Class methods

parse(content : String) : Document
Source
strip_comments(text : String) : String

Blanks //, /* */ and # comments, keeping every newline so line numbers in the result match the original. Quoted literals (single or double) are kept verbatim, so a # or // inside an annotation value is not mistaken for a comment.

Source
tokenize(text : String) : Array(Token)
Source

Nested types