pub mod assign;
pub mod compound;
pub mod declare;
pub mod expression;
pub mod function_call;
pub mod if_statement;
pub mod return_statement;
pub mod while_statement;
use enum_dispatch::enum_dispatch;
use nom::{branch::alt, combinator::map, IResult};
pub use assign::Assign;
pub use declare::Declare;
pub use function_call::FunctionCall;
pub use if_statement::If;
pub use return_statement::Return;
pub use while_statement::While;
#[enum_dispatch]
trait IsStatement {}
#[enum_dispatch(IsStatement)]
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
pub enum Statement {
Declare,
Assign,
Return,
If,
While,
FunctionCall,
}
pub fn parse(code: &str) -> IResult<&str, Statement> {
alt((
map(declare::parse, Statement::Declare),
map(assign::parse, Statement::Assign),
map(return_statement::parse, Statement::Return),
map(if_statement::parse, Statement::If),
map(while_statement::parse, Statement::While),
map(function_call::parse, Statement::FunctionCall),
))(code)
}