mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-24 07:48:04 +03:00
Merge pull request #550 from AleoHQ/ternary-rename
Rename conditional expr to ternary
This commit is contained in:
commit
0318bb770a
@ -34,7 +34,7 @@ use leo_grammar::{
|
|||||||
CircuitInlineExpression,
|
CircuitInlineExpression,
|
||||||
Expression as GrammarExpression,
|
Expression as GrammarExpression,
|
||||||
PostfixExpression,
|
PostfixExpression,
|
||||||
TernaryExpression,
|
TernaryExpression as GrammarTernaryExpression,
|
||||||
UnaryExpression as GrammarUnaryExpression,
|
UnaryExpression as GrammarUnaryExpression,
|
||||||
},
|
},
|
||||||
operations::{BinaryOperation as GrammarBinaryOperation, UnaryOperation as GrammarUnaryOperation},
|
operations::{BinaryOperation as GrammarBinaryOperation, UnaryOperation as GrammarUnaryOperation},
|
||||||
@ -59,8 +59,8 @@ mod binary;
|
|||||||
pub use binary::*;
|
pub use binary::*;
|
||||||
mod unary;
|
mod unary;
|
||||||
pub use unary::*;
|
pub use unary::*;
|
||||||
mod conditional;
|
mod ternary;
|
||||||
pub use conditional::*;
|
pub use ternary::*;
|
||||||
mod array_access;
|
mod array_access;
|
||||||
pub use array_access::*;
|
pub use array_access::*;
|
||||||
mod array_range_access;
|
mod array_range_access;
|
||||||
@ -91,7 +91,7 @@ pub enum Expression {
|
|||||||
Value(ValueExpression),
|
Value(ValueExpression),
|
||||||
Binary(BinaryExpression),
|
Binary(BinaryExpression),
|
||||||
Unary(UnaryExpression),
|
Unary(UnaryExpression),
|
||||||
Conditional(ConditionalExpression),
|
Ternary(TernaryExpression),
|
||||||
|
|
||||||
ArrayInline(ArrayInlineExpression),
|
ArrayInline(ArrayInlineExpression),
|
||||||
ArrayInit(ArrayInitExpression),
|
ArrayInit(ArrayInitExpression),
|
||||||
@ -116,7 +116,7 @@ impl Node for Expression {
|
|||||||
Value(n) => n.span(),
|
Value(n) => n.span(),
|
||||||
Binary(n) => n.span(),
|
Binary(n) => n.span(),
|
||||||
Unary(n) => n.span(),
|
Unary(n) => n.span(),
|
||||||
Conditional(n) => n.span(),
|
Ternary(n) => n.span(),
|
||||||
ArrayInline(n) => n.span(),
|
ArrayInline(n) => n.span(),
|
||||||
ArrayInit(n) => n.span(),
|
ArrayInit(n) => n.span(),
|
||||||
ArrayAccess(n) => n.span(),
|
ArrayAccess(n) => n.span(),
|
||||||
@ -137,7 +137,7 @@ impl Node for Expression {
|
|||||||
Value(n) => n.set_span(span),
|
Value(n) => n.set_span(span),
|
||||||
Binary(n) => n.set_span(span),
|
Binary(n) => n.set_span(span),
|
||||||
Unary(n) => n.set_span(span),
|
Unary(n) => n.set_span(span),
|
||||||
Conditional(n) => n.set_span(span),
|
Ternary(n) => n.set_span(span),
|
||||||
ArrayInline(n) => n.set_span(span),
|
ArrayInline(n) => n.set_span(span),
|
||||||
ArrayInit(n) => n.set_span(span),
|
ArrayInit(n) => n.set_span(span),
|
||||||
ArrayAccess(n) => n.set_span(span),
|
ArrayAccess(n) => n.set_span(span),
|
||||||
@ -160,7 +160,7 @@ impl<'ast> fmt::Display for Expression {
|
|||||||
Value(n) => n.fmt(f),
|
Value(n) => n.fmt(f),
|
||||||
Binary(n) => n.fmt(f),
|
Binary(n) => n.fmt(f),
|
||||||
Unary(n) => n.fmt(f),
|
Unary(n) => n.fmt(f),
|
||||||
Conditional(n) => n.fmt(f),
|
Ternary(n) => n.fmt(f),
|
||||||
ArrayInline(n) => n.fmt(f),
|
ArrayInline(n) => n.fmt(f),
|
||||||
ArrayInit(n) => n.fmt(f),
|
ArrayInit(n) => n.fmt(f),
|
||||||
ArrayAccess(n) => n.fmt(f),
|
ArrayAccess(n) => n.fmt(f),
|
||||||
@ -341,9 +341,9 @@ impl<'ast> From<GrammarBinaryExpression<'ast>> for Expression {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'ast> From<TernaryExpression<'ast>> for Expression {
|
impl<'ast> From<GrammarTernaryExpression<'ast>> for Expression {
|
||||||
fn from(expression: TernaryExpression<'ast>) -> Self {
|
fn from(expression: GrammarTernaryExpression<'ast>) -> Self {
|
||||||
Expression::Conditional(ConditionalExpression {
|
Expression::Ternary(TernaryExpression {
|
||||||
condition: Box::new(Expression::from(expression.first)),
|
condition: Box::new(Expression::from(expression.first)),
|
||||||
if_true: Box::new(Expression::from(expression.second)),
|
if_true: Box::new(Expression::from(expression.second)),
|
||||||
if_false: Box::new(Expression::from(expression.third)),
|
if_false: Box::new(Expression::from(expression.third)),
|
||||||
|
@ -17,20 +17,20 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub struct ConditionalExpression {
|
pub struct TernaryExpression {
|
||||||
pub condition: Box<Expression>,
|
pub condition: Box<Expression>,
|
||||||
pub if_true: Box<Expression>,
|
pub if_true: Box<Expression>,
|
||||||
pub if_false: Box<Expression>,
|
pub if_false: Box<Expression>,
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ConditionalExpression {
|
impl fmt::Display for TernaryExpression {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "if {} ? {} : {}", self.condition, self.if_true, self.if_false)
|
write!(f, "if {} ? {} : {}", self.condition, self.if_true, self.if_false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Node for ConditionalExpression {
|
impl Node for TernaryExpression {
|
||||||
fn span(&self) -> &Span {
|
fn span(&self) -> &Span {
|
||||||
&self.span
|
&self.span
|
||||||
}
|
}
|
@ -121,7 +121,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
|||||||
)?),
|
)?),
|
||||||
},
|
},
|
||||||
|
|
||||||
Expression::Conditional(ConditionalExpression {
|
Expression::Ternary(TernaryExpression {
|
||||||
condition,
|
condition,
|
||||||
if_true,
|
if_true,
|
||||||
if_false,
|
if_false,
|
||||||
|
@ -484,7 +484,7 @@ impl Frame {
|
|||||||
UnaryOperation::Not => self.parse_boolean_expression(&unary.inner, &unary.span),
|
UnaryOperation::Not => self.parse_boolean_expression(&unary.inner, &unary.span),
|
||||||
},
|
},
|
||||||
|
|
||||||
Conditional(conditional) => self.parse_conditional_expression(
|
Ternary(conditional) => self.parse_conditional_expression(
|
||||||
&conditional.condition,
|
&conditional.condition,
|
||||||
&conditional.if_true,
|
&conditional.if_true,
|
||||||
&conditional.if_false,
|
&conditional.if_false,
|
||||||
|
Loading…
Reference in New Issue
Block a user