Much work on build.rs and related.
This commit is contained in:
parent
16e180180b
commit
9d843097bc
513
src/ast/build.rs
513
src/ast/build.rs
@ -1,9 +1,4 @@
|
|||||||
use crate::ast::{
|
use crate::ast::{ClassDeclaration, CompilationUnit, DelegateOrIdentifier, FullyQualifiedName, FunctionDeclaration, FunctionModifier, FunctionTypeParameters, FunctionTypeUse, GenericArgument, GenericArguments, GenericParameter, GenericParameters, Identifier, InputArgument, InputArguments, InterfaceDeclaration, InterfaceFunctionDeclaration, InterfaceOperatorFunctionDeclaration, InterfaceOrClassTypeUse, ModuleDeclaration, ModuleLevelDeclaration, OperatorFunctionDeclaration, PlatformFunctionDeclaration, Reference, References, ReturnType, TupleTypeUse, TypeDeclaration, TypeFunctionArguments, TypeGenericArgument, TypeGenericArguments, TypeImplements, TypeImplementsArguments, TypeImplementsList, TypeTupleArgument, TypeTupleArguments, TypeUse, TypeWhereGuard, TypeWhereGuards, VoidOrTypeUse};
|
||||||
CompilationUnit, DelegateOrIdentifier, FullyQualifiedName, FunctionModifier, FunctionTypeUse,
|
|
||||||
GenericArgument, GenericArguments, GenericParameter, GenericParameters, Identifier,
|
|
||||||
InputArgument, InputArguments, InterfaceOrClassTypeUse, Reference, References, ReturnType,
|
|
||||||
TupleTypeUse, TypeUse, VoidOrTypeUse,
|
|
||||||
};
|
|
||||||
use crate::parser::Rule;
|
use crate::parser::Rule;
|
||||||
use pest::iterators::Pair;
|
use pest::iterators::Pair;
|
||||||
|
|
||||||
@ -15,7 +10,7 @@ fn expect_and_use<T>(pair: Pair<Rule>, rule: Rule, f: fn(Pair<Rule>) -> T) -> T
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_ast(compilation_unit_pair: Pair<Rule>) -> CompilationUnit {
|
pub fn build_ast(compilation_unit_pair: Pair<Rule>) -> CompilationUnit {
|
||||||
todo!()
|
build_compilation_unit(compilation_unit_pair)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_identifier(identifier_pair: Pair<Rule>) -> Identifier {
|
fn build_identifier(identifier_pair: Pair<Rule>) -> Identifier {
|
||||||
@ -37,61 +32,109 @@ fn build_fqn(fqn_pair: Pair<Rule>) -> FullyQualifiedName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn build_type_use(type_use_pair: Pair<Rule>) -> TypeUse {
|
fn build_type_use(type_use_pair: Pair<Rule>) -> TypeUse {
|
||||||
let inner_pair = type_use_pair.into_inner().next().unwrap();
|
let mut borrow_count = 0;
|
||||||
match inner_pair.as_rule() {
|
let mut result = None;
|
||||||
Rule::InterfaceOrClassTypeUse => {
|
for inner_pair in type_use_pair.into_inner() {
|
||||||
TypeUse::InterfaceOrClass(build_interface_or_class_type_use(inner_pair))
|
match inner_pair.as_rule() {
|
||||||
|
Rule::Borrow => {
|
||||||
|
borrow_count += 1;
|
||||||
|
}
|
||||||
|
Rule::InterfaceOrClassTypeUse => {
|
||||||
|
result = Some(TypeUse::InterfaceOrClass(
|
||||||
|
build_interface_or_class_type_use(borrow_count, inner_pair),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Rule::TupleTypeUse => {
|
||||||
|
result = Some(TypeUse::Tuple(build_tuple_type_use(
|
||||||
|
borrow_count,
|
||||||
|
inner_pair,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
Rule::FunctionTypeUse => {
|
||||||
|
result = Some(TypeUse::Function(build_function_type_use(
|
||||||
|
borrow_count,
|
||||||
|
inner_pair,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
Rule::TupleTypeUse => TypeUse::Tuple(build_tuple_type_use(inner_pair)),
|
}
|
||||||
Rule::FunctionTypeUse => TypeUse::Function(build_function_type_use(inner_pair)),
|
result.unwrap()
|
||||||
_ => unreachable!(),
|
}
|
||||||
|
|
||||||
|
fn build_interface_or_class_type_use(
|
||||||
|
borrow_count: usize,
|
||||||
|
pair: Pair<Rule>,
|
||||||
|
) -> InterfaceOrClassTypeUse {
|
||||||
|
let mut is_mut = false;
|
||||||
|
let mut fqn = None;
|
||||||
|
let mut generic_arguments = GenericArguments(vec![]);
|
||||||
|
|
||||||
|
for inner_pair in pair.into_inner() {
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::Mut => {
|
||||||
|
is_mut = true;
|
||||||
|
}
|
||||||
|
Rule::FullyQualifiedName => {
|
||||||
|
fqn = Some(build_fqn(inner_pair));
|
||||||
|
}
|
||||||
|
Rule::GenericArguments => {
|
||||||
|
generic_arguments = build_generic_arguments(inner_pair);
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InterfaceOrClassTypeUse {
|
||||||
|
borrow_count,
|
||||||
|
is_mut,
|
||||||
|
fqn: fqn.unwrap(),
|
||||||
|
generics: generic_arguments,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_interface_or_class_type_use(pair: Pair<Rule>) -> InterfaceOrClassTypeUse {
|
fn build_tuple_type_use(borrow_count: usize, tuple_type_use_pair: Pair<Rule>) -> TupleTypeUse {
|
||||||
let mut inner = pair.into_inner();
|
let mut is_mut = false;
|
||||||
let fqn = expect_and_use(inner.next().unwrap(), Rule::FullyQualifiedName, build_fqn);
|
let mut type_uses = vec![];
|
||||||
|
for inner_pair in tuple_type_use_pair.into_inner() {
|
||||||
let generics = inner
|
match inner_pair.as_rule() {
|
||||||
.next()
|
Rule::Mut => {
|
||||||
.map(|inner_pair| {
|
is_mut = true;
|
||||||
expect_and_use(inner_pair, Rule::GenericArguments, build_generic_arguments)
|
}
|
||||||
})
|
Rule::TypeUse => {
|
||||||
.unwrap_or(GenericArguments(vec![]));
|
type_uses.push(build_type_use(inner_pair));
|
||||||
|
}
|
||||||
InterfaceOrClassTypeUse { fqn, generics }
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TupleTypeUse {
|
||||||
|
borrow_count,
|
||||||
|
is_mut,
|
||||||
|
type_uses,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_tuple_type_use(tuple_type_use_pair: Pair<Rule>) -> TupleTypeUse {
|
fn build_function_type_use(borrow_count: usize, function_pair: Pair<Rule>) -> FunctionTypeUse {
|
||||||
TupleTypeUse(
|
|
||||||
tuple_type_use_pair
|
|
||||||
.into_inner()
|
|
||||||
.map(|type_use_pair| expect_and_use(type_use_pair, Rule::TypeUse, build_type_use))
|
|
||||||
.collect(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_function_type_use(function_pair: Pair<Rule>) -> FunctionTypeUse {
|
|
||||||
let mut function_modifier: Option<FunctionModifier> = None;
|
let mut function_modifier: Option<FunctionModifier> = None;
|
||||||
let mut generics: Option<GenericParameters> = None;
|
let mut generics: GenericParameters = GenericParameters(vec![]);
|
||||||
let mut parameters: Option<TupleTypeUse> = None;
|
let mut parameters: Option<FunctionTypeParameters> = None;
|
||||||
let mut inputs: Option<InputArguments> = None;
|
let mut inputs: InputArguments = InputArguments(vec![]);
|
||||||
let mut return_type: Option<ReturnType> = None;
|
let mut return_type: Option<ReturnType> = None;
|
||||||
|
|
||||||
for inner_pair in function_pair.into_inner() {
|
for inner_pair in function_pair.into_inner() {
|
||||||
match inner_pair.as_rule() {
|
match inner_pair.as_rule() {
|
||||||
Rule::FunctionTypeModifier => {
|
Rule::FunctionTypeModifier => {
|
||||||
function_modifier = Some(build_function_modifier(inner_pair));
|
function_modifier = Some(build_function_type_modifier(inner_pair));
|
||||||
}
|
}
|
||||||
Rule::Fn => {}
|
Rule::Fn => {}
|
||||||
Rule::GenericParameters => {
|
Rule::GenericParameters => {
|
||||||
generics = Some(build_generic_parameters(inner_pair));
|
generics = build_generic_parameters(inner_pair);
|
||||||
}
|
}
|
||||||
Rule::TupleTypeUse => {
|
Rule::FunctionTypeParameters => {
|
||||||
parameters = Some(build_tuple_type_use(inner_pair));
|
parameters = Some(build_function_type_parameters(inner_pair));
|
||||||
}
|
}
|
||||||
Rule::FunctionInputArguments => {
|
Rule::FunctionInputArguments => {
|
||||||
inputs = Some(build_function_input_arguments(inner_pair));
|
inputs = build_function_input_arguments(inner_pair);
|
||||||
}
|
}
|
||||||
Rule::ReturnType => {
|
Rule::ReturnType => {
|
||||||
return_type = Some(build_return_type(inner_pair));
|
return_type = Some(build_return_type(inner_pair));
|
||||||
@ -101,10 +144,11 @@ fn build_function_type_use(function_pair: Pair<Rule>) -> FunctionTypeUse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FunctionTypeUse {
|
FunctionTypeUse {
|
||||||
|
borrow_count,
|
||||||
function_modifier,
|
function_modifier,
|
||||||
generics: generics.unwrap_or(GenericParameters(vec![])),
|
generics,
|
||||||
parameters: parameters.unwrap(),
|
parameters: parameters.unwrap(),
|
||||||
inputs: inputs.unwrap_or(InputArguments(vec![])),
|
inputs,
|
||||||
return_type: return_type.unwrap(),
|
return_type: return_type.unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,20 +171,6 @@ fn build_generic_argument(fqn_pair: Pair<Rule>) -> GenericArgument {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_function_modifier(function_modifier_pair: Pair<Rule>) -> FunctionModifier {
|
|
||||||
let mut inner = function_modifier_pair.into_inner();
|
|
||||||
if inner.len() == 2 {
|
|
||||||
FunctionModifier::MutRef
|
|
||||||
} else {
|
|
||||||
match inner.next().unwrap().as_rule() {
|
|
||||||
Rule::Cons => FunctionModifier::Cons,
|
|
||||||
Rule::Mut => FunctionModifier::Mut,
|
|
||||||
Rule::Ref => FunctionModifier::Ref,
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_generic_parameters(generic_parameters_pair: Pair<Rule>) -> GenericParameters {
|
fn build_generic_parameters(generic_parameters_pair: Pair<Rule>) -> GenericParameters {
|
||||||
GenericParameters(
|
GenericParameters(
|
||||||
generic_parameters_pair
|
generic_parameters_pair
|
||||||
@ -156,6 +186,17 @@ fn build_generic_parameters(generic_parameters_pair: Pair<Rule>) -> GenericParam
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_function_type_parameters(
|
||||||
|
function_type_parameters_pair: Pair<Rule>,
|
||||||
|
) -> FunctionTypeParameters {
|
||||||
|
FunctionTypeParameters(
|
||||||
|
function_type_parameters_pair
|
||||||
|
.into_inner()
|
||||||
|
.map(|type_use_pair| expect_and_use(type_use_pair, Rule::TypeUse, build_type_use))
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fn build_function_input_arguments(pair: Pair<Rule>) -> InputArguments {
|
fn build_function_input_arguments(pair: Pair<Rule>) -> InputArguments {
|
||||||
InputArguments(
|
InputArguments(
|
||||||
pair.into_inner()
|
pair.into_inner()
|
||||||
@ -176,6 +217,20 @@ fn build_function_input_arguments(pair: Pair<Rule>) -> InputArguments {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_function_type_modifier(function_type_modifier_pair: Pair<Rule>) -> FunctionModifier {
|
||||||
|
let mut inner = function_type_modifier_pair.into_inner();
|
||||||
|
if inner.len() == 2 {
|
||||||
|
FunctionModifier::MutRef
|
||||||
|
} else {
|
||||||
|
match inner.next().unwrap().as_rule() {
|
||||||
|
Rule::Cons => FunctionModifier::Cons,
|
||||||
|
Rule::Mut => FunctionModifier::Mut,
|
||||||
|
Rule::Ref => FunctionModifier::Ref,
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn build_return_type(return_type_pair: Pair<Rule>) -> ReturnType {
|
fn build_return_type(return_type_pair: Pair<Rule>) -> ReturnType {
|
||||||
let mut inner = return_type_pair.into_inner();
|
let mut inner = return_type_pair.into_inner();
|
||||||
|
|
||||||
@ -215,3 +270,341 @@ fn build_references(ref_list_pair: Pair<Rule>) -> References {
|
|||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn build_compilation_unit(compilation_unit_pair: Pair<Rule>) -> CompilationUnit {
|
||||||
|
let mut namespace = None;
|
||||||
|
let mut declarations = vec![];
|
||||||
|
|
||||||
|
for inner_pair in compilation_unit_pair.into_inner() {
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::Namespace => {
|
||||||
|
namespace = Some(build_namespace(inner_pair));
|
||||||
|
}
|
||||||
|
Rule::ModuleLevelDeclaration => {
|
||||||
|
declarations.push(build_module_level_declaration(inner_pair));
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CompilationUnit {
|
||||||
|
namespace,
|
||||||
|
declarations,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_namespace(namespace_pair: Pair<Rule>) -> FullyQualifiedName {
|
||||||
|
let mut inner = namespace_pair.into_inner();
|
||||||
|
inner.next(); // ns
|
||||||
|
build_fqn(inner.next().unwrap())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_module_level_declaration(pair: Pair<Rule>) -> ModuleLevelDeclaration {
|
||||||
|
let inner_pair = pair.into_inner().next().unwrap();
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::Type => ModuleLevelDeclaration::Type(build_type_declaration(inner_pair)),
|
||||||
|
Rule::Module => ModuleLevelDeclaration::Module(build_module_declaration(inner_pair)),
|
||||||
|
Rule::Interface => {
|
||||||
|
ModuleLevelDeclaration::Interface(build_interface_declaration(inner_pair))
|
||||||
|
}
|
||||||
|
Rule::Class => ModuleLevelDeclaration::Class(build_class_declaration(inner_pair)),
|
||||||
|
Rule::FunctionDefinition => {
|
||||||
|
ModuleLevelDeclaration::Function(build_function_declaration(inner_pair))
|
||||||
|
}
|
||||||
|
Rule::PlatformFunction => ModuleLevelDeclaration::PlatformFunction(
|
||||||
|
build_platform_function_declaration(inner_pair),
|
||||||
|
),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_module_declaration(module_pair: Pair<Rule>) -> ModuleDeclaration {
|
||||||
|
let mut is_public = false;
|
||||||
|
let mut identifier = None;
|
||||||
|
let mut declarations = vec![];
|
||||||
|
|
||||||
|
for inner_pair in module_pair.into_inner() {
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::Pub => {
|
||||||
|
is_public = true;
|
||||||
|
}
|
||||||
|
Rule::Mod => {}
|
||||||
|
Rule::Identifier => {
|
||||||
|
identifier = Some(build_identifier(inner_pair));
|
||||||
|
}
|
||||||
|
Rule::ModuleLevelDeclaration => {
|
||||||
|
declarations.push(build_module_level_declaration(inner_pair));
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ModuleDeclaration {
|
||||||
|
is_public,
|
||||||
|
identifier: identifier.unwrap(),
|
||||||
|
declarations,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_interface_declaration(interface_pair: Pair<Rule>) -> InterfaceDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_class_declaration(class_pair: Pair<Rule>) -> ClassDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_declaration(type_pair: Pair<Rule>) -> TypeDeclaration {
|
||||||
|
let mut is_public = false;
|
||||||
|
let mut identifier = None;
|
||||||
|
let mut lhs = None;
|
||||||
|
let mut where_guards = TypeWhereGuards(vec![]);
|
||||||
|
let mut rhs = None;
|
||||||
|
|
||||||
|
for inner_pair in type_pair.into_inner() {
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::Pub => is_public = true,
|
||||||
|
Rule::TypeKw => {}
|
||||||
|
Rule::Identifier => {
|
||||||
|
identifier = Some(build_identifier(inner_pair));
|
||||||
|
}
|
||||||
|
Rule::TypeUse => {
|
||||||
|
if lhs.is_none() {
|
||||||
|
lhs = Some(build_type_use(inner_pair));
|
||||||
|
} else {
|
||||||
|
rhs = Some(build_type_use(inner_pair));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rule::TypeWhereGuards => {
|
||||||
|
where_guards = build_type_where_guards(inner_pair);
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeDeclaration {
|
||||||
|
is_public,
|
||||||
|
identifier: identifier.unwrap(),
|
||||||
|
lhs: lhs.unwrap(),
|
||||||
|
where_guards,
|
||||||
|
rhs: rhs.unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_where_guards(type_where_guards_pair: Pair<Rule>) -> TypeWhereGuards {
|
||||||
|
let mut inner = type_where_guards_pair.into_inner();
|
||||||
|
inner.next(); // where
|
||||||
|
TypeWhereGuards(
|
||||||
|
inner
|
||||||
|
.map(|type_where_guard_pair| {
|
||||||
|
expect_and_use(
|
||||||
|
type_where_guard_pair,
|
||||||
|
Rule::TypeWhereGuard,
|
||||||
|
build_type_where_guard,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_where_guard(type_where_guard_pair: Pair<Rule>) -> TypeWhereGuard {
|
||||||
|
let mut inner = type_where_guard_pair.into_inner();
|
||||||
|
let identifier = expect_and_use(inner.next().unwrap(), Rule::Identifier, build_identifier);
|
||||||
|
let implements = expect_and_use(
|
||||||
|
inner.next().unwrap(),
|
||||||
|
Rule::TypeImplementsList,
|
||||||
|
build_type_implements_list,
|
||||||
|
);
|
||||||
|
TypeWhereGuard {
|
||||||
|
identifier,
|
||||||
|
implements,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_implements_list(type_implements_list_pair: Pair<Rule>) -> TypeImplementsList {
|
||||||
|
TypeImplementsList(
|
||||||
|
type_implements_list_pair
|
||||||
|
.into_inner()
|
||||||
|
.map(|type_implements_pair| {
|
||||||
|
expect_and_use(
|
||||||
|
type_implements_pair,
|
||||||
|
Rule::TypeImplements,
|
||||||
|
build_type_implements,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_implements(type_implements_pair: Pair<Rule>) -> TypeImplements {
|
||||||
|
let mut inner = type_implements_pair.into_inner();
|
||||||
|
let fqn = expect_and_use(inner.next().unwrap(), Rule::FullyQualifiedName, build_fqn);
|
||||||
|
let arguments = expect_and_use(
|
||||||
|
inner.next().unwrap(),
|
||||||
|
Rule::TypeImplementsArguments,
|
||||||
|
build_type_implements_arguments,
|
||||||
|
);
|
||||||
|
TypeImplements { fqn, arguments }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_implements_arguments(
|
||||||
|
type_implements_arguments_pair: Pair<Rule>,
|
||||||
|
) -> TypeImplementsArguments {
|
||||||
|
let inner_pair = type_implements_arguments_pair.into_inner().next().unwrap();
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::TypeGenericArguments => {
|
||||||
|
TypeImplementsArguments::Generic(build_type_generic_arguments(inner_pair))
|
||||||
|
}
|
||||||
|
Rule::TypeTupleArguments => {
|
||||||
|
TypeImplementsArguments::Tuple(build_type_tuple_arguments(inner_pair))
|
||||||
|
}
|
||||||
|
Rule::TypeFunctionArguments => {
|
||||||
|
TypeImplementsArguments::Function(build_type_function_arguments(inner_pair))
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_generic_arguments(type_generic_arguments_pair: Pair<Rule>) -> TypeGenericArguments {
|
||||||
|
TypeGenericArguments(
|
||||||
|
type_generic_arguments_pair
|
||||||
|
.into_inner()
|
||||||
|
.map(|type_generic_argument_pair| {
|
||||||
|
expect_and_use(
|
||||||
|
type_generic_argument_pair,
|
||||||
|
Rule::TypeGenericArgument,
|
||||||
|
build_type_generic_argument,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_generic_argument(type_generic_argument_pair: Pair<Rule>) -> TypeGenericArgument {
|
||||||
|
let mut inner = type_generic_argument_pair.into_inner();
|
||||||
|
if inner.len() == 2 {
|
||||||
|
inner.next(); // infer
|
||||||
|
TypeGenericArgument::Infer(expect_and_use(
|
||||||
|
inner.next().unwrap(),
|
||||||
|
Rule::Identifier,
|
||||||
|
build_identifier,
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
let inner_pair = inner.next().unwrap();
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::Underscore => TypeGenericArgument::Underscore,
|
||||||
|
Rule::FullyQualifiedName => {
|
||||||
|
TypeGenericArgument::FullyQualifiedName(build_fqn(inner_pair))
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_tuple_arguments(type_tuple_arguments_pair: Pair<Rule>) -> TypeTupleArguments {
|
||||||
|
TypeTupleArguments(
|
||||||
|
type_tuple_arguments_pair
|
||||||
|
.into_inner()
|
||||||
|
.map(|type_tuple_argument_pair| {
|
||||||
|
expect_and_use(
|
||||||
|
type_tuple_argument_pair,
|
||||||
|
Rule::TypeTupleArgument,
|
||||||
|
build_type_tuple_argument,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_tuple_argument(type_tuple_argument_pair: Pair<Rule>) -> TypeTupleArgument {
|
||||||
|
let mut inner = type_tuple_argument_pair.into_inner();
|
||||||
|
let first = inner.next().unwrap();
|
||||||
|
match first.as_rule() {
|
||||||
|
Rule::Underscore => TypeTupleArgument::Underscore,
|
||||||
|
Rule::FullyQualifiedName => TypeTupleArgument::FullyQualifiedName(build_fqn(first)),
|
||||||
|
Rule::Infer => {
|
||||||
|
let second = inner.next().unwrap();
|
||||||
|
TypeTupleArgument::Infer(expect_and_use(second, Rule::Identifier, build_identifier))
|
||||||
|
}
|
||||||
|
Rule::Ellipsis => {
|
||||||
|
let second = inner.next().unwrap();
|
||||||
|
match second.as_rule() {
|
||||||
|
Rule::Underscore => TypeTupleArgument::EllipsisUnderscore,
|
||||||
|
Rule::Infer => TypeTupleArgument::EllipsisInfer(expect_and_use(
|
||||||
|
inner.next().unwrap(),
|
||||||
|
Rule::Identifier,
|
||||||
|
build_identifier,
|
||||||
|
)),
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_type_function_arguments(
|
||||||
|
type_function_arguments_pair: Pair<Rule>,
|
||||||
|
) -> TypeFunctionArguments {
|
||||||
|
let mut generics = TypeGenericArguments(vec![]);
|
||||||
|
let mut parameters = None;
|
||||||
|
let mut return_type = None;
|
||||||
|
|
||||||
|
for inner_pair in type_function_arguments_pair.into_inner() {
|
||||||
|
match inner_pair.as_rule() {
|
||||||
|
Rule::TypeGenericArguments => {
|
||||||
|
generics = build_type_generic_arguments(inner_pair);
|
||||||
|
}
|
||||||
|
Rule::TypeTupleArguments => {
|
||||||
|
parameters = Some(build_type_tuple_arguments(inner_pair));
|
||||||
|
}
|
||||||
|
Rule::ReturnType => {
|
||||||
|
return_type = Some(build_return_type(inner_pair));
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeFunctionArguments {
|
||||||
|
generics,
|
||||||
|
parameters: parameters.unwrap(),
|
||||||
|
return_type: return_type.unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_function_declaration(function_definition_pair: Pair<Rule>) -> FunctionDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_operator_function_declaration(
|
||||||
|
operator_function_pair: Pair<Rule>,
|
||||||
|
) -> OperatorFunctionDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_platform_function_declaration(platform_function_pair: Pair<Rule>) -> PlatformFunctionDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_interface_function_declaration(
|
||||||
|
interface_function_pair: Pair<Rule>,
|
||||||
|
) -> InterfaceFunctionDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_interface_operator_function_declaration(
|
||||||
|
interface_operator_pair: Pair<Rule>,
|
||||||
|
) -> InterfaceOperatorFunctionDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_default_interface_function_declaration(
|
||||||
|
default_interface_function_pair: Pair<Rule>,
|
||||||
|
) -> InterfaceFunctionDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn build_default_interface_operator_function_declaration(
|
||||||
|
default_interface_operator_pair: Pair<Rule>,
|
||||||
|
) -> InterfaceOperatorFunctionDeclaration {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
@ -69,18 +69,25 @@ pub enum TypeUse {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InterfaceOrClassTypeUse {
|
pub struct InterfaceOrClassTypeUse {
|
||||||
|
pub borrow_count: usize,
|
||||||
|
pub is_mut: bool,
|
||||||
pub fqn: FullyQualifiedName,
|
pub fqn: FullyQualifiedName,
|
||||||
pub generics: GenericArguments,
|
pub generics: GenericArguments,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TupleTypeUse(pub Vec<TypeUse>);
|
pub struct TupleTypeUse {
|
||||||
|
pub borrow_count: usize,
|
||||||
|
pub is_mut: bool,
|
||||||
|
pub type_uses: Vec<TypeUse>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FunctionTypeUse {
|
pub struct FunctionTypeUse {
|
||||||
|
pub borrow_count: usize,
|
||||||
pub function_modifier: Option<FunctionModifier>,
|
pub function_modifier: Option<FunctionModifier>,
|
||||||
pub generics: GenericParameters,
|
pub generics: GenericParameters,
|
||||||
pub parameters: TupleTypeUse,
|
pub parameters: FunctionTypeParameters,
|
||||||
pub inputs: InputArguments,
|
pub inputs: InputArguments,
|
||||||
pub return_type: ReturnType,
|
pub return_type: ReturnType,
|
||||||
}
|
}
|
||||||
@ -126,6 +133,11 @@ impl GenericParameters {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GenericParameter(Identifier);
|
pub struct GenericParameter(Identifier);
|
||||||
|
|
||||||
|
/* Function Type Parameters */
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct FunctionTypeParameters(pub Vec<TypeUse>);
|
||||||
|
|
||||||
/* Input Arguments */
|
/* Input Arguments */
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -341,7 +353,7 @@ pub enum TypeTupleArgument {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TypeFunctionArguments {
|
pub struct TypeFunctionArguments {
|
||||||
pub generics: GenericArguments,
|
pub generics: TypeGenericArguments,
|
||||||
pub parameters: TypeTupleArguments,
|
pub parameters: TypeTupleArguments,
|
||||||
pub return_type: ReturnType,
|
pub return_type: ReturnType,
|
||||||
}
|
}
|
||||||
@ -387,6 +399,7 @@ pub struct InterfaceFunctionDeclaration {
|
|||||||
pub identifier: Identifier,
|
pub identifier: Identifier,
|
||||||
pub parameters: Parameters,
|
pub parameters: Parameters,
|
||||||
pub return_type: ReturnType,
|
pub return_type: ReturnType,
|
||||||
|
pub body: Option<FunctionBody>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -396,10 +409,9 @@ pub struct InterfaceOperatorFunctionDeclaration {
|
|||||||
pub operator: Operator,
|
pub operator: Operator,
|
||||||
pub parameters: Parameters,
|
pub parameters: Parameters,
|
||||||
pub return_type: ReturnType,
|
pub return_type: ReturnType,
|
||||||
|
pub body: Option<FunctionBody>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: default interface functions
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum FunctionBody {
|
pub enum FunctionBody {
|
||||||
Equals(Expression),
|
Equals(Expression),
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use std::fmt::write;
|
|
||||||
use crate::ast::*;
|
use crate::ast::*;
|
||||||
|
|
||||||
macro_rules! to_unparse_vec {
|
macro_rules! to_unparse_vec {
|
||||||
@ -80,7 +79,7 @@ impl Unparse for Operator {
|
|||||||
use Operator::*;
|
use Operator::*;
|
||||||
match self {
|
match self {
|
||||||
Binary(op) => op.unparse(buf),
|
Binary(op) => op.unparse(buf),
|
||||||
Unary(op) => op.unparse(buf),
|
PrefixUnary(op) => op.unparse(buf),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,9 +107,9 @@ impl Unparse for BinaryOperator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Unparse for UnaryOperator {
|
impl Unparse for PrefixUnaryOperator {
|
||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
||||||
use UnaryOperator::*;
|
use PrefixUnaryOperator::*;
|
||||||
match self {
|
match self {
|
||||||
Not => write!(buf, "!"),
|
Not => write!(buf, "!"),
|
||||||
Negative => write!(buf, "-"),
|
Negative => write!(buf, "-"),
|
||||||
@ -130,7 +129,7 @@ impl Unparse for Identifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ListUnparse for Fqn {
|
impl ListUnparse for FullyQualifiedName {
|
||||||
fn separator() -> &'static str {
|
fn separator() -> &'static str {
|
||||||
"::"
|
"::"
|
||||||
}
|
}
|
||||||
@ -198,7 +197,9 @@ impl Unparse for TypeUse {
|
|||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
||||||
use TypeUse::*;
|
use TypeUse::*;
|
||||||
match self {
|
match self {
|
||||||
InterfaceOrClass(interface_or_class_type_use) => interface_or_class_type_use.unparse(buf),
|
InterfaceOrClass(interface_or_class_type_use) => {
|
||||||
|
interface_or_class_type_use.unparse(buf)
|
||||||
|
}
|
||||||
Tuple(tuple_type_use) => tuple_type_use.unparse(buf),
|
Tuple(tuple_type_use) => tuple_type_use.unparse(buf),
|
||||||
Function(function_type_use) => function_type_use.unparse(buf),
|
Function(function_type_use) => function_type_use.unparse(buf),
|
||||||
}
|
}
|
||||||
@ -252,44 +253,6 @@ impl Unparse for FunctionTypeUse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Unparse for TypeArguments {
|
|
||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
use TypeArguments::*;
|
|
||||||
match self {
|
|
||||||
Generics(generic_arguments) => generic_arguments.unparse(buf),
|
|
||||||
Tuple(tuple_arguments) => tuple_arguments.unparse(buf),
|
|
||||||
Function(function_type_arguments) => function_type_arguments.unparse(buf),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ListUnparse for TupleArguments {
|
|
||||||
fn prefix() -> &'static str {
|
|
||||||
"("
|
|
||||||
}
|
|
||||||
|
|
||||||
fn separator() -> &'static str {
|
|
||||||
", "
|
|
||||||
}
|
|
||||||
|
|
||||||
fn suffix() -> &'static str {
|
|
||||||
")"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inner(&self) -> Vec<&dyn Unparse> {
|
|
||||||
to_unparse_vec!(self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Unparse for FunctionTypeArguments {
|
|
||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
self.parameters.unparse(buf)?;
|
|
||||||
write!(buf, " ")?;
|
|
||||||
self.return_type.unparse(buf)?;
|
|
||||||
unparse_ok!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Function components */
|
/* Function components */
|
||||||
|
|
||||||
impl ListUnparse for Parameters {
|
impl ListUnparse for Parameters {
|
||||||
@ -417,31 +380,6 @@ impl Unparse for InputArgument {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Where guards */
|
|
||||||
|
|
||||||
impl ListUnparse for WhereGuards {
|
|
||||||
fn prefix() -> &'static str {
|
|
||||||
"where "
|
|
||||||
}
|
|
||||||
|
|
||||||
fn separator() -> &'static str {
|
|
||||||
", "
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inner(&self) -> Vec<&dyn Unparse> {
|
|
||||||
to_unparse_vec!(self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Unparse for WhereGuard {
|
|
||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
self.identifier.unparse(buf)?;
|
|
||||||
write!(buf, " : ")?;
|
|
||||||
self.implements.unparse(buf)?;
|
|
||||||
unparse_ok!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Implements */
|
/* Implements */
|
||||||
|
|
||||||
impl ListUnparse for ImplementsList {
|
impl ListUnparse for ImplementsList {
|
||||||
@ -540,7 +478,6 @@ impl Unparse for TypeDeclaration {
|
|||||||
type_parameters.unparse(buf)?;
|
type_parameters.unparse(buf)?;
|
||||||
write!(buf, " ")?;
|
write!(buf, " ")?;
|
||||||
}
|
}
|
||||||
self.where_guards.unparse(buf)?;
|
|
||||||
write!(buf, "= ")?;
|
write!(buf, "= ")?;
|
||||||
self.rhs.unparse(buf)?;
|
self.rhs.unparse(buf)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -578,10 +515,6 @@ impl Unparse for InterfaceDeclaration {
|
|||||||
self.implements.unparse(buf)?;
|
self.implements.unparse(buf)?;
|
||||||
write!(buf, " ")?;
|
write!(buf, " ")?;
|
||||||
}
|
}
|
||||||
if !self.where_guards.is_empty() {
|
|
||||||
self.where_guards.unparse(buf)?;
|
|
||||||
write!(buf, " ")?;
|
|
||||||
}
|
|
||||||
unparse_contained_declarations!(self.declarations, buf);
|
unparse_contained_declarations!(self.declarations, buf);
|
||||||
unparse_ok!()
|
unparse_ok!()
|
||||||
}
|
}
|
||||||
@ -605,14 +538,6 @@ impl Unparse for ClassDeclaration {
|
|||||||
self.implements.unparse(buf)?;
|
self.implements.unparse(buf)?;
|
||||||
write!(buf, " ")?;
|
write!(buf, " ")?;
|
||||||
}
|
}
|
||||||
if !self.inputs.is_empty() {
|
|
||||||
self.inputs.unparse(buf)?;
|
|
||||||
write!(buf, " ")?;
|
|
||||||
}
|
|
||||||
if !self.where_guards.is_empty() {
|
|
||||||
self.where_guards.unparse(buf)?;
|
|
||||||
write!(buf, " ")?;
|
|
||||||
}
|
|
||||||
unparse_contained_declarations!(self.declarations, buf);
|
unparse_contained_declarations!(self.declarations, buf);
|
||||||
unparse_ok!()
|
unparse_ok!()
|
||||||
}
|
}
|
||||||
@ -637,12 +562,12 @@ impl Unparse for FunctionBody {
|
|||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
||||||
use FunctionBody::*;
|
use FunctionBody::*;
|
||||||
match self {
|
match self {
|
||||||
EqualsBody(expression) => {
|
Equals(expression) => {
|
||||||
write!(buf, "= ")?;
|
write!(buf, "= ")?;
|
||||||
expression.unparse(buf)
|
expression.unparse(buf)
|
||||||
}
|
}
|
||||||
BlockBody(body) => body.unparse(buf),
|
Block(body) => body.unparse(buf),
|
||||||
AliasBody(identifier) => {
|
Alias(identifier) => {
|
||||||
write!(buf, "alias ")?;
|
write!(buf, "alias ")?;
|
||||||
identifier.unparse(buf)
|
identifier.unparse(buf)
|
||||||
}
|
}
|
||||||
@ -752,46 +677,6 @@ impl Unparse for InterfaceOperatorFunctionDeclaration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Type components */
|
|
||||||
|
|
||||||
impl Unparse for TypeParameters {
|
|
||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
use TypeParameters::*;
|
|
||||||
match self {
|
|
||||||
Generic(generic_parameters) => generic_parameters.unparse(buf),
|
|
||||||
Tuple(tuple_parameters) => tuple_parameters.unparse(buf),
|
|
||||||
Function(function_type_parameters) => function_type_parameters.unparse(buf),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ListUnparse for TupleParameters {
|
|
||||||
fn prefix() -> &'static str {
|
|
||||||
"("
|
|
||||||
}
|
|
||||||
|
|
||||||
fn separator() -> &'static str {
|
|
||||||
", "
|
|
||||||
}
|
|
||||||
|
|
||||||
fn suffix() -> &'static str {
|
|
||||||
")"
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inner(&self) -> Vec<&dyn Unparse> {
|
|
||||||
to_unparse_vec!(self.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Unparse for FunctionTypeParameters {
|
|
||||||
fn unparse(&self, buf: &mut dyn std::fmt::Write) -> std::fmt::Result {
|
|
||||||
self.parameters.unparse(buf)?;
|
|
||||||
write!(buf, " ")?;
|
|
||||||
self.return_type.unparse(buf)?;
|
|
||||||
unparse_ok!()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Class components */
|
/* Class components */
|
||||||
|
|
||||||
impl ListUnparse for ClassConstructor {
|
impl ListUnparse for ClassConstructor {
|
||||||
@ -915,7 +800,7 @@ impl Unparse for IfStatement {
|
|||||||
write!(buf, "if ")?;
|
write!(buf, "if ")?;
|
||||||
self.condition.unparse(buf)?;
|
self.condition.unparse(buf)?;
|
||||||
write!(buf, " {{\n")?;
|
write!(buf, " {{\n")?;
|
||||||
self.then_branch.unparse(buf)?;
|
self.then_block.unparse(buf)?;
|
||||||
write!(buf, "\n}}")?;
|
write!(buf, "\n}}")?;
|
||||||
unparse_ok!()
|
unparse_ok!()
|
||||||
}
|
}
|
||||||
@ -926,11 +811,11 @@ impl Unparse for IfElseStatement {
|
|||||||
write!(buf, "if ")?;
|
write!(buf, "if ")?;
|
||||||
self.condition.unparse(buf)?;
|
self.condition.unparse(buf)?;
|
||||||
write!(buf, " ")?;
|
write!(buf, " ")?;
|
||||||
self.then_branch.unparse(buf)?;
|
self.then_block.unparse(buf)?;
|
||||||
write!(buf, " ")?;
|
write!(buf, " ")?;
|
||||||
self.else_ifs.unparse(buf)?;
|
self.else_ifs.unparse(buf)?;
|
||||||
write!(buf, "else ")?;
|
write!(buf, "else ")?;
|
||||||
self.else_branch.unparse(buf)?;
|
self.else_Block.unparse(buf)?;
|
||||||
unparse_ok!()
|
unparse_ok!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,10 +144,7 @@ FullyQualifiedName = {
|
|||||||
// Parameters = declaration
|
// Parameters = declaration
|
||||||
|
|
||||||
TypeUse = {
|
TypeUse = {
|
||||||
(
|
Borrow*
|
||||||
Mut
|
|
||||||
| ( Borrow ~ Mut? )*
|
|
||||||
)?
|
|
||||||
~ (
|
~ (
|
||||||
InterfaceOrClassTypeUse
|
InterfaceOrClassTypeUse
|
||||||
| TupleTypeUse
|
| TupleTypeUse
|
||||||
@ -156,12 +153,14 @@ TypeUse = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
InterfaceOrClassTypeUse = {
|
InterfaceOrClassTypeUse = {
|
||||||
FullyQualifiedName
|
Mut?
|
||||||
|
~ FullyQualifiedName
|
||||||
~ GenericArguments?
|
~ GenericArguments?
|
||||||
}
|
}
|
||||||
|
|
||||||
TupleTypeUse = {
|
TupleTypeUse = {
|
||||||
"("
|
Mut?
|
||||||
|
~ "("
|
||||||
~ (
|
~ (
|
||||||
TypeUse
|
TypeUse
|
||||||
~ ( "," ~ TypeUse )*
|
~ ( "," ~ TypeUse )*
|
||||||
@ -173,7 +172,7 @@ FunctionTypeUse = {
|
|||||||
FunctionTypeModifier?
|
FunctionTypeModifier?
|
||||||
~ Fn
|
~ Fn
|
||||||
~ GenericParameters?
|
~ GenericParameters?
|
||||||
~ TupleTypeUse
|
~ FunctionTypeParameters
|
||||||
~ FunctionInputArguments?
|
~ FunctionInputArguments?
|
||||||
~ ReturnType
|
~ ReturnType
|
||||||
}
|
}
|
||||||
@ -196,6 +195,17 @@ GenericParameters = {
|
|||||||
~ ">"
|
~ ">"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Function Type Parameters
|
||||||
|
|
||||||
|
FunctionTypeParameters = {
|
||||||
|
"("
|
||||||
|
~ (
|
||||||
|
TypeUse
|
||||||
|
~ ( "," ~ TypeUse )*
|
||||||
|
)?
|
||||||
|
~ ")"
|
||||||
|
}
|
||||||
|
|
||||||
// Function Input Arguments
|
// Function Input Arguments
|
||||||
|
|
||||||
FunctionInputArguments = {
|
FunctionInputArguments = {
|
||||||
|
Loading…
Reference in New Issue
Block a user