Transofrmation
This commit is contained in:
parent
9e4141fc96
commit
ddba3423df
|
@ -1,5 +1,5 @@
|
|||
#with language.toml
|
||||
variable:=-3; c := (a+b- 3) * 23 + variable; d := c - a;Natural : Number (n) := {n >= 0};faculty : Natural (n) -> Natural := if n = 0 then 1 else faculty (n-1) * n end;
|
||||
String Natural (n) := {Character * n};hello_word -> String := "Hello World!";
|
||||
first_letter -> Character := 'a';
|
||||
wrong -> Logic := false;date -> String := "#date_now";
|
||||
user -> String := "#user"
|
||||
|
|
|
@ -10,6 +10,7 @@ comments = ["^--.*", ""]
|
|||
[meta.interpolation]
|
||||
with = ["^#with ([\\w./]+)", "cat $1"]
|
||||
date = ["#date_now", "date"]
|
||||
user = ["#user", "user"]
|
||||
|
||||
# Describes tokens to be replaced by identifiers and then later swapped back in after the tokenizer.
|
||||
# All special tokens are treated as constants
|
||||
|
|
|
@ -125,9 +125,20 @@ impl MetaRules {
|
|||
println!("[INFO] Applying rule {}", rule.0);
|
||||
let base_pattern: Regex = Regex::new((rule.1 .0).as_str()).unwrap();
|
||||
let processed_code_replacement = processed_code.clone();
|
||||
let parameter = &base_pattern
|
||||
let parameter = if &base_pattern
|
||||
.captures(processed_code_replacement.as_str())
|
||||
.unwrap()[0];
|
||||
.unwrap()
|
||||
.len()
|
||||
> 0
|
||||
{
|
||||
&base_pattern
|
||||
.captures(processed_code_replacement.as_str())
|
||||
.unwrap()[0]
|
||||
} else {
|
||||
&base_pattern
|
||||
.captures(processed_code_replacement.as_str())
|
||||
.unwrap()
|
||||
};
|
||||
let command: &str = &base_pattern.replace(parameter, rule.1 .1.as_str());
|
||||
println!("{:?}", &command);
|
||||
let subprocess = std::process::Command::new("/bin/bash")
|
||||
|
|
Loading…
Reference in New Issue