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