Skip to content

Commit

Permalink
Add last_stmt_with_semicolon (#159)
Browse files Browse the repository at this point in the history
* Add last_stmt_with_semicolon

* Update full-moon/src/ast/mod.rs

Co-authored-by: boyned//Kampfkarren <[email protected]>

Co-authored-by: boyned//Kampfkarren <[email protected]>
  • Loading branch information
JohnnyMorganz and Kampfkarren authored Mar 26, 2021
1 parent b6ffb86 commit 814b7f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added a `lua52` feature flag for Lua 5.2 specific syntax
- Added support for `goto` and labels when using the `lua52` feature flag
- Added initialiser methods for all Luau-related structs available under the roblox feature flag.
- Added `block.last_stmt_with_semicolon()` which returns a tuple containing the last stmt in the block, and an optional token reference.

### Changed
- Updated dependency cfg_if to v1.0
Expand Down
5 changes: 5 additions & 0 deletions full-moon/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ impl<'a> Block<'a> {
Some(&self.last_stmt.as_ref()?.0)
}

/// The last statement of the block if on exists, including any optional semicolon token reference present
pub fn last_stmt_with_semicolon(&self) -> Option<&(LastStmt<'a>, Option<TokenReference<'a>>)> {
self.last_stmt.as_ref()
}

/// Returns a new block with the given statements
/// Takes a vector of statements, followed by an optional semicolon token reference
pub fn with_stmts(self, stmts: Vec<(Stmt<'a>, Option<TokenReference<'a>>)>) -> Self {
Expand Down

0 comments on commit 814b7f9

Please sign in to comment.