diff --git a/compiler/tests/group/input/point.in b/compiler/tests/group/input/point.in new file mode 100644 index 0000000000..9d49d9d847 --- /dev/null +++ b/compiler/tests/group/input/point.in @@ -0,0 +1,2 @@ +[main] +a: group = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; \ No newline at end of file diff --git a/compiler/tests/group/mod.rs b/compiler/tests/group/mod.rs index 01839ecec8..69cb0dfed1 100644 --- a/compiler/tests/group/mod.rs +++ b/compiler/tests/group/mod.rs @@ -44,6 +44,16 @@ fn test_point() { assert_satisfied(program); } +#[test] +fn test_point_input() { + let program_bytes = include_bytes!("point_input.leo"); + let input_bytes = include_bytes!("input/point.in"); + + let program = parse_program_with_input(program_bytes, input_bytes).unwrap(); + + assert_satisfied(program); +} + #[test] fn test_input() { let program_bytes = include_bytes!("input.leo"); diff --git a/compiler/tests/group/point_input.leo b/compiler/tests/group/point_input.leo new file mode 100644 index 0000000000..68d8c458a3 --- /dev/null +++ b/compiler/tests/group/point_input.leo @@ -0,0 +1,3 @@ +function main(a: group) { + let b = a; +} \ No newline at end of file diff --git a/input/src/leo-input.pest b/input/src/leo-input.pest index bc487e98a5..bf9c86f9aa 100644 --- a/input/src/leo-input.pest +++ b/input/src/leo-input.pest @@ -8,8 +8,10 @@ protected_name = { | "const" | "else" | "false" - | "function" + | type_field | "for" + | "function" + | type_group | "if" | "import" | "in" diff --git a/input/src/values/group_value.rs b/input/src/values/group_value.rs index da8a076576..27e2633224 100644 --- a/input/src/values/group_value.rs +++ b/input/src/values/group_value.rs @@ -7,7 +7,7 @@ use std::fmt; #[derive(Clone, Debug, FromPest, PartialEq, Eq)] #[pest_ast(rule(Rule::value_group))] pub struct GroupValue<'ast> { - pub value: GroupTuple<'ast>, + pub value: GroupRepresentation<'ast>, pub _type: GroupType, #[pest_ast(outer())] pub span: Span<'ast>, @@ -19,6 +19,22 @@ impl<'ast> fmt::Display for GroupValue<'ast> { } } +#[derive(Clone, Debug, FromPest, PartialEq, Eq)] +#[pest_ast(rule(Rule::group_single_or_tuple))] +pub enum GroupRepresentation<'ast> { + Single(NumberValue<'ast>), + Tuple(GroupTuple<'ast>), +} + +impl<'ast> fmt::Display for GroupRepresentation<'ast> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + GroupRepresentation::Single(number) => write!(f, "{}", number), + GroupRepresentation::Tuple(tuple) => write!(f, "{}", tuple), + } + } +} + #[derive(Clone, Debug, FromPest, PartialEq, Eq)] #[pest_ast(rule(Rule::group_tuple))] pub struct GroupTuple<'ast> {