tangled
alpha
login
or
join now
tholps.site
/
skidmark
0
fork
atom
Tholp's bespoke website generator
0
fork
atom
overview
issues
pulls
pipelines
Inverse ephermerality
Tholp1
1 year ago
5bb7ef44
2d1a770b
+37
-28
1 changed file
expand all
collapse all
unified
split
src
main.rs
+37
-28
src/main.rs
···
50
50
.starts_with(['!', '&'])
51
51
{
52
52
let mut matched: bool = false;
53
53
+
let mut prefix_len = 1;
54
54
+
let mut symbol = file.tokens[file.working_index].contents.clone();
55
55
+
symbol = symbol.trim().to_string();
53
56
54
54
-
for m in &MACRO_LIST {
55
55
-
let symbol = file.tokens[file.working_index].contents.trim();
56
56
-
if symbol.len() < 2
57
57
+
if symbol.len() > 2 {
58
58
+
let mut ephemeral = false;
59
59
+
let same_file = file.tokens[file.working_index].origin_file != file.filename_input;
60
60
+
61
61
+
//if file.tokens[file.working_index].contents.starts_with("!&")
62
62
+
if symbol.starts_with("!&")
63
63
+
{
64
64
+
prefix_len = 2;
65
65
+
ephemeral = !same_file;
66
66
+
}
67
67
+
//else if file.tokens[file.working_index].contents.starts_with("&")
68
68
+
else if symbol.starts_with("&")
57
69
{
58
58
-
continue;
70
70
+
ephemeral = same_file;
59
71
}
60
60
-
if &symbol[1..] == m.symbol {
61
61
-
matched = true;
62
62
-
println!("Found a macro ({})", m.symbol);
63
63
-
let mut ephemeral = false;
64
64
-
if file.tokens[file.working_index].contents.starts_with('&')
65
65
-
&& file.tokens[file.working_index].origin_file != file.filename_input
66
66
-
{
67
67
-
println!("Skipping Ephermal macro from included file.");
68
68
-
ephemeral = true;
69
69
-
}
72
72
+
73
73
+
// Check if its a macro
74
74
+
for m in &MACRO_LIST {
75
75
+
if &symbol[prefix_len..] == m.symbol {
76
76
+
matched = true;
77
77
+
println!("Found a macro ({})", m.symbol);
70
78
71
71
-
let (args, tokcount) = collect_arguments(&file.tokens[file.working_index..]);
72
72
-
let expansion: Vec<Token>;
73
73
-
if ephemeral {
74
74
-
expansion = Vec::new();
75
75
-
} else {
76
76
-
expansion = (m.expand)(file, &args);
79
79
+
let (args, tokcount) =
80
80
+
collect_arguments(&file.tokens[file.working_index..]);
81
81
+
let expansion: Vec<Token>;
82
82
+
if ephemeral {
83
83
+
expansion = Vec::new();
84
84
+
} else {
85
85
+
expansion = (m.expand)(file, &args);
86
86
+
}
87
87
+
file.tokens.remove(file.working_index);
88
88
+
file.tokens.splice(
89
89
+
file.working_index..(file.working_index + tokcount - 1),
90
90
+
expansion,
91
91
+
);
77
92
}
78
78
-
file.tokens.remove(file.working_index);
79
79
-
file.tokens.splice(
80
80
-
file.working_index..(file.working_index + tokcount - 1),
81
81
-
expansion,
82
82
-
);
83
93
}
94
94
+
// Check if its a block
95
95
+
// for b in &BLOCK_LIST {}}
84
96
}
85
85
-
86
86
-
// for b in &BLOCK_LIST {}
87
87
-
88
97
if !matched {
89
98
println!(
90
99
"Token written as a function but no such function exists \"{}\"",