diff --git a/sm-test-files/actual-testing/io.sm b/sm-test-files/actual-testing/io.sm new file mode 100644 index 0000000..e13b8e7 --- /dev/null +++ b/sm-test-files/actual-testing/io.sm @@ -0,0 +1,25 @@ + +&& line comment test + +¡<= /"Hello world!"\! + +¡<= ]] inline comment example [[ /"inline cmmnts work"\! + +`` + big ass block comment! + ye boiiiii +´´ + +&& declare variable out as string +¡}}string{{ out! + +&& take input and take it into var +¡=> /out\! + +&& log out +¡<= /out\! + + + + + diff --git a/sm-test-files/animals-example/cat.sm b/sm-test-files/animals-example/cat.sm index b08bec4..ac9ab12 100644 --- a/sm-test-files/animals-example/cat.sm +++ b/sm-test-files/animals-example/cat.sm @@ -3,30 +3,30 @@ && inherit via ::: ++cat:::animal ( - ¡+}}float{{ meowingVolume!; - - ### /}}string{{ name\ /}}float{{ speed\ /}}float{{ meowingVolume\ | ( - && ## calls the super - ¡##/name, speed\!; - ¡+meowingVolume < meowingVolume!; - ) - - +#meow /\ | ( - ¿??€/+meowingVolume >> 0\ | ( - ¡<=/"*silence*"!; - ) ?>$/+meowingVolume >> 0\ | ( - ¡<=/"mow"\!; - ) ?>$/+meowingVolume >> 2\ | ( - ¡<=/"meow"\!; - ) ?>$/+meowingVolume >> 5\ | ( - ¡<=/"Meow."\!; - ) ?>$/+meowingVolume >> 10\ | ( - ¡<=/"Meow!!"\!; - ) ?>$/+meowingVolume >> 20\ | ( - ¡<=/"MEOW!!!"\!; - ) >? | ( - !<=/"Error: weird as fuck meowing volume."\!; + ¡+}}float{{ meowingVolume!; + + ### /}}string{{ name\ /}}float{{ speed\ /}}float{{ meowingVolume\ | ( + && ## calls the super + ¡##/name, speed\!; + ¡+meowingVolume < meowingVolume!; + ) + + +#meow /\ | ( + ¿??€/+meowingVolume >> 0\ | ( + ¡<=/"*silence*"!; + ) ?>$/+meowingVolume >> 0\ | ( + ¡<=/"mow"\!; + ) ?>$/+meowingVolume >> 2\ | ( + ¡<=/"meow"\!; + ) ?>$/+meowingVolume >> 5\ | ( + ¡<=/"Meow."\!; + ) ?>$/+meowingVolume >> 10\ | ( + ¡<=/"Meow!!"\!; + ) ?>$/+meowingVolume >> 20\ | ( + ¡<=/"MEOW!!!"\!; + ) >? | ( + !<=/"Error: weird as fuck meowing volume."\!; + ) ) - ) ) diff --git a/sm-test-files/hello.sm b/sm-test-files/hello.sm index 65f41b3..6ffb5d1 100644 --- a/sm-test-files/hello.sm +++ b/sm-test-files/hello.sm @@ -1,3 +1,6 @@ +&& ¡! around code means its a statement +&& ¿? around code means its an expression + #mult /}}string{{str\ /{float}num\ | ( ¿string * float? ) @@ -7,16 +10,9 @@ ]]Inline comment[[ `` - multiline comment - indention example (comments have to be indented as well, btw): - first level - second level - third level - fourth level - fifth level - sixth level - - main function has to be a thing + multiline comment + indention is 3 spaces + main function has to be a thing ´´ ¡}}string{{ variable! @@ -36,24 +32,24 @@ && if condition is true log the text ¿??$/condition\ | ( - ¡<=/"condition was true"! + ¡<=/"condition was true"! )? && if condition is false log the text ¿??€/condition\ | ( - ¡<=/"condition was false"! + ¡<=/"condition was false"! )? #sub /\ | ( - && This code prints hello world - ¿??$? | ( - !<= "Hello World"!; - ) + && This code prints hello world + ¿??$? | ( + !<= "Hello World"!; + ) ) #sub /\ | ( - && This code checks if input is equal to another string - ¿??$ /=> "hello"\? | ( && Takes input and compares to string - !<= "World!"!; Prints World! - )? + && This code checks if input is equal to another string + ¿??$ /=> "hello"\? | ( && Takes input and compares to string + !<= "World!"!; Prints World! + )? ) diff --git a/src/main.rs b/src/main.rs index 613ce20..ccce34f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,16 @@ use std::env; use std::fs; +mod preprocessor; + fn main() { let args: Vec = env::args().collect(); let file = fs::read_to_string(&args[1]).expect("Couldnt read file:"); - println!("{:?}", multiply_strings(file, 3.5)); + + println!("{:?}", preprocessor::preprocess(file)); } -fn multiply_strings(str: String, multiplier: f32) -> String { - let mut r: String = String::from(str); - let rest = multiplier - (multiplier as i32) as f32; - let slice = &r.clone()[0..(r.len() as f32 * rest) as usize]; +fn parse_and_interpret(code: String) { - r = r.repeat(multiplier as usize); - r += slice; - r } + diff --git a/src/preprocessor.rs b/src/preprocessor.rs new file mode 100644 index 0000000..ee0f7dc --- /dev/null +++ b/src/preprocessor.rs @@ -0,0 +1,5 @@ +pub fn preprocess(raw_code: String) -> String { + let lines = raw_code.split(' '); + for &line in lines { + } +} diff --git a/src/string_math.rs b/src/string_math.rs new file mode 100644 index 0000000..269bab6 --- /dev/null +++ b/src/string_math.rs @@ -0,0 +1,9 @@ +fn multiply_strings(str: String, multiplier: f32) -> String { + let mut r: String = String::from(str); + let rest = multiplier - (multiplier as i32) as f32; + let slice = &r.clone()[0..(r.len() as f32 * rest) as usize]; + + r = r.repeat(multiplier as usize); + r += slice; + r +}