change struct declaration syntax
This commit is contained in:
parent
20f3a980fe
commit
47395d0b4b
7 changed files with 35 additions and 35 deletions
|
@ -1,6 +1,6 @@
|
|||
struct Bar {
|
||||
field[2] c
|
||||
bool b
|
||||
bool d
|
||||
}
|
||||
|
||||
struct Foo {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
struct Point {
|
||||
x: field,
|
||||
y: field
|
||||
field x
|
||||
field y
|
||||
}
|
||||
|
||||
def main(Point p, Point q) -> (Point):
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
struct Bar {
|
||||
c: field[2],
|
||||
d: bool
|
||||
field[2] c
|
||||
bool d
|
||||
}
|
||||
|
||||
struct Foo {
|
||||
a: Bar,
|
||||
b: bool
|
||||
Bar a
|
||||
bool b
|
||||
}
|
||||
|
||||
def main() -> (Foo):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
struct A {
|
||||
a: field,
|
||||
b: bool
|
||||
field a
|
||||
bool b
|
||||
}
|
||||
|
||||
def main(A a) -> (A):
|
||||
|
|
|
@ -149,40 +149,40 @@ mod tests {
|
|||
fn parse_struct_def() {
|
||||
parses_to! {
|
||||
parser: ZoKratesParser,
|
||||
input: "struct Foo { foo: field, bar: field[2] }
|
||||
input: "struct Foo { field foo\n field[2] bar }
|
||||
",
|
||||
rule: Rule::ty_struct_definition,
|
||||
tokens: [
|
||||
ty_struct_definition(0, 41, [
|
||||
ty_struct_definition(0, 39, [
|
||||
identifier(7, 10),
|
||||
struct_field(13, 23, [
|
||||
identifier(13, 16),
|
||||
ty(18, 23, [
|
||||
ty_basic(18, 23, [
|
||||
ty_field(18, 23)
|
||||
struct_field(13, 22, [
|
||||
ty(13, 18, [
|
||||
ty_basic(13, 18, [
|
||||
ty_field(13, 18)
|
||||
])
|
||||
])
|
||||
]),
|
||||
identifier(19, 22)
|
||||
]),
|
||||
struct_field(25, 39, [
|
||||
identifier(25, 28),
|
||||
ty(30, 39, [
|
||||
ty_array(30, 39, [
|
||||
ty_basic_or_struct(30, 35, [
|
||||
ty_basic(30, 35, [
|
||||
ty_field(30, 35)
|
||||
struct_field(24, 36, [
|
||||
ty(24, 33, [
|
||||
ty_array(24, 33, [
|
||||
ty_basic_or_struct(24, 29, [
|
||||
ty_basic(24, 29, [
|
||||
ty_field(24, 29)
|
||||
])
|
||||
]),
|
||||
expression(36, 37, [
|
||||
term(36, 37, [
|
||||
primary_expression(36, 37, [
|
||||
constant(36, 37, [
|
||||
decimal_number(36, 37)
|
||||
expression(30, 31, [
|
||||
term(30, 31, [
|
||||
primary_expression(30, 31, [
|
||||
constant(30, 31, [
|
||||
decimal_number(30, 31)
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
])
|
||||
]),
|
||||
identifier(33, 36)
|
||||
])
|
||||
])
|
||||
]
|
||||
|
|
|
@ -26,8 +26,8 @@ type_list = _{(ty ~ ("," ~ ty)*)?}
|
|||
ty_struct = { identifier }
|
||||
// type definitions
|
||||
ty_struct_definition = { "struct" ~ identifier ~ "{" ~ NEWLINE* ~ struct_field_list ~ NEWLINE* ~ "}" ~ NEWLINE* }
|
||||
struct_field_list = _{(struct_field ~ ("," ~ NEWLINE* ~ struct_field)*)? ~ ","? }
|
||||
struct_field = { identifier ~ ":" ~ ty }
|
||||
struct_field_list = _{(struct_field ~ (NEWLINE+ ~ struct_field)*)? }
|
||||
struct_field = { ty ~ identifier }
|
||||
|
||||
vis_private = {"private"}
|
||||
vis_public = {"public"}
|
||||
|
|
|
@ -178,8 +178,8 @@ mod ast {
|
|||
#[derive(Debug, FromPest, PartialEq, Clone)]
|
||||
#[pest_ast(rule(Rule::struct_field))]
|
||||
pub struct StructField<'ast> {
|
||||
pub id: IdentifierExpression<'ast>,
|
||||
pub ty: Type<'ast>,
|
||||
pub id: IdentifierExpression<'ast>,
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
@ -1083,8 +1083,8 @@ mod tests {
|
|||
let source = r#"import "heyman" as yo
|
||||
|
||||
struct Foo {
|
||||
foo: field[2],
|
||||
bar: Bar
|
||||
field[2] foo
|
||||
Bar bar
|
||||
}
|
||||
|
||||
def main(private field[23] a) -> (bool[234 + 6]):
|
||||
|
|
Loading…
Reference in a new issue