started work

This commit is contained in:
Schrottkatze 2021-12-16 11:45:16 +01:00
parent f174ec9927
commit 9fa7ed1dcf
6 changed files with 85 additions and 52 deletions

View file

@ -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\!

View file

@ -3,30 +3,30 @@
&& inherit via ::: && inherit via :::
++cat:::animal ( ++cat:::animal (
¡+}}float{{ meowingVolume!; ¡+}}float{{ meowingVolume!;
### /}}string{{ name\ /}}float{{ speed\ /}}float{{ meowingVolume\ | ( ### /}}string{{ name\ /}}float{{ speed\ /}}float{{ meowingVolume\ | (
&& ## calls the super && ## calls the super
¡##/name, speed\!; ¡##/name, speed\!;
¡+meowingVolume < meowingVolume!; ¡+meowingVolume < meowingVolume!;
) )
+#meow /\ | ( +#meow /\ | (
¿??€/+meowingVolume >> 0\ | ( ¿??€/+meowingVolume >> 0\ | (
¡<=/"*silence*"!; ¡<=/"*silence*"!;
) ?>$/+meowingVolume >> 0\ | ( ) ?>$/+meowingVolume >> 0\ | (
¡<=/"mow"\!; ¡<=/"mow"\!;
) ?>$/+meowingVolume >> 2\ | ( ) ?>$/+meowingVolume >> 2\ | (
¡<=/"meow"\!; ¡<=/"meow"\!;
) ?>$/+meowingVolume >> 5\ | ( ) ?>$/+meowingVolume >> 5\ | (
¡<=/"Meow."\!; ¡<=/"Meow."\!;
) ?>$/+meowingVolume >> 10\ | ( ) ?>$/+meowingVolume >> 10\ | (
¡<=/"Meow!!"\!; ¡<=/"Meow!!"\!;
) ?>$/+meowingVolume >> 20\ | ( ) ?>$/+meowingVolume >> 20\ | (
¡<=/"MEOW!!!"\!; ¡<=/"MEOW!!!"\!;
) >? | ( ) >? | (
!<=/"Error: weird as fuck meowing volume."\!; !<=/"Error: weird as fuck meowing volume."\!;
)
) )
)
) )

View file

@ -1,3 +1,6 @@
&& ¡! around code means its a statement
&& ¿? around code means its an expression
#mult /}}string{{str\ /{float}num\ | ( #mult /}}string{{str\ /{float}num\ | (
¿string * float? ¿string * float?
) )
@ -7,16 +10,9 @@
]]Inline comment[[ ]]Inline comment[[
`` ``
multiline comment multiline comment
indention example (comments have to be indented as well, btw): indention is 3 spaces
first level main function has to be a thing
second level
third level
fourth level
fifth level
sixth level
main function has to be a thing
´´ ´´
¡}}string{{ variable! ¡}}string{{ variable!
@ -36,24 +32,24 @@
&& if condition is true log the text && if condition is true log the text
¿??$/condition\ | ( ¿??$/condition\ | (
¡<=/"condition was true"! ¡<=/"condition was true"!
)? )?
&& if condition is false log the text && if condition is false log the text
¿??€/condition\ | ( ¿??€/condition\ | (
¡<=/"condition was false"! ¡<=/"condition was false"!
)? )?
#sub /\ | ( #sub /\ | (
&& This code prints hello world && This code prints hello world
¿??$? | ( ¿??$? | (
!<= "Hello World"!; !<= "Hello World"!;
) )
) )
#sub /\ | ( #sub /\ | (
&& This code checks if input is equal to another string && This code checks if input is equal to another string
¿??$ /=> "hello"\? | ( && Takes input and compares to string ¿??$ /=> "hello"\? | ( && Takes input and compares to string
!<= "World!"!; Prints World! !<= "World!"!; Prints World!
)? )?
) )

View file

@ -1,18 +1,16 @@
use std::env; use std::env;
use std::fs; use std::fs;
mod preprocessor;
fn main() { fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
let file = fs::read_to_string(&args[1]).expect("Couldnt read file:"); 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 { fn parse_and_interpret(code: 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
} }

5
src/preprocessor.rs Normal file
View file

@ -0,0 +1,5 @@
pub fn preprocess(raw_code: String) -> String {
let lines = raw_code.split(' ');
for &line in lines {
}
}

9
src/string_math.rs Normal file
View file

@ -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
}