Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mauro-balades committed Sep 18, 2023
2 parents 26e14c8 + 0f9f1da commit bd8d984
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/langs/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use crate::runner::Runner;
use crate::Args;
use std::collections::HashMap;

#[derive(Debug, Clone, PartialEq)]
pub struct Language {
pub name: String,
pub functions: HashMap<String, fn(HashMap<String, String>, Args, &mut Runner) -> ()>,
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pub mod nodes;
pub mod runner;
pub mod project;
pub mod functions;
pub mod langs;

lalrpop_mod!(pub parser); // synthesized by LALRPOP

Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

use std::path::Path;
use breeze::{nodes::AST, project::ProjectInfo, runner::Runner, parser, Args};
use breeze::{nodes::AST, runner::Runner, parser, Args};
use clap::Parser;
use label_logger::{info, log, success};
use label_logger::{success};

use std::fs;

Expand Down
3 changes: 2 additions & 1 deletion src/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub enum Node {
DefaultTask(String),
VariableDecl(String, Expr),
FunctionCall(String, Vec<(String, Expr)>),
Message(Expr)
Message(Expr),
LangCall(String, String, Vec<(String, Expr)>),
}

#[derive(Debug, Clone)]
Expand Down
5 changes: 5 additions & 0 deletions src/parser.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RootHeader: ProjectInfo = {

Statement: Node = {
FunctionCall,
LangCall,
Message,
}

Expand All @@ -40,6 +41,10 @@ Expr: Expr = {
StringExpr
}

LangCall: Node = {
"@" <lang:ident> "." <i:ident> "(" <args:CallArguments> ")" ";" => Node::LangCall(lang, i, args)
}

FunctionCall: Node = {
<i:ident> "(" <args:CallArguments> ")" ";" => Node::FunctionCall(i, args)
}
Expand Down
26 changes: 24 additions & 2 deletions src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{collections::{HashMap}, process::exit};
use crate::{nodes::{{ AST, Node }, Expr}, Args};
use crate::functions::get_std_functions;
use crate::langs::{ Language };

use lazy_static;

Expand All @@ -20,7 +21,10 @@ pub struct Runner {
tasks: HashMap<String, Node>,

args: Args,
functions: HashMap<String, fn(HashMap<String, String>, Args, &mut Runner) -> ()>
functions: HashMap<String, fn(HashMap<String, String>, Args, &mut Runner) -> ()>,

languages: Vec<Language>,

}

impl Runner {
Expand All @@ -37,6 +41,7 @@ impl Runner {
tasks: HashMap::<String, Node>::new(),
args,
functions: get_std_functions(),
languages: vec![],
}
}

Expand Down Expand Up @@ -167,13 +172,30 @@ impl Runner {
}
},

Node::LangCall(ref lang, ref ident, ref args) => {
let name = format!("@{}.{}", lang, ident);

let mut found_lang = Option::None;
for lang_dir in &self.languages {
if lang_dir.name == lang.to_string() {
found_lang = Some(lang_dir);
}
}

if found_lang == Option::None {
Self::throw_error(format!("Language directory '{}' not found!", lang));
}

todo!()
}

Node::Message(ref e) => {
let expr = self.execute_expr(e).unwrap();
let lines = expr.lines();

if expr.contains("\n") {
for l in lines {
info!(label: "==>", "{}", l);
info!(label: "=>", "{}", l);
}
} else {
info!(label: "==>", "{}", expr);
Expand Down
2 changes: 1 addition & 1 deletion test/project.breeze
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project test version "0.0.1";

task build {
exec(cmd="git --help");
@python.install_requirements();
}

default_task build;

0 comments on commit bd8d984

Please sign in to comment.