-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add base for statement, block and add parsing for block in function d…
…eclaration
- Loading branch information
Showing
4 changed files
with
55 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Module responsible for parsing blocks. | ||
use crate::prelude::*; | ||
use crate::stmt::Statement; | ||
|
||
#[derive(Debug)] | ||
pub struct Block { | ||
pub stmts: Vec<Statement>, | ||
pub span: Range<usize>, | ||
} | ||
|
||
impl Parse for Block { | ||
type Output = Self; | ||
|
||
fn parse(parser: &mut Parser) -> ParsingResult<Self::Output> { | ||
let mut parsed_tokens = Vec::new(); | ||
|
||
expect_token!(parser => [T::OpenBrace, ()], OpenBrace, parsed_tokens); | ||
let start = span_toks!(start parsed_tokens); | ||
|
||
// TODO(Larsouille25): Statments parsing here | ||
|
||
expect_token!(parser => [T::CloseBrace, ()], CloseBrace, parsed_tokens); | ||
let end = span_toks!(end parsed_tokens); | ||
|
||
Good( | ||
Block { | ||
stmts: Vec::new(), | ||
span: start..end, | ||
}, | ||
parsed_tokens, | ||
) | ||
} | ||
} |
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,7 @@ | ||
//! Module responsible for parsing statement. | ||
use crate::prelude::*; | ||
|
||
#[derive(Debug)] | ||
pub struct Statement { | ||
pub span: Range<usize>, | ||
} |