forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…Labs#2438) * misc minor improvements to CFA * split out sway_ast from sway_parse * cargo clippy
- Loading branch information
Showing
102 changed files
with
3,008 additions
and
2,395 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "sway-ast" | ||
version = "0.19.1" | ||
authors = ["Fuel Labs <[email protected]>"] | ||
edition = "2021" | ||
homepage = "https://fuel.network/" | ||
license = "Apache-2.0" | ||
repository = "https://github.com/FuelLabs/sway" | ||
description = "Sway's parser" | ||
|
||
[dependencies] | ||
extension-trait = "1.0.1" | ||
num-bigint = "0.4.3" | ||
num-traits = "0.2.14" | ||
sway-types = { version = "0.19.1", path = "../sway-types" } |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use crate::priv_prelude::*; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Annotated<T> { | ||
pub attribute_list: Vec<AttributeDecl>, | ||
pub value: T, | ||
} | ||
|
||
// Attributes can have any number of arguments: | ||
// | ||
// #[attribute] | ||
// #[attribute()] | ||
// #[attribute(value)] | ||
// #[attribute(value0, value1, value2)] | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AttributeDecl { | ||
pub hash_token: HashToken, | ||
pub attribute: SquareBrackets<Attribute>, | ||
} | ||
|
||
impl Spanned for AttributeDecl { | ||
fn span(&self) -> Span { | ||
Span::join(self.hash_token.span(), self.attribute.span()) | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Attribute { | ||
pub name: Ident, | ||
pub args: Option<Parens<Punctuated<Ident, CommaToken>>>, | ||
} | ||
|
||
impl Spanned for Attribute { | ||
fn span(&self) -> Span { | ||
self.args | ||
.as_ref() | ||
.map(|args| Span::join(self.name.span(), args.span())) | ||
.unwrap_or_else(|| self.name.span()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::priv_prelude::*; | ||
|
||
macro_rules! define_brackets ( | ||
($ty_name:ident) => { | ||
#[derive(Clone, Debug)] | ||
pub struct $ty_name<T> { | ||
pub inner: T, | ||
pub span: Span, | ||
} | ||
|
||
impl<T> $ty_name<T> { | ||
pub fn new<'a>(inner: T, span: Span) -> $ty_name<T> { | ||
$ty_name { | ||
inner, | ||
span, | ||
} | ||
} | ||
|
||
pub fn get(&self) -> &T { | ||
&self.inner | ||
} | ||
|
||
pub fn into_inner(self) -> T { | ||
self.inner | ||
} | ||
} | ||
|
||
impl<T> Spanned for $ty_name<T> { | ||
fn span(&self) -> Span { | ||
self.span.clone() | ||
} | ||
} | ||
}; | ||
); | ||
|
||
define_brackets!(Braces); | ||
define_brackets!(Parens); | ||
define_brackets!(SquareBrackets); | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AngleBrackets<T> { | ||
pub open_angle_bracket_token: OpenAngleBracketToken, | ||
pub inner: T, | ||
pub close_angle_bracket_token: CloseAngleBracketToken, | ||
} | ||
|
||
impl<T> AngleBrackets<T> { | ||
pub fn into_inner(self) -> T { | ||
self.inner | ||
} | ||
} | ||
|
||
impl<T> Spanned for AngleBrackets<T> { | ||
fn span(&self) -> Span { | ||
Span::join( | ||
self.open_angle_bracket_token.span(), | ||
self.close_angle_bracket_token.span(), | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::priv_prelude::*; | ||
|
||
pub struct Dependency { | ||
pub dep_token: DepToken, | ||
pub path: DependencyPath, | ||
pub semicolon_token: SemicolonToken, | ||
} | ||
|
||
impl Spanned for Dependency { | ||
fn span(&self) -> Span { | ||
Span::join(self.dep_token.span(), self.semicolon_token.span()) | ||
} | ||
} | ||
|
||
pub struct DependencyPath { | ||
pub prefix: Ident, | ||
pub suffixes: Vec<(ForwardSlashToken, Ident)>, | ||
} | ||
|
||
impl Spanned for DependencyPath { | ||
fn span(&self) -> Span { | ||
match self.suffixes.last() { | ||
Some((_forward_slash_token, suffix)) => Span::join(self.prefix.span(), suffix.span()), | ||
None => self.prefix.span(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use crate::priv_prelude::*; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AsmBlock { | ||
pub asm_token: AsmToken, | ||
pub registers: Parens<Punctuated<AsmRegisterDeclaration, CommaToken>>, | ||
pub contents: Braces<AsmBlockContents>, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AsmRegisterDeclaration { | ||
pub register: Ident, | ||
pub value_opt: Option<(ColonToken, Box<Expr>)>, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AsmBlockContents { | ||
pub instructions: Vec<(Instruction, SemicolonToken)>, | ||
pub final_expr_opt: Option<AsmFinalExpr>, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AsmFinalExpr { | ||
pub register: Ident, | ||
pub ty_opt: Option<(ColonToken, Ty)>, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct AsmImmediate { | ||
pub span: Span, | ||
pub parsed: BigUint, | ||
} | ||
|
||
impl Spanned for AsmImmediate { | ||
fn span(&self) -> Span { | ||
self.span.clone() | ||
} | ||
} | ||
|
||
impl Spanned for AsmBlock { | ||
fn span(&self) -> Span { | ||
Span::join(self.asm_token.span(), self.contents.span()) | ||
} | ||
} |
Oops, something went wrong.