diff options
| author | Laurenz <laurmaedje@gmail.com> | 2020-10-04 22:36:20 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2020-10-04 22:36:20 +0200 |
| commit | 605ab104c5e041c345007020d277b4c6267debe6 (patch) | |
| tree | c18f3333a0c0e0527ad1039a498cb210300f7fd9 /src/syntax | |
| parent | ef8aa763faa59fd62c90c6d6245e8d2c5eece35e (diff) | |
Better argument parsing 🥙
Diffstat (limited to 'src/syntax')
| -rw-r--r-- | src/syntax/ast/expr.rs | 2 | ||||
| -rw-r--r-- | src/syntax/span.rs | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/syntax/ast/expr.rs b/src/syntax/ast/expr.rs index 4f440d33..433dcca2 100644 --- a/src/syntax/ast/expr.rs +++ b/src/syntax/ast/expr.rs @@ -21,7 +21,7 @@ pub struct ExprCall { /// The name of the function. pub name: Spanned<Ident>, /// The arguments to the function. - pub args: LitDict, + pub args: Spanned<LitDict>, } /// A unary operation: `-x`. diff --git a/src/syntax/span.rs b/src/syntax/span.rs index e9e1021c..6ba9c44a 100644 --- a/src/syntax/span.rs +++ b/src/syntax/span.rs @@ -40,7 +40,7 @@ impl<T> Offset for SpanVec<T> { } /// A value with the span it corresponds to in the source code. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] +#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] pub struct Spanned<T> { /// The spanned value. @@ -178,6 +178,12 @@ impl PartialEq for Span { } } +impl Default for Span { + fn default() -> Self { + Span::ZERO + } +} + impl<T> From<T> for Span where T: Into<Pos> + Copy, @@ -229,6 +235,12 @@ impl From<u32> for Pos { } } +impl From<i32> for Pos { + fn from(index: i32) -> Self { + Self(index as u32) + } +} + impl From<usize> for Pos { fn from(index: usize) -> Self { Self(index as u32) |
