Type File Syntax
This page documents the syntax of the C3 "type" files (.c3typ) in BNF. There is also a list of the keywords.
Note that these are only the syntax rules; additional semantic rules further restrict valid usage.
start
- type EOF
- annotation + type EOF
type
- type_modif * type ident_path bind_vars ? extends_ ? mixes ? type_suffix * (
'{'ann_field *'}') ? - private ? remix type ident_path as ident_path extends_ ? mixes ? type_suffix * (
'{'ann_field *'}') ? - private ? native ( lang_only | lang_runtime ) remix type ident_path mixes ? (
'{'ann_field *'}') ? - ( private | remix ) * enum type ident_path mixes ? (
'{'ann_enum_field +'}') ? - ( private | remix ) * union type ident_path bind_vars ?
'='union_anyof - abstract ? duck type ident_path bind_vars ? extends_ ? mixes type_suffix * (
'{'ann_field *'}') ?
union_anyof
type_modif
- abstract | private | inline | final | not mixable | not remixable | entity | extendable | not extendable | remix | native
type_suffix
default_rt
ann_field
type_field
- ident
':'field_mod * ann_value_type fkey_ref_type ? field_suffix * (';') ?
field_mod
- private | const
fkey_ref_type
'('ident_path (','ident_path ) ?')'
field_suffix
- defaultv enum_vals ? | calculated
- schema_name | schema_suffix | not persistable | translate
schema_name
- schema name STRING
schema_suffix
- schema suffix STRING
type_key
- type key STRING
calculated
- stored ? calc expr_top
- periodic stored ? calc expr_top period STRING
- scheduled stored ? calc expr_top schedule STRING
translate
- translate by ident
ann_enum_field
enum_field
kw_type
- kw_base
- as
- calc
- const
- duck
- extendable
- period
- periodic
- schedule
- scheduled
- stored
- type
- union
ident
value_type_start
- ann_value_type EOF
annotations_start
- annotations EOF
param_types_start
- param_types EOF
param_types
'('')'EOF'('param_type (','param_type ) *')'EOF
param_type
- ann_value_type
'...'?
bind_vars
bind_var
bind_restr
- ident
':'value_type
extends_
- extends ref_type
mixes
value_type
ann_value_type
data_type
- lambda_type
'('lambda_type')'union_alts- vt_mods
'('( simple_type | ('('lambda_type')') ) ( union_alts')'
ann_data_type
simple_type
atom_type
basic_type
any_type
- vt_mods ? any
prim_type
serialized
- serialized ser_rhs_type
ser_rhs_type
prim_types
- string serialized ?
- string enum_vals
- binary serialized ?
- binary enum_vals
- typed ? json serialized ?
- json enum_vals
- int enum_vals ?
- utc ? PRIM_TYPE_DATETIME no tz ? ( with millis | with micros | with nanos ) ? enum_vals ?
- prim_other enum_vals ?
prim_other
- byte | int16 | int32 | bigint
- float | double | decimal
- boolean | number
ref_type
ref_path
bind_meta
'<''<'ann_data_type'>''>'
ref_var
coll_type
- vt_mods ?
'['ann_value_type']' - vt_mods ?
'set<'ann_value_type'>' - vt_mods ?
'map<'ann_value_type','ann_value_type'>' - vt_mods ? stream
'<'ann_value_type'>' - vt_mods ? collection
'<'ann_value_type'>'
push_stream_type
- vt_mods ? push stream
'<'ann_value_type'>'
event_stream_type
- vt_mods ? event stream
'<'ann_value_type'>'
tuple_type
- vt_mods ?
'{'tuple_field (','tuple_field ) *','?'}' '('simple_type','( simple_type (','simple_type ) *','? ) ?')'- vt_mods ? tuple
tuple_field
- ( ident | STRING )
':'ann_data_type
simple_ref
vector_type
func_type
- func_mods ? function bind_vars ?
'('func_param ? (','func_param ) *')'return_type ? inherit_from ? claim_suffix - func_mods ? member function bind_vars ?
'('func_param ? (','func_param ) *')'return_type ? inherit_from ? claim_suffix - func_mods ? property bind_vars ?
'('')'return_type claim_suffix
lambda_type
- vt_mods ? lambda
'('func_param ? (','func_param ) *')'return_type ?
func_mod
- abstract | optional | final | inline | cached | stateful
func_mods
func_param
- annotation * ident
':'ann_data_type ('...'| defaultv ) ?
inherit_from
- from ident_path
claim_suffix
- lang_runtime (
'|'( lang_only | lang_runtime ) ) * - lang_only (
'|'( lang_only | lang_runtime ) ) *
lang_runtime
- lang_key (
'-'ident ) + runtime_ver ?
lang_only
lang_key
- java | js | py | ts | tsx
runtime_ver
inherit_type
- func_mods ? vt_mods ?
'~'inherit_from ? claim_suffix - func_mods ?
'~'return_type inherit_from ? claim_suffix - func_mods ?
'~''('inherit_param ? (','inherit_param ) *')'inherit_from ? claim_suffix - vt_mods ?
'~'( serialized | enum_vals )
inherit_param
- annotation * ident
':'inherit_pt ('...'| defaultv ) ?
inherit_pt
- data_type
- annotation * vt_mods ?
'~'
return_type
':'ann_data_type
native_type
- vt_mods ? native
void_type
- void
vt_mods
'!'|'?'|'!?'
defaultv
'='expr_top
annotation
'@'ident'@'ident'@('ann_values')''@'ident'('ann_values')''@'ident'@('ann_value_only')'
annotations
ann_values
ann_value
- ann_val_lhs
'='ann_val_rhs - ann_val_lhs
'+='ann_val_rhs
ann_value_only
ann_val_lhs
ann_val_rhs
literal
- primitive | object_val | array_val | datefn
primitive
object_val
key_value
- ident
':'literal - STRING
':'literal - INT
':'literal - DEC
':'literal - ident
':'ID - STRING
':'ID - INT
':'ID - DEC
':'ID
array_val
datefn
'Date('STRING')'
id_path
ident_path
enum_vals
union_alts
union_alt
union_elt
- simple_type
'('ann_data_type')'
expr_start
- expr_top EOF
expr_top
expr_ternary
expr_or
expr_and
- expr_bitOr (
'&&'expr_bitOr ) *
expr_bitOr
- expr_bitXOr (
'|'expr_bitXOr ) *
expr_bitXOr
- expr_bitAnd (
'^'expr_bitAnd ) *
expr_bitAnd
- expr_equal (
'&'expr_equal ) *
expr_equal
expr_comp
- expr_shift (
'<'expr_shift '>'expr_shift- (
'<''=') expr_shift - (
'>''=') expr_shift - (
'<''=''>') expr_shift ) *
expr_shift
expr_add
expr_mul
expr_exp
- expr_unary ( (
'*''*') expr_unary ) *
expr_unary
- expr_dotcall
'!'expr_unary'-'expr_unary'~'expr_unary
expr_dotcall
- ( expr_value | kw_func ) ( expr_callargs
'['expr_top']''.'( id_path'('expr_top')') ) *
expr_callargs
'('( expr_top (','expr_top ) * ) ?')''('expr_namedarg (','expr_namedarg ) *')'
expr_namedarg
expr_lambda
'('')''=>'expr_top'('lambda_param (','lambda_param ) *')''=>'expr_top- lambda_param
'=>'expr_top
lambda_param
expr_value
expr_array
expr_object
'{'expr_objkv (','expr_objkv ) *','?'}''{''}'
expr_objkv
kw_base
- boolean
- binary
- byte
- decimal
- double
- float
- int
- int16
- int32
- bigint
- json
- BOOL
- abstract
- any
- cached
- collection
- entity
- enum
- extends
- final
- function
- inline
- lambda
- mixes
- mixing
- native
- optional
- private
- property
- remix
- stateful
- stream
- tuple
- typed
- utc
- void
- kw_func
- kw_safe
kw_func
- string
- PRIM_TYPE_DATETIME
- number
kw_safe
- default
- from
- in
- instanceof
- isA
- java
- js
- py
- serialized
- ts
- tsx
multi_string
PRIM_TYPE_DATETIME
- datetime | date
VERSION
BOOL
- true | false
INT
'-'? DIGITS
DEC
FLOAT
STRING
'"'( STRING_ESC | ~ ('"'|'\\'|'\n'|'\r') ) *'"''\''( STRING_ESC | ~ ('\''|'\\'|'\n'|'\r') ) *'\''
ID
ID_PATH
WS_WS
- (
' '|'\t'|'\u000C'|'\r') +
WS_NL
WS_COMMENT
- (
'//'~ ('\n'|'\r') * ('\r\n'|'\r'|'\n') '//'~ ('\n'|'\r') *'/*'( . ) *'*/')
ID_FIRST
- LETTER |
'_'
ID_REST
STRING_ESC
LETTER
- UNICODE_CLASS_LL | UNICODE_CLASS_LU | UNICODE_CLASS_LM | UNICODE_CLASS_LO
DIGIT
'0'..'9'
DIGITS
HEX_DIGIT
- DIGIT |
'a'..'f'|'A'..'F'
EXP
- ( e | E )
'-'? DIGIT +