-
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.
add log framework and new grammar definitions
- Loading branch information
Showing
8 changed files
with
147 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
[package] | ||
name = "rasynth" | ||
version = "0.1.0" | ||
authors = ["wheatfox <[email protected]>"] | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[build-dependencies] # <-- We added this and everything after! | ||
[build-dependencies] | ||
lalrpop = "0.20.2" | ||
|
||
[dependencies] | ||
env_logger = "0.11.5" | ||
graph = "0.3.1" | ||
lalrpop-util = { version = "0.20.2", features = ["lexer", "unicode"] } | ||
log = "0.4.22" |
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,26 @@ | ||
use crate::ast; | ||
use log::*; | ||
use std::sync::Mutex; | ||
|
||
pub static FLOW_GRAPH: Mutex<Option<FlowGraph>> = Mutex::new(None); | ||
|
||
#[derive(Debug)] | ||
pub struct FlowGraph { | ||
pub timestamp: u64, | ||
pub ast: Mutex<Option<ast::TopDef>>, | ||
} | ||
|
||
impl FlowGraph { | ||
pub fn new(ast: Option<ast::TopDef>) -> Self { | ||
FlowGraph { | ||
timestamp: std::time::SystemTime::now() | ||
.duration_since(std::time::UNIX_EPOCH) | ||
.unwrap() | ||
.as_secs(), | ||
ast: Mutex::new(ast), | ||
} | ||
} | ||
pub fn generate(&self) { | ||
info!("Generating Graph..."); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,42 @@ | ||
use env_logger::Env; | ||
use lalrpop_util::lalrpop_mod; | ||
use log::*; | ||
use std::fs; | ||
|
||
pub mod ast; | ||
pub mod graph; | ||
|
||
lalrpop_mod!(pub raslisp); // synthesized by LALRPOP | ||
|
||
fn main() { | ||
let test1 = fs::read_to_string("../test/test.raslisp").unwrap(); | ||
let r = raslisp::BoxDefineParser::new().parse(&test1).unwrap(); | ||
println!("{:?}", r); | ||
let env = Env::default() | ||
.filter_or("MY_LOG_LEVEL", "trace") | ||
.write_style_or("MY_LOG_STYLE", "always"); | ||
env_logger::init_from_env(env); | ||
|
||
info!("RASLISP Interpreter, version {}", env!("CARGO_PKG_VERSION")); | ||
info!("Author: {}", env!("CARGO_PKG_AUTHORS")); | ||
|
||
let input_file = "../test/osc1.raslisp"; | ||
info!("Input Top File Path: {}", input_file); | ||
let test1 = fs::read_to_string(input_file).expect("Unable to read file"); | ||
|
||
let r = raslisp::TopParser::new().parse(&test1).unwrap(); | ||
info!("AST Parsed Successfully!"); | ||
|
||
graph::FLOW_GRAPH | ||
.lock() | ||
.unwrap() | ||
.replace(graph::FlowGraph::new(Some(r))); | ||
|
||
graph::FLOW_GRAPH | ||
.lock() | ||
.unwrap() | ||
.as_ref() | ||
.unwrap() | ||
.generate(); | ||
|
||
info!("Graph: {:?}", graph::FLOW_GRAPH.lock().unwrap()); | ||
|
||
info!("Goodbye!"); | ||
} |
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 |
---|---|---|
@@ -1,19 +1,20 @@ | ||
[box osc1 ( | ||
(box osc1 ( | ||
in freq: float | ||
in amp: float | ||
in wav_sel: i32 | ||
out raw_wav: float | ||
) | ||
(let sin1 (sinwave 128)) // sin1: waveform | ||
(let sample (idx sin1 65)) // get sin1[65]'s sample value | ||
(let raw_wav amp * sample) | ||
] | ||
(let sin1 (sinwave 128)) ; sin1: waveform | ||
(let sample (idx sin1 65)) ; get sin1[65]'s sample value | ||
(let raw_wav (* amp sample)) | ||
) | ||
|
||
[box main ( | ||
(box main ( | ||
out stereo_L: float | ||
out stereo_R: float | ||
) | ||
[osc1 osc1_out_raw] | ||
(let stereo_L = osc1_out_raw) | ||
(let stereo_R = osc1_out_raw) | ||
] | ||
(let amp (* 50 2)) | ||
[osc1 440 amp 0 osc1_out_raw] | ||
(let stereo_L osc1_out_raw) | ||
(let stereo_R osc1_out_raw) | ||
) |
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