mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-19 23:52:02 +03:00
remove private keyword
This commit is contained in:
parent
6aa6b0fa07
commit
16914e3ce8
@ -27,8 +27,6 @@ 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?
|
||||
@ -41,7 +39,11 @@ pub struct FunctionInputVariable {
|
||||
|
||||
impl FunctionInputVariable {
|
||||
fn format(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
// mut var: bool
|
||||
if self.public {
|
||||
write!(f, "public ")?;
|
||||
} else {
|
||||
write!(f, "private ")?;
|
||||
}
|
||||
if self.const_ {
|
||||
write!(f, "const ")?;
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ use crate::{Expression, Identifier, Type};
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Definition {
|
||||
pub const_: bool,
|
||||
pub private: bool,
|
||||
pub public: bool,
|
||||
pub type_: Type,
|
||||
pub name: Identifier,
|
||||
|
@ -276,7 +276,6 @@ pub trait ReconstructingReducer {
|
||||
identifier,
|
||||
const_: variable.const_,
|
||||
mutable: variable.mutable,
|
||||
private: variable.private,
|
||||
public: variable.public,
|
||||
type_,
|
||||
span: variable.span.clone(),
|
||||
|
@ -67,7 +67,6 @@ impl ParserContext<'_> {
|
||||
pub fn parse_function_parameters(&mut self) -> Result<FunctionInput> {
|
||||
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()?;
|
||||
@ -81,7 +80,6 @@ impl ParserContext<'_> {
|
||||
Ok(FunctionInput::Variable(FunctionInputVariable {
|
||||
const_: const_.is_some(),
|
||||
mutable: const_.is_none(),
|
||||
private,
|
||||
public,
|
||||
type_,
|
||||
span: name.span.clone(),
|
||||
|
@ -17,7 +17,6 @@
|
||||
use super::*;
|
||||
|
||||
use leo_errors::{ParserError, Result};
|
||||
use leo_span::sym;
|
||||
|
||||
impl ParserContext<'_> {
|
||||
/// Returns a [`ParsedInputFile`] struct filled with the data acquired in the file.
|
||||
@ -50,11 +49,11 @@ impl ParserContext<'_> {
|
||||
let mut definitions = Vec::new();
|
||||
|
||||
while let Some(SpannedToken {
|
||||
token: Token::Const | Token::Private | Token::Public | Token::Ident(_),
|
||||
token: Token::Const | Token::Public | Token::Ident(_),
|
||||
..
|
||||
}) = self.peek_option()
|
||||
{
|
||||
definitions.push(self.parse_input_definition(section.name == sym::main)?);
|
||||
definitions.push(self.parse_input_definition()?);
|
||||
}
|
||||
|
||||
Ok(Section {
|
||||
@ -67,18 +66,10 @@ impl ParserContext<'_> {
|
||||
/// Parses a single parameter definition:
|
||||
/// `<identifier> : <type> = <expression>;`
|
||||
/// Returns [`Definition`].
|
||||
pub fn parse_input_definition(&mut self, is_main: bool) -> Result<Definition> {
|
||||
pub fn parse_input_definition(&mut self) -> Result<Definition> {
|
||||
let const_ = self.eat(Token::Const).is_some();
|
||||
let private = self.eat(Token::Private).is_some();
|
||||
let public = self.eat(Token::Public).is_some();
|
||||
|
||||
match (const_, private, public) {
|
||||
(true, false, false) | (false, true, false) | (false, false, true) if is_main => {}
|
||||
(false, false, false) if is_main => return Err(ParserError::inputs_no_variable_type_specified().into()),
|
||||
_ if is_main => return Err(ParserError::inputs_multpe_variable_types_specified().into()),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let name = self.expect_ident()?;
|
||||
self.expect(Token::Colon)?;
|
||||
let (type_, span) = self.parse_type()?;
|
||||
@ -88,7 +79,6 @@ impl ParserContext<'_> {
|
||||
|
||||
Ok(Definition {
|
||||
const_,
|
||||
private,
|
||||
public,
|
||||
name,
|
||||
type_,
|
||||
|
@ -421,7 +421,6 @@ impl Token {
|
||||
"input" => Token::Input,
|
||||
"let" => Token::Let,
|
||||
"mut" => Token::Mut,
|
||||
"private" => Token::Private,
|
||||
"public" => Token::Public,
|
||||
"return" => Token::Return,
|
||||
"true" => Token::True,
|
||||
|
@ -128,8 +128,6 @@ pub enum Token {
|
||||
In,
|
||||
Let,
|
||||
Mut,
|
||||
/// For private inputs.
|
||||
Private,
|
||||
/// For public inputs.
|
||||
Public,
|
||||
Return,
|
||||
@ -162,6 +160,7 @@ pub const KEYWORD_TOKENS: &[Token] = &[
|
||||
Token::Input,
|
||||
Token::Let,
|
||||
Token::Mut,
|
||||
Token::Public,
|
||||
Token::Return,
|
||||
Token::True,
|
||||
Token::Type,
|
||||
@ -202,7 +201,6 @@ 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,
|
||||
@ -300,7 +298,6 @@ 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"),
|
||||
|
@ -358,20 +358,4 @@ create_errors!(
|
||||
msg: format!("Found the char `{}`, but expected `{}`", found, expected),
|
||||
help: None,
|
||||
}
|
||||
|
||||
/// For when a user does not specify a type of input.
|
||||
@backtraced
|
||||
inputs_no_variable_type_specified {
|
||||
args: (),
|
||||
msg: "An input must be either const, private, or public.",
|
||||
help: None,
|
||||
}
|
||||
|
||||
/// For when a user specified more than a type of input.
|
||||
@backtraced
|
||||
inputs_multpe_variable_types_specified {
|
||||
args: (),
|
||||
msg: "An input can only be one of const, private, or public.",
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -131,7 +131,6 @@ symbols! {
|
||||
main,
|
||||
Mut: "mut",
|
||||
prelude,
|
||||
Private: "private",
|
||||
Public: "public",
|
||||
Return: "return",
|
||||
Star: "*",
|
||||
|
Loading…
Reference in New Issue
Block a user