Add function and class constructs to ast.yaml.
This commit is contained in:
parent
59165f6235
commit
17f5d2d62d
@ -206,3 +206,108 @@ PlatformFunction:
|
||||
- identifier
|
||||
- parameters
|
||||
- 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 = {
|
||||
FunctionModifier?
|
||||
~ Fn
|
||||
Fn
|
||||
~ GenericParameters?
|
||||
~ Identifier
|
||||
~ Parameters
|
||||
@ -468,18 +467,16 @@ InterfaceFunction = {
|
||||
|
||||
InterfaceDefaultFunction = {
|
||||
Def
|
||||
~ FunctionModifier?
|
||||
~ Fn
|
||||
~ GenericParameters?
|
||||
~ Identifier
|
||||
~ Parameters
|
||||
~ ReturnType
|
||||
~ ReturnType?
|
||||
~ FunctionBody
|
||||
}
|
||||
|
||||
InterfaceOperatorFunction = {
|
||||
FunctionModifier?
|
||||
~ Op
|
||||
Op
|
||||
~ GenericParameters?
|
||||
~ Operator
|
||||
~ Parameters
|
||||
@ -488,12 +485,11 @@ InterfaceOperatorFunction = {
|
||||
|
||||
InterfaceDefaultOperatorFunction = {
|
||||
Def
|
||||
~ FunctionModifier?
|
||||
~ Op
|
||||
~ GenericParameters?
|
||||
~ Operator
|
||||
~ Parameters
|
||||
~ ReturnType
|
||||
~ ReturnType?
|
||||
~ FunctionBody
|
||||
}
|
||||
|
||||
@ -502,7 +498,7 @@ InterfaceDefaultOperatorFunction = {
|
||||
FunctionBody = {
|
||||
FunctionAliasBody
|
||||
| FunctionEqualsBody
|
||||
| BlockStatement
|
||||
| FunctionBlockBody
|
||||
}
|
||||
|
||||
FunctionEqualsBody = {
|
||||
@ -515,30 +511,23 @@ FunctionAliasBody = {
|
||||
~ Identifier
|
||||
}
|
||||
|
||||
FunctionBlockBody = {
|
||||
Statement*
|
||||
~ End
|
||||
}
|
||||
|
||||
// Class constructs
|
||||
|
||||
ClassConstructor = {
|
||||
"("
|
||||
~ DataMember
|
||||
~ ( "," ~ DataMember )*
|
||||
~ Member
|
||||
~ ( "," ~ Member )*
|
||||
~ ")"
|
||||
}
|
||||
|
||||
DataMember = {
|
||||
Property
|
||||
| Field
|
||||
}
|
||||
|
||||
Property = {
|
||||
Mut?
|
||||
~ Identifier
|
||||
~ ":"
|
||||
~ TypeUse
|
||||
}
|
||||
|
||||
Field = {
|
||||
Mut?
|
||||
~ Fld
|
||||
Member = {
|
||||
Pub?
|
||||
~ Mut?
|
||||
~ Identifier
|
||||
~ ":"
|
||||
~ TypeUse
|
||||
|
Loading…
Reference in New Issue
Block a user