diff --git a/compiler/ast/src/functions/input/function_input.rs b/compiler/ast/src/functions/input/function_input.rs index 1e7c46895c..eae6971964 100644 --- a/compiler/ast/src/functions/input/function_input.rs +++ b/compiler/ast/src/functions/input/function_input.rs @@ -27,6 +27,10 @@ pub struct FunctionInputVariable { pub identifier: Identifier, /// Is it a const parameter? pub const_: bool, + /// Is it a private input parameter? + pub private: bool, + /// Is it a public parameter? + pub public: bool, /// Is it a mutable parameter? pub mutable: bool, /// What's the parameter's type? diff --git a/compiler/ast/src/reducer/reconstructing_reducer.rs b/compiler/ast/src/reducer/reconstructing_reducer.rs index 9521010288..d015103a64 100644 --- a/compiler/ast/src/reducer/reconstructing_reducer.rs +++ b/compiler/ast/src/reducer/reconstructing_reducer.rs @@ -276,6 +276,8 @@ pub trait ReconstructingReducer { identifier, const_: variable.const_, mutable: variable.mutable, + private: variable.private, + public: variable.public, type_, span: variable.span.clone(), }) diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index 207711b1d5..34db99b7b5 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -67,6 +67,9 @@ impl ParserContext<'_> { pub fn parse_function_parameters(&mut self) -> Result { let const_ = self.eat(Token::Const); let mutable = self.eat(Token::Mut); + let private = self.eat(Token::Private).is_some(); + let public = self.eat(Token::Public).is_some(); + let name = self.expect_ident()?; if let Some(mutable) = &mutable { @@ -78,6 +81,8 @@ impl ParserContext<'_> { Ok(FunctionInput::Variable(FunctionInputVariable { const_: const_.is_some(), mutable: const_.is_none(), + private, + public, type_, span: name.span.clone(), identifier: name, diff --git a/compiler/parser/src/tokenizer/lexer.rs b/compiler/parser/src/tokenizer/lexer.rs index f8f87ae77c..46b84611ad 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -421,6 +421,8 @@ impl Token { "input" => Token::Input, "let" => Token::Let, "mut" => Token::Mut, + "private" => Token::Private, + "public" => Token::Public, "return" => Token::Return, "true" => Token::True, "type" => Token::Type, diff --git a/compiler/parser/src/tokenizer/token.rs b/compiler/parser/src/tokenizer/token.rs index f4f3fed866..43c906b94b 100644 --- a/compiler/parser/src/tokenizer/token.rs +++ b/compiler/parser/src/tokenizer/token.rs @@ -128,6 +128,10 @@ pub enum Token { In, Let, Mut, + /// For private inputs. + Private, + /// For public inputs. + Public, Return, Type, @@ -198,6 +202,8 @@ impl Token { Token::Input => sym::input, Token::Let => sym::Let, Token::Mut => sym::Mut, + Token::Private => sym::Private, + Token::Public => sym::Public, Token::Return => sym::Return, Token::True => sym::True, Token::Type => sym::Type, @@ -294,6 +300,8 @@ impl fmt::Display for Token { In => write!(f, "in"), Let => write!(f, "let"), Mut => write!(f, "mut"), + Private => write!(f, "private"), + Public => write!(f, "public"), Return => write!(f, "return"), Type => write!(f, "type"), Eof => write!(f, ""), diff --git a/leo/span/src/symbol.rs b/leo/span/src/symbol.rs index 7f5bbe42b0..d4dd9daa20 100644 --- a/leo/span/src/symbol.rs +++ b/leo/span/src/symbol.rs @@ -131,6 +131,8 @@ symbols! { main, Mut: "mut", prelude, + Private: "private", + Public: "public", Return: "return", Star: "*", std,