Skip to content

Baiji IDL Formal Syntax

baijioss edited this page Dec 18, 2014 · 1 revision

Baiji interface description language

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.

Description

Here is the description of the Baiji IDL.

Document

Every Baiji document contains 0 or more headers followed by 0 or more definitions.

[1] Document ::= Header* Definition*

Header

A header is either a Baiji include, or a namespace declaration.

[2] Header ::= Include | Namespace

Baiji Include

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

Namespace

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)

Definition

[5] Definition ::= Enum | Class | Service | DocString

Enum

An enum creates an enumerated type, with named values.

[6] Enum ::= DocString? Annotation* 'enum' Identifier '{' ( DocString? Identifier ListSeparator?)* '}'

Class

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* '}'

Service

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* '}'

Function

[9] Function ::= DocString? Annotation* Identifier Identifier '(' Identifier Identifier ')' ListSeparator?

Field

[10] Field ::= DocString? Annotation* ('required' | 'optional')? FieldType Identifier + ListSeparator?

Types

[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 '>'

Basic Definitions

[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.