mirror of
https://github.com/nushell/nushell.git
synced 2025-04-08 11:58:32 +02:00
This is partially "feng-shui programming" of moving things to new separate places. The later commits include "`git blame` tollbooths" by moving out chunks of code into new files, which requires an extra step to track things with `git blame`. We can negiotiate if you want to keep particular things in their original place. If egregious I tried to add a bit of documentation. If I see something that is unused/unnecessarily `pub` I will try to remove that. - Move `nu_protocol::Exportable` to `nu-parser` - Guess doccomment for `Exportable` - Move `Unit` enum from `value` to `AST` - Move engine state `Variable` def into its folder - Move error-related files in `nu-protocol` subdir - Move `pipeline_data` module into its own folder - Move `stream.rs` over into the `pipeline_data` mod - Move `PipelineMetadata` into its own file - Doccomment `PipelineMetadata` - Remove unused `is_leap_year` in `value/mod` - Note about criminal `type_compatible` helper - Move duration fmting into new `value/duration.rs` - Move filesize fmting logic to new `value/filesize` - Split reexports from standard imports in `value/mod` - Doccomment trait `CustomValue` - Polish doccomments and intradoc links
62 lines
1.9 KiB
Rust
62 lines
1.9 KiB
Rust
use chrono::FixedOffset;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use super::{
|
|
Call, CellPath, Expression, ExternalArgument, FullCellPath, MatchPattern, Operator,
|
|
RangeOperator,
|
|
};
|
|
use crate::{ast::ImportPattern, ast::Unit, BlockId, Signature, Span, Spanned, VarId};
|
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
pub enum Expr {
|
|
Bool(bool),
|
|
Int(i64),
|
|
Float(f64),
|
|
Binary(Vec<u8>),
|
|
Range(
|
|
Option<Box<Expression>>, // from
|
|
Option<Box<Expression>>, // next value after "from"
|
|
Option<Box<Expression>>, // to
|
|
RangeOperator,
|
|
),
|
|
Var(VarId),
|
|
VarDecl(VarId),
|
|
Call(Box<Call>),
|
|
ExternalCall(Box<Expression>, Vec<ExternalArgument>, bool), // head, args, is_subexpression
|
|
Operator(Operator),
|
|
RowCondition(BlockId),
|
|
UnaryNot(Box<Expression>),
|
|
BinaryOp(Box<Expression>, Box<Expression>, Box<Expression>), //lhs, op, rhs
|
|
Subexpression(BlockId),
|
|
Block(BlockId),
|
|
Closure(BlockId),
|
|
MatchBlock(Vec<(MatchPattern, Expression)>),
|
|
List(Vec<Expression>),
|
|
Table(Vec<Expression>, Vec<Vec<Expression>>),
|
|
Record(Vec<RecordItem>),
|
|
Keyword(Vec<u8>, Span, Box<Expression>),
|
|
ValueWithUnit(Box<Expression>, Spanned<Unit>),
|
|
DateTime(chrono::DateTime<FixedOffset>),
|
|
Filepath(String, bool),
|
|
Directory(String, bool),
|
|
GlobPattern(String, bool),
|
|
String(String),
|
|
CellPath(CellPath),
|
|
FullCellPath(Box<FullCellPath>),
|
|
ImportPattern(ImportPattern),
|
|
Overlay(Option<BlockId>), // block ID of the overlay's origin module
|
|
Signature(Box<Signature>),
|
|
StringInterpolation(Vec<Expression>),
|
|
Spread(Box<Expression>),
|
|
Nothing,
|
|
Garbage,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
pub enum RecordItem {
|
|
/// A key: val mapping
|
|
Pair(Expression, Expression),
|
|
/// Span for the "..." and the expression that's being spread
|
|
Spread(Span, Expression),
|
|
}
|