Add function and class constructs to ast.yaml.
This commit is contained in:
parent
59165f6235
commit
17f5d2d62d
@ -206,3 +206,108 @@ PlatformFunction:
|
|||||||
- identifier
|
- identifier
|
||||||
- parameters
|
- parameters
|
||||||
- return_type
|
- return_type
|
||||||
|
InterfaceFunction:
|
||||||
|
children:
|
||||||
|
- fn_kw:
|
||||||
|
rule: Fn
|
||||||
|
skip: true
|
||||||
|
- generics:
|
||||||
|
rule: GenericParameters
|
||||||
|
build:
|
||||||
|
or_else_default: true
|
||||||
|
- identifier
|
||||||
|
- parameters
|
||||||
|
- return_type
|
||||||
|
InterfaceDefaultFunction:
|
||||||
|
children:
|
||||||
|
- def_kw:
|
||||||
|
rule: Def
|
||||||
|
skip: true
|
||||||
|
- fn_kw:
|
||||||
|
rule: Fn
|
||||||
|
skip: true
|
||||||
|
- generics:
|
||||||
|
rule: GenericParameters
|
||||||
|
build:
|
||||||
|
or_else_default: true
|
||||||
|
- identifier
|
||||||
|
- parameters
|
||||||
|
- return_type:
|
||||||
|
build:
|
||||||
|
or_else: void
|
||||||
|
- function_body
|
||||||
|
InterfaceOperatorFunction:
|
||||||
|
children:
|
||||||
|
- op_kw:
|
||||||
|
rule: Op
|
||||||
|
skip: true
|
||||||
|
- generics:
|
||||||
|
rule: GenericParameters
|
||||||
|
build:
|
||||||
|
or_else_default: true
|
||||||
|
- operator
|
||||||
|
- parameters
|
||||||
|
- return_type
|
||||||
|
InterfaceDefaultOperatorFunction:
|
||||||
|
children:
|
||||||
|
- def_kw:
|
||||||
|
rule: Def
|
||||||
|
skip: true
|
||||||
|
- op_kw:
|
||||||
|
rule: Op
|
||||||
|
skip: true
|
||||||
|
- generics:
|
||||||
|
rule: GenericParameters
|
||||||
|
build:
|
||||||
|
or_else_default: true
|
||||||
|
- operator
|
||||||
|
- parameters
|
||||||
|
- return_type:
|
||||||
|
build:
|
||||||
|
or_else: void
|
||||||
|
- function_body
|
||||||
|
|
||||||
|
# Function Bodies
|
||||||
|
FunctionBody:
|
||||||
|
rules:
|
||||||
|
- FunctionAliasBody
|
||||||
|
- FunctionEqualsBody
|
||||||
|
- FunctionBlockBody
|
||||||
|
FunctionEqualsBody:
|
||||||
|
children:
|
||||||
|
- expression
|
||||||
|
FunctionAliasBody:
|
||||||
|
children:
|
||||||
|
- alias_kw:
|
||||||
|
rule: Alias
|
||||||
|
skip: true
|
||||||
|
- identifier
|
||||||
|
FunctionBlockBody:
|
||||||
|
children:
|
||||||
|
- statements:
|
||||||
|
rule: Statement
|
||||||
|
vec: true
|
||||||
|
- end_kw:
|
||||||
|
rule: End
|
||||||
|
skip: true
|
||||||
|
|
||||||
|
# Class constructs
|
||||||
|
ClassConstructor:
|
||||||
|
children:
|
||||||
|
- members:
|
||||||
|
rule: Member
|
||||||
|
vec: true
|
||||||
|
Member:
|
||||||
|
children:
|
||||||
|
- is_public:
|
||||||
|
rule: Pub
|
||||||
|
build:
|
||||||
|
type: boolean
|
||||||
|
on: rule_present
|
||||||
|
- is_mut:
|
||||||
|
rule: Mut
|
||||||
|
build:
|
||||||
|
type: boolean
|
||||||
|
on: rule_present
|
||||||
|
- identifier
|
||||||
|
- type_use
|
||||||
|
@ -458,8 +458,7 @@ PlatformFunction = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InterfaceFunction = {
|
InterfaceFunction = {
|
||||||
FunctionModifier?
|
Fn
|
||||||
~ Fn
|
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ Parameters
|
~ Parameters
|
||||||
@ -468,18 +467,16 @@ InterfaceFunction = {
|
|||||||
|
|
||||||
InterfaceDefaultFunction = {
|
InterfaceDefaultFunction = {
|
||||||
Def
|
Def
|
||||||
~ FunctionModifier?
|
|
||||||
~ Fn
|
~ Fn
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ Parameters
|
~ Parameters
|
||||||
~ ReturnType
|
~ ReturnType?
|
||||||
~ FunctionBody
|
~ FunctionBody
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceOperatorFunction = {
|
InterfaceOperatorFunction = {
|
||||||
FunctionModifier?
|
Op
|
||||||
~ Op
|
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Operator
|
~ Operator
|
||||||
~ Parameters
|
~ Parameters
|
||||||
@ -488,12 +485,11 @@ InterfaceOperatorFunction = {
|
|||||||
|
|
||||||
InterfaceDefaultOperatorFunction = {
|
InterfaceDefaultOperatorFunction = {
|
||||||
Def
|
Def
|
||||||
~ FunctionModifier?
|
|
||||||
~ Op
|
~ Op
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ Operator
|
~ Operator
|
||||||
~ Parameters
|
~ Parameters
|
||||||
~ ReturnType
|
~ ReturnType?
|
||||||
~ FunctionBody
|
~ FunctionBody
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -502,7 +498,7 @@ InterfaceDefaultOperatorFunction = {
|
|||||||
FunctionBody = {
|
FunctionBody = {
|
||||||
FunctionAliasBody
|
FunctionAliasBody
|
||||||
| FunctionEqualsBody
|
| FunctionEqualsBody
|
||||||
| BlockStatement
|
| FunctionBlockBody
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionEqualsBody = {
|
FunctionEqualsBody = {
|
||||||
@ -515,30 +511,23 @@ FunctionAliasBody = {
|
|||||||
~ Identifier
|
~ Identifier
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FunctionBlockBody = {
|
||||||
|
Statement*
|
||||||
|
~ End
|
||||||
|
}
|
||||||
|
|
||||||
// Class constructs
|
// Class constructs
|
||||||
|
|
||||||
ClassConstructor = {
|
ClassConstructor = {
|
||||||
"("
|
"("
|
||||||
~ DataMember
|
~ Member
|
||||||
~ ( "," ~ DataMember )*
|
~ ( "," ~ Member )*
|
||||||
~ ")"
|
~ ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
DataMember = {
|
Member = {
|
||||||
Property
|
Pub?
|
||||||
| Field
|
~ Mut?
|
||||||
}
|
|
||||||
|
|
||||||
Property = {
|
|
||||||
Mut?
|
|
||||||
~ Identifier
|
|
||||||
~ ":"
|
|
||||||
~ TypeUse
|
|
||||||
}
|
|
||||||
|
|
||||||
Field = {
|
|
||||||
Mut?
|
|
||||||
~ Fld
|
|
||||||
~ Identifier
|
~ Identifier
|
||||||
~ ":"
|
~ ":"
|
||||||
~ TypeUse
|
~ TypeUse
|
||||||
|
Loading…
Reference in New Issue
Block a user