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.
Return the lexing stage produced by
sway_parse
from `forc-pkg::chec…
…k()` (FuelLabs#3675) Previous to this PR, `forc_pkg::check()` would only return the `ParseProgram` and `TyProgram` AST's. In the language server, we now also need access to the initial lexing stage produced by `sway_parse` in order to get access to the sway keyword tokens. This PR now returns the lexing stage of a program along with the parsed and typed stages. closes FuelLabs#3524
- Loading branch information
1 parent
76f5653
commit b21009e
Showing
9 changed files
with
147 additions
and
44 deletions.
There are no files selected for viewing
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
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
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,25 @@ | ||
mod program; | ||
|
||
use crate::language::DepName; | ||
pub use program::LexedProgram; | ||
use sway_ast::Module; | ||
use sway_types::Ident; | ||
|
||
/// A module and its submodules in the form of a tree. | ||
#[derive(Debug, Clone)] | ||
pub struct LexedModule { | ||
/// The content of this module in the form of a [Module]. | ||
pub module: Module, | ||
/// Submodules introduced within this module using the `dep` syntax in order of declaration. | ||
pub submodules: Vec<(DepName, LexedSubmodule)>, | ||
} | ||
|
||
/// A library module that was declared as a `dep` of another module. | ||
/// | ||
/// Only submodules are guaranteed to be a `library` and have a `library_name`. | ||
#[derive(Debug, Clone)] | ||
pub struct LexedSubmodule { | ||
/// The name of a submodule, parsed from the `library` declaration within the module itself. | ||
pub library_name: Ident, | ||
pub module: LexedModule, | ||
} |
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,17 @@ | ||
use super::LexedModule; | ||
use crate::language::parsed::TreeType; | ||
|
||
/// A lexed, but not yet parsed or type-checked, Sway program. | ||
/// | ||
/// Includes all modules in the form of a [LexedModule] tree accessed via the `root`. | ||
#[derive(Debug, Clone)] | ||
pub struct LexedProgram { | ||
pub kind: TreeType, | ||
pub root: LexedModule, | ||
} | ||
|
||
impl LexedProgram { | ||
pub fn new(kind: TreeType, root: LexedModule) -> LexedProgram { | ||
LexedProgram { kind, root } | ||
} | ||
} |
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
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