intial adding of public and private params

This commit is contained in:
gluax 2022-04-04 14:14:17 -07:00
parent 5353b33c1b
commit 76070a8795
6 changed files with 23 additions and 0 deletions

View File

@ -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?

View File

@ -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(),
})

View File

@ -67,6 +67,9 @@ 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()?;
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,

View File

@ -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,

View File

@ -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, ""),

View File

@ -131,6 +131,8 @@ symbols! {
main,
Mut: "mut",
prelude,
Private: "private",
Public: "public",
Return: "return",
Star: "*",
std,