-
Notifications
You must be signed in to change notification settings - Fork 6
Baiji IDL Formal Syntax
The Baiji interface definition langauge(IDL) allows for the definition of Baiji Types. A Baiji IDL is processed by the Baiji code generator to produce code for the various target languages to support the defined classes and services in the IDL file.
Here is the description of the Baiji IDL.
Every Baiji document contains 0 or more headers followed by 0 or more definitions.
[1] Document ::= Header* Definition*
A header is either a Baiji include, or a namespace declaration.
[2] Header ::= Include | Namespace
An include makes all the symbols from another file visible (with a prefix) and adds corresponding include statements into the code generated for the Baiji document.
[3] Include ::= 'include' Literal
A namespace declares with namespaces/package the type definition in this file will be declared in for the target languages. The namespace scope indicates which language the namespace applies to.
[4] Namespace ::= 'namespace' NamespaceScope (Identifier | Literal)
[5] Definition ::= Enum | Class | Service | DocString
An enum creates an enumerated type, with named values.
[6] Enum ::= DocString? Annotation* 'enum' Identifier '{' ( DocString? Identifier ListSeparator?)* '}'
Classes are the fundamental compositional type in Baiji. The name of each field must be unique within the struct.
[7] Class ::= DocString? Annotation* 'class' Identifier '{' Field* '}'
A service provides the interface for a set of functionality provided by a Baiji sever. The interface is simply a list of functions.
[8] Service ::= DocString? Annotation* 'service' Identifier '{' Function* '}'
[9] Function ::= DocString? Annotation* Identifier Identifier '(' Identifier Identifier ')' ListSeparator?
[10] Field ::= DocString? Annotation* ('required' | 'optional')? FieldType Identifier + ListSeparator?
[11] FieldType ::= Identifier | BaseType | ContainerType
[12] BaseType ::= 'bool' | 'int' | 'long' | 'double' | 'string' | 'binary'
[13] ContainerType ::= MapType | ListType
[14] MapType ::= 'map' '<' MapKeyType ',' FieldType '>'
[15] MapKeyType ::= 'string'
[16] ListType ::= 'list' '<' FieldType '>'
[17] Literal ::= ('"' [^"]* '"') | ("'" [^']* "'")
[18] Identifier ::= ( Letter | '_' ) ( Letter | Digit | '.' | '_' )*
[19] ListSeparator ::= ',' | ';'
[20] Letter ::= ['A'-'Z'] | ['a'-'z']
[21] Digit ::= ['0'-'9']
[22] DocString ::= multiple lines comment starts with '/*' and ends with '*/'
[23] Annotation ::= '@' Identifer + ( '=' Literal )?
Note:Single line comment starting with '#' or '//' is ignored by the grammar.