mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 23:23:50 +03:00
Migrates boolean value
This commit is contained in:
parent
103a12f7ab
commit
47bcb069ba
@ -9,11 +9,9 @@ use crate::{
|
||||
ArrayType,
|
||||
CircuitType,
|
||||
DataType,
|
||||
FieldType,
|
||||
ForStatement,
|
||||
GroupType,
|
||||
Identifier,
|
||||
IntegerType,
|
||||
SelfType,
|
||||
Visibility
|
||||
},
|
||||
@ -120,22 +118,6 @@ impl<'ast> fmt::Display for Group<'ast> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::value_boolean))]
|
||||
pub struct Boolean<'ast> {
|
||||
#[pest_ast(outer(with(span_into_string)))]
|
||||
pub value: String,
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for Boolean<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Variables + Mutability
|
||||
|
||||
|
@ -106,13 +106,16 @@ value_implicit = { value_number }
|
||||
// Declared in values/integer_value.rs
|
||||
value_integer = { value_number ~ type_integer }
|
||||
|
||||
// Declared in values/boolean_value.rs
|
||||
value_boolean = { "true" | "false" }
|
||||
|
||||
// Declared in values/field_value.rs
|
||||
value_field = { value_number ~ type_field }
|
||||
|
||||
group_tuple = {"(" ~ value_number ~ "," ~ value_number ~ ")"}
|
||||
group_single_or_tuple = {value_number | group_tuple}
|
||||
value_group = { group_single_or_tuple ~ type_group }
|
||||
value_boolean = { "true" | "false" }
|
||||
|
||||
value = { value_field | value_group | value_boolean | value_integer | value_implicit }
|
||||
expression_primitive = { value | identifier }
|
||||
|
||||
|
20
ast/src/values/boolean_value.rs
Normal file
20
ast/src/values/boolean_value.rs
Normal file
@ -0,0 +1,20 @@
|
||||
use crate::ast::{Rule, span_into_string};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Debug, FromPest, PartialEq)]
|
||||
#[pest_ast(rule(Rule::value_boolean))]
|
||||
pub struct BooleanValue<'ast> {
|
||||
#[pest_ast(outer(with(span_into_string)))]
|
||||
pub value: String,
|
||||
#[pest_ast(outer())]
|
||||
pub span: Span<'ast>,
|
||||
}
|
||||
|
||||
impl<'ast> fmt::Display for BooleanValue<'ast> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.value)
|
||||
}
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
pub mod boolean_value;
|
||||
pub use boolean_value::*;
|
||||
|
||||
pub mod field_value;
|
||||
pub use field_value::*;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::{ast::{Group, Boolean, Rule}, values::{IntegerValue, FieldValue, NumberImplicitValue}};
|
||||
use crate::{ast::{Group, Rule}, values::{BooleanValue, IntegerValue, FieldValue, NumberImplicitValue}};
|
||||
|
||||
use pest::Span;
|
||||
use pest_ast::FromPest;
|
||||
@ -10,7 +10,7 @@ pub enum Value<'ast> {
|
||||
Integer(IntegerValue<'ast>),
|
||||
Field(FieldValue<'ast>),
|
||||
Group(Group<'ast>),
|
||||
Boolean(Boolean<'ast>),
|
||||
Boolean(BooleanValue<'ast>),
|
||||
Implicit(NumberImplicitValue<'ast>),
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ use leo_ast::{
|
||||
Private,
|
||||
},
|
||||
values::{
|
||||
BooleanValue,
|
||||
FieldValue,
|
||||
IntegerValue,
|
||||
NumberValue,
|
||||
@ -147,8 +148,8 @@ impl<'ast> From<ast::Group<'ast>> for types::Expression {
|
||||
|
||||
/// pest ast -> types::Boolean
|
||||
|
||||
impl<'ast> From<ast::Boolean<'ast>> for types::Expression {
|
||||
fn from(boolean: ast::Boolean<'ast>) -> Self {
|
||||
impl<'ast> From<BooleanValue<'ast>> for types::Expression {
|
||||
fn from(boolean: BooleanValue<'ast>) -> Self {
|
||||
types::Expression::Boolean(Boolean::Constant(
|
||||
boolean
|
||||
.value
|
||||
|
Loading…
Reference in New Issue
Block a user