Skip to main content

RAPID Pro Syntax

DRAFT March 2021

Overview

This grammar uses ABNF as defined by RFC5234, with the addition for case-sensitive strings defined by RFC7405

Note: to increase readability of the grammar, whitespace is not reflected

Syntax rules

Model

model                = OWS [ namespace RWS ] *include [ modelElement *( RWS modelElement ) ] OWS

namespace = %s"namespace" RWS qualifiedName

include = %s"include" RWS DQUOTE 1*CHAR DQUOTE RWS %s"as" RWS identifier RWS

modelElement = ( structuredType / enumType / typeDefinition / service )

Structured Type

structuredType       = annotations [ %s"abstract" RWS ] %s"type" RWS identifier [ %s"extends" RWS qualifiedName ] OWS "{" *( OWS structuredTypeMember ) OWS "}"

structuredTypeMember = property / operation ; property, action, or function

property = annotations [propertyModifier RWS] identifier OWS ":" OWS typeReference

propertyModifier = %s"key"

typeReference = typeName [ "?" ] / "[" typeName [ "?" ] "]"

typeName = builtInType / edmType / qualifiedName

builtInType = %s"Boolean"
/ %s"DateTime"
/ %s"Date"
/ %s"Decimal" [ "(" precision "," scale ")"]
/ %s"Double"
/ %s"Duration"
/ %s"Integer"
/ %s"String" [ "(" maxLength ")" ]
/ %s"TimeOfDay"

edmType = %s"Edm" "." identifier

operation = annotations operationKind RWS identifier OWS
"(" OWS [ parameter *( OWS "," OWS parameter) OWS ] ")"
[ OWS ":" OWS annotations typeReference ]

operationKind = %s"action" / %s"function"

parameter = annotations identifier OWS ":" OWS typeReference

Enumeration Type

enumType             = annotations ( %s"enum" / %s"flags" ) RWS identifier OWS "{" OWS 1*enumMember "}"

enumMember = annotations identifier OWS

Type Definition

typeDefinition       = annotations %s"typedef" RWS identifier OWS ":" OWS ( builtInType / edmType )

Service

service              = annotations %s"service" [ RWS identifier ] OWS "{" OWS serviceMember *( RWS serviceMember ) OWS "}"

serviceMember = annotations ( entitySet / singleton / serviceOperation )

entitySet = identifier OWS ":" OWS "[" qualifiedName "]"

singleton = identifier OWS ":" OWS qualifiedName

serviceOperation = operationKind RWS identifier
OWS "(" OWS [ parameter *(OWS "," OWS parameter) OWS ] ")"
[ OWS ":" OWS annotations typeReference ]

Annotations

annotations          = *( annotation RWS )

annotation = "@" qualifiedName [ "#" identifier ] OWS ":" OWS annotationValue / DOC-COMMENT

annotationValue = %s"true"
/ %s"false"
/ %s"null"
/ number
/ DQUOTE *CHAR DQUOTE
/ "[" OWS [ annotationValue *( ( OWS "," OWS / RWS ) annotationValue ) OWS [ "," OWS ] ] "]"
/ "{" OWS [ annotationProperty *( ( OWS "," OWS /RWS ) annotationProperty ) OWS [ "," OWS ] ] "}"
/ "." *( "/" identifier )

annotationProperty = propertyName OWS ":" OWS annotationValue

propertyName = identifier / DQUOTE 1*CHAR DQUOTE / "@" qualifiedName [ "#" identifier ]

Core Syntax Elements

qualifiedName       = identifier *( "." identifier )

identifier = identInitial *identSubsequent

identInitial = ALPHA / "_" ; Note: actually all Unicode letters

identSubsequent = identInitial / DIGIT

number = integer [ "." 1*DIGIT ] [ "e" integer ]

integer = [ "+" / "-" ] ( %x30 / %x31-39 *DIGIT )

precision = integer

scale = integer

maxLength = integer

DOC-COMMENT = "##" *( %x0-9 / %xB-C / %xE-10FFFF)

ALPHA = %x41-5A / %x61-7A

DIGIT = %x30-39

CHAR = %x20-21 / %x23-5B / %x5D-10FFFF
/ ESCAPE ESCAPE
/ ESCAPE DQUOTE

DQUOTE = %x22 ; "

ESCAPE = %x5C ; \

OWS = *WS
RWS = 1*WS
WS = %x8 / %xA / %xD / %x20 ; TAB, LF, CR, SPACE