Tholp's bespoke website generator

for_each_file_in_group, output_filename

+5 -5
src/closures.rs
···
use boa_engine::Context;
use crate::{
-
project::ProjectContext,
+
project::Project,
types::{SkidContext, Token},
};
-
type ClosureFunction = fn(&[Token], &mut ProjectContext, &mut SkidContext) -> Vec<Token>;
+
type ClosureFunction = fn(&[Token], &mut Project, &mut SkidContext) -> Vec<Token>;
pub struct Closure {
pub opener: &'static str,
···
fn closure_comment(
_tokens: &[Token],
-
_project_context: &mut ProjectContext,
+
_project_context: &mut Project,
_skid_context: &mut SkidContext,
) -> Vec<Token> {
Vec::new()
···
fn closure_section(
tokens: &[Token],
-
_project_context: &mut ProjectContext,
+
_project_context: &mut Project,
_skid_context: &mut SkidContext,
) -> Vec<Token> {
tokens.to_vec()
···
fn closure_js(
tokens: &[Token],
-
project_context: &mut ProjectContext,
+
project_context: &mut Project,
skid_context: &mut SkidContext,
) -> Vec<Token> {
Vec::new()
+7 -7
src/console.rs
···
use colored::Colorize;
-
use crate::project::{Indexing, ProjectContext};
+
use crate::project::{Indexing, Project};
pub fn error_generic(msg: &String) {
println!("{} {}", "[ERROR]".red(), msg);
exit(1);
}
-
pub fn error_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) {
+
pub fn error_skid(proj_context: &Project, origin_index: usize, origin_line: usize, msg: &String) {
println!(
"{} {}:{}; {}",
"[ERROR]".red(),
-
context
+
proj_context
.file_for_index(origin_index)
.expect("Panic in the error func.... (file_for_index() was None!)")
.into_os_string()
···
println!("{} {}", "[WARN]".yellow(), msg);
}
-
pub fn warn_skid(context: &ProjectContext, origin_index: usize, origin_line: usize, msg: &String) {
+
pub fn warn_skid(proj_context: &Project, origin_index: usize, origin_line: usize, msg: &String) {
println!(
"{} {}:{}; {}",
"[WARN]".yellow(),
-
context
+
proj_context
.file_for_index(origin_index)
.expect("Panic in the warn func.... (file_for_index() was None!)")
.into_os_string()
···
}
pub fn reminder_skid(
-
context: &ProjectContext,
+
proj_context: &Project,
origin_index: usize,
origin_line: usize,
msg: &String,
···
println!(
"{} {}:{}; {}",
"[REMINDER]".cyan(),
-
context
+
proj_context
.file_for_index(origin_index)
.expect("Panic in the warn func.... (file_for_index() was None!)")
.into_os_string()
+131
src/macros/for_each.rs
···
+
use crate::{console::*, project::Project, stringtools::*, types::*};
+
+
fn for_each_base(
+
identifier: &String,
+
replacements: &[String],
+
proj_context: &mut Project,
+
origin_index: usize,
+
origin_line: usize,
+
scope: &[Token],
+
) -> Vec<Token> {
+
let mut output = Vec::new();
+
let block: Vec<Token> = scope.into();
+
+
let mut replacement_count: usize = 0;
+
+
let mut replacement_pattern = find_pattern(scope, format!("[[{}..1]]", identifier));
+
+
if replacement_pattern.is_none() {
+
warn_skid(
+
proj_context,
+
origin_index,
+
origin_line,
+
&format!(
+
"Macro `for_each_arg` given block with no \"[[{}..1]]\", intentional?",
+
identifier
+
),
+
);
+
}
+
+
while replacement_pattern.is_some() {
+
replacement_count += 1;
+
replacement_pattern = find_pattern(
+
scope,
+
format!("[[{}..{}]]", identifier, replacement_count + 1),
+
);
+
}
+
+
if replacement_count == 0 {
+
for _i in 0..replacements.iter().count() {
+
output.append(&mut block.clone());
+
}
+
return output;
+
}
+
+
if replacements.len() % replacement_count != 0 {
+
error_skid(proj_context, origin_index, origin_line,
+
&format!("`for_each_var` was not given a number of arguments({}) that was a multiple of its replacement posistions({}) (got {:?})",
+
replacements.len(),
+
replacement_count,
+
replacements));
+
}
+
+
let mut replacement_index: usize = 0;
+
let mut arg_output: Vec<Token> = block.clone();
+
for r in replacements {
+
let mut found_pattern = find_pattern(
+
&arg_output,
+
format!("[[{}..{}]]", identifier, replacement_index + 1),
+
);
+
+
while found_pattern.is_some() {
+
let (start, len) = found_pattern.unwrap();
+
let replacement = split_to_tokens(r.clone(), origin_index);
+
arg_output.splice(start..start + len, replacement);
+
found_pattern = find_pattern(
+
&arg_output,
+
format!("[[{}..{}]]", identifier, replacement_index + 1),
+
);
+
//println!("{}", replacement_index + 1);
+
}
+
+
//println!("{} {}", replacement_index, replacement_count);
+
replacement_index += 1;
+
if replacement_index == replacement_count {
+
replacement_index = 0;
+
output.append(&mut arg_output.trim_whitespace().into());
+
arg_output = block.clone();
+
//println!("push");
+
}
+
//println!("test");
+
}
+
return output;
+
}
+
+
pub fn macro_for_each_arg(
+
origin_index: usize,
+
origin_line: usize,
+
proj_context: &mut Project,
+
_skid_context: &mut SkidContext,
+
args: &Vec<String>,
+
scope: &[Token],
+
) -> Vec<Token> {
+
return for_each_base(
+
&args[0],
+
&args[1..],
+
proj_context,
+
origin_index,
+
origin_line,
+
scope,
+
);
+
}
+
+
pub fn macro_for_each_file_in_group(
+
origin_index: usize,
+
origin_line: usize,
+
proj_context: &mut Project,
+
_skid_context: &mut SkidContext,
+
args: &Vec<String>,
+
scope: &[Token],
+
) -> Vec<Token> {
+
let mut files: Vec<String> = Vec::new();
+
for g in &proj_context.filegroups {
+
if g.name == args[1] {
+
for f in &g.files {
+
let path = f
+
.file_input
+
.strip_prefix(&proj_context.input_folder)
+
.unwrap();
+
files.push(path.to_str().unwrap().into());
+
}
+
}
+
}
+
return for_each_base(
+
&args[0],
+
&files,
+
proj_context,
+
origin_index,
+
origin_line,
+
scope,
+
);
+
}
+2 -2
src/macros/insert.rs
···
use crate::{
console::error_skid,
macros::template::SkidTemplate,
-
project::{Indexing, ProjectContext},
+
project::{Indexing, Project},
stringtools::split_to_tokens,
types::{SkidContext, Token},
};
···
pub fn macro_insert(
origin_index: usize,
origin_line: usize,
-
context: &mut ProjectContext,
+
context: &mut Project,
_skid_context: &mut SkidContext,
args: &Vec<String>,
_scope: &[Token],
+28 -14
src/macros/mod.rs
···
+
pub mod for_each;
pub mod insert;
pub mod simple_blocks;
pub mod simple_macros;
pub mod template;
-
use crate::macros::simple_macros::macro_reminder;
use super::types::Macro;
-
+
use for_each::*;
use insert::macro_insert;
-
use simple_blocks::{macro_comment, macro_for_each_arg, macro_repeat, macro_section};
-
use simple_macros::{macro_filename, macro_filename_canonical, macro_time};
+
use simple_blocks::*;
+
use simple_macros::*;
use template::macro_template;
pub static MACRO_LIST: &'static [Macro] = &[
···
Macro {
symbol: "insert", // Inserts another file
expansion: macro_insert,
-
has_scope: false,
+
takes_block: false,
min_args: 1,
max_args: 1,
},
Macro {
symbol: "time",
expansion: macro_time,
-
has_scope: false,
+
takes_block: false,
min_args: 1,
max_args: 1,
},
Macro {
symbol: "filename",
expansion: macro_filename,
-
has_scope: false,
+
takes_block: false,
min_args: 0,
max_args: 0,
},
Macro {
symbol: "filename_canonical",
expansion: macro_filename_canonical,
-
has_scope: false,
+
takes_block: false,
min_args: 0,
max_args: 0,
},
Macro {
symbol: "reminder",
expansion: macro_reminder,
-
has_scope: false,
+
takes_block: false,
min_args: 1,
max_args: 1,
},
+
Macro {
+
symbol: "output_filename",
+
expansion: macro_output_filename,
+
takes_block: false,
+
min_args: 0,
+
max_args: 1,
+
},
// Scoped
Macro {
symbol: "comment", // Nothing
expansion: macro_comment,
-
has_scope: true,
+
takes_block: true,
min_args: 0,
max_args: 0,
},
Macro {
symbol: "repeat", // Outputs what its give x number of times
expansion: macro_repeat,
-
has_scope: true,
+
takes_block: true,
min_args: 1,
max_args: 1,
},
Macro {
symbol: "section",
expansion: macro_section,
-
has_scope: true,
+
takes_block: true,
min_args: 0,
max_args: 1,
},
Macro {
symbol: "template",
expansion: macro_template,
-
has_scope: true,
+
takes_block: true,
min_args: 1,
max_args: usize::max_value(),
},
Macro {
symbol: "for_each_arg",
expansion: macro_for_each_arg,
-
has_scope: true,
+
takes_block: true,
min_args: 1,
max_args: usize::max_value(),
+
},
+
Macro {
+
symbol: "for_each_file_in_group",
+
expansion: macro_for_each_file_in_group,
+
takes_block: true,
+
min_args: 2,
+
max_args: 2,
},
];
+6 -90
src/macros/simple_blocks.rs
···
// This file for implementations of short blocks, im qualifying that as less than 30ish lines
-
use crate::{
-
console::{error_skid, warn_skid},
-
project::ProjectContext,
-
stringtools::{find_pattern, split_to_tokens, TokenTools},
+
console::*,
+
project::Project,
+
stringtools::TokenTools,
types::{SkidContext, Token},
};
pub fn macro_comment(
_origin_index: usize,
_origin_line: usize,
-
_context: &mut ProjectContext,
+
_context: &mut Project,
_skid_context: &mut SkidContext,
_args: &Vec<String>,
_scope: &[Token],
···
pub fn macro_section(
_origin_index: usize,
_origin_line: usize,
-
_context: &mut ProjectContext,
+
_context: &mut Project,
_skid_context: &mut SkidContext,
_args: &Vec<String>,
scope: &[Token],
···
pub fn macro_repeat(
_origin_index: usize,
_origin_line: usize,
-
_context: &mut ProjectContext,
+
_context: &mut Project,
_skid_context: &mut SkidContext,
args: &Vec<String>,
scope: &[Token],
···
}
return tokens;
}
-
-
pub fn macro_for_each_arg(
-
origin_index: usize,
-
origin_line: usize,
-
context: &mut ProjectContext,
-
_skid_context: &mut SkidContext,
-
args: &Vec<String>,
-
scope: &[Token],
-
) -> Vec<Token> {
-
let mut output = Vec::new();
-
let block: Vec<Token> = scope.into();
-
let varname = &args[0];
-
let real_args = &args[1..];
-
-
let mut replacement_count: usize = 0;
-
-
let mut replacement_pattern = find_pattern(scope, format!("[[{}..1]]", varname));
-
-
if replacement_pattern.is_none() {
-
warn_skid(
-
context,
-
origin_index,
-
origin_line,
-
&format!(
-
"Macro `for_each_arg` given block with no \"[[{}..1]]\", intentional?",
-
varname
-
),
-
);
-
}
-
-
while replacement_pattern.is_some() {
-
replacement_count += 1;
-
replacement_pattern =
-
find_pattern(scope, format!("[[{}..{}]]", varname, replacement_count + 1));
-
}
-
-
if replacement_count == 0 {
-
for _i in 0..real_args.iter().count() {
-
output.append(&mut block.clone());
-
}
-
return output;
-
}
-
-
if real_args.len() % replacement_count != 0 {
-
error_skid(context, origin_index, origin_line,
-
&format!("`for_each_var` was not given a number of arguments({}) that was a multiple of its replacement posistions({}) (got {:?})",
-
real_args.len(),
-
replacement_count,
-
real_args));
-
}
-
-
let mut replacement_index: usize = 0;
-
let mut arg_output: Vec<Token> = block.clone();
-
for arg in real_args {
-
let mut found_pattern = find_pattern(
-
&arg_output,
-
format!("[[{}..{}]]", varname, replacement_index + 1),
-
);
-
-
while found_pattern.is_some() {
-
let (start, len) = found_pattern.unwrap();
-
let replacement = split_to_tokens(arg.clone(), origin_index);
-
arg_output.splice(start..start + len, replacement);
-
found_pattern = find_pattern(
-
&arg_output,
-
format!("[[{}..{}]]", varname, replacement_index + 1),
-
);
-
//println!("{}", replacement_index + 1);
-
}
-
-
//println!("{} {}", replacement_index, replacement_count);
-
replacement_index += 1;
-
if replacement_index == replacement_count {
-
replacement_index = 0;
-
output.append(&mut arg_output.trim_whitespace().into());
-
arg_output = block.clone();
-
//println!("push");
-
}
-
//println!("test");
-
}
-
-
return output;
-
}
+52 -9
src/macros/simple_macros.rs
···
use chrono::Local;
use crate::{
-
console::{error_skid, reminder_skid},
-
macros::template::SkidTemplate,
-
project::{Indexing, ProjectContext},
+
args,
+
console::{error_skid, reminder_skid, warn_skid},
+
project::{Indexing, Project},
stringtools::split_to_tokens,
types::{SkidContext, Token},
};
···
pub fn macro_time(
origin_index: usize,
origin_line: usize,
-
context: &mut ProjectContext,
+
context: &mut Project,
_skid_context: &mut SkidContext,
args: &Vec<String>,
_scope: &[Token],
···
pub fn macro_filename(
origin_index: usize,
-
origin_line: usize,
-
context: &mut ProjectContext,
+
_origin_line: usize,
+
proj_context: &mut Project,
_skid_context: &mut SkidContext,
_args: &Vec<String>,
_scope: &[Token],
) -> Vec<Token> {
return split_to_tokens(
-
context
+
proj_context
.file_for_index(origin_index)
.unwrap()
.to_str()
···
);
}
+
pub fn macro_output_filename(
+
origin_index: usize,
+
origin_line: usize,
+
proj_context: &mut Project,
+
_skid_context: &mut SkidContext,
+
args: &Vec<String>,
+
_scope: &[Token],
+
) -> Vec<Token> {
+
let mut in_filepath = proj_context.input_folder.clone();
+
if args.len() == 0 {
+
in_filepath.push(proj_context.file_for_index(origin_index).unwrap());
+
} else {
+
in_filepath.push(&args[0]);
+
}
+
+
if in_filepath.exists() {
+
for g in &proj_context.filegroups {
+
if !g.process {
+
continue;
+
}
+
for f in &g.files {
+
if f.file_input == in_filepath {
+
let stripped = f
+
.file_out
+
.strip_prefix(&proj_context.output_folder)
+
.unwrap();
+
return split_to_tokens(stripped.to_str().unwrap().into(), origin_index);
+
}
+
}
+
}
+
}
+
warn_skid(
+
proj_context,
+
origin_index,
+
origin_line,
+
&format!(
+
"output_filename given a file with no matching output file ({:?}), returning empty",
+
in_filepath
+
),
+
);
+
Vec::new()
+
}
+
pub fn macro_filename_canonical(
origin_index: usize,
_origin_line: usize,
-
context: &mut ProjectContext,
+
context: &mut Project,
_skid_context: &mut SkidContext,
_args: &Vec<String>,
_scope: &[Token],
···
pub fn macro_reminder(
origin_index: usize,
origin_line: usize,
-
context: &mut ProjectContext,
+
context: &mut Project,
_skid_context: &mut SkidContext,
args: &Vec<String>,
_scope: &[Token],
+3 -3
src/macros/template.rs
···
use crate::{
console::error_skid,
-
project::ProjectContext,
+
project::Project,
reservednames::{RESERVED_NAMES_HTML, RESERVED_NAMES_MISC},
stringtools::{find_pattern, split_to_tokens, WhitespaceChecks},
types::{IsScoped, SkidContext, Token},
···
//_file: &mut InputFile,
origin_index: usize,
origin_line: usize,
-
proj_context: &mut ProjectContext,
+
proj_context: &mut Project,
args: &Vec<String>,
scope: &[Token],
) -> Vec<Token> {
···
pub fn macro_template(
origin_index: usize,
origin_line: usize,
-
project_context: &mut ProjectContext,
+
project_context: &mut Project,
skid_context: &mut SkidContext,
args: &Vec<String>,
scope: &[Token],
+23 -23
src/main.rs
···
use console::*;
use macros::MACRO_LIST;
use markdown::{CompileOptions, Constructs, Options, ParseOptions};
-
use project::{parse_project, Indexing, ProjectContext};
+
use project::{parse_project, Indexing, Project};
use reservednames::RESERVED_NAMES_HTML;
use std::{
env,
···
// strings split on kind of abitrary chars..
static DELIMITERS: &'static [char] = &[
' ', '\n', '\t', '(', ')', '{', '}', '[', ']', '<', '>', '\\', '\'', '\"', ';', '?', '^', '-',
+
'`',
];
#[derive(PartialEq)]
···
// }
// }
-
for group in &mut project.filegroups {
-
if !group.process {
+
for i in 0..project.filegroups.len() {
+
if !project.filegroups[i].process {
continue;
}
-
for infile in &mut group.files {
-
let contents =
-
fs::read_to_string(&infile.file_input).expect("File unreadable or missing");
-
let tokens =
-
split_to_tokens(contents, project.context.index_of_file(&infile.file_input));
+
let convert_html = project.filegroups[i].convert_html;
+
for k in 0..project.filegroups[i].files.len() {
+
let file_input = project.filegroups[i].files[k].file_input.clone();
+
let contents = fs::read_to_string(&project.filegroups[i].files[k].file_input)
+
.expect("File unreadable or missing");
+
let tokens = split_to_tokens(contents, project.index_of_file(&file_input));
-
let mut skid_context =
-
SkidContext::new(project.context.index_of_file(&infile.file_input));
+
let mut skid_context = SkidContext::new(project.index_of_file(&file_input));
write_file(
-
infile,
-
group.convert_html,
-
&process_skid(&tokens, &mut project.context, &mut skid_context),
+
&project.filegroups[i].files[k].file_skidout.clone(),
+
&project.filegroups[i].files[k].file_out.clone(),
+
convert_html,
+
&process_skid(&tokens, &mut project, &mut skid_context),
);
}
}
···
fn find_and_run_macro(
tokens_in: &[Token],
-
proj_context: &mut ProjectContext,
+
proj_context: &mut Project,
skid_context: &mut SkidContext,
) -> Option<(Vec<Token>, usize)> {
// (Output, to be consumed size)
···
fn process_skid(
tokens_in: &[Token],
-
proj_context: &mut ProjectContext,
+
proj_context: &mut Project,
skid_context: &mut SkidContext,
) -> Vec<Token> {
//}, context: &mut ProjectContext) {
···
return tokens;
}
-
fn write_file(file: &InputFile, convert_html: bool, tokens: &[Token]) {
+
fn write_file(file_skidout: &PathBuf, file_out: &PathBuf, convert_html: bool, tokens: &[Token]) {
//println!("{:?}", tokens);
let mut skid_output: String = "".to_string();
for t in tokens {
skid_output.push(t.contents);
}
-
let mut folder = file.file_skidout.clone();
+
let mut folder = file_skidout.clone();
folder.pop();
if fs::create_dir_all(&folder).is_err() {
error_generic(&format!("Could not make the folder {:?}", &folder));
}
if convert_html {
-
fs::write(&file.file_skidout, &skid_output).expect("Couldn't write skid to file");
+
fs::write(&file_skidout, &skid_output).expect("Couldn't write skid to file");
//let html_output = markdown::to_html(&skid_output);
let html_output = markdown::to_html_with_options(
···
},
)
.unwrap();
-
fs::write(&file.file_out, &html_output).expect("Couldn't write output to file");
+
fs::write(&file_out, &html_output).expect("Couldn't write output to file");
} else {
-
fs::write(&file.file_out, &skid_output).expect("Couldn't write output to file");
+
fs::write(&file_out, &skid_output).expect("Couldn't write output to file");
}
ok_generic(&format!(
"{} written",
-
file.file_out
-
.to_str()
-
.unwrap_or("Couldnt Unwrap file_out name")
+
file_out.to_str().unwrap_or("Couldnt Unwrap file_out name")
));
}
+29 -23
src/project.rs
···
pub struct Project {
pub filegroups: Vec<FileGroup>,
//pub settings: ProjectSettings,
-
pub context: ProjectContext,
+
//pub context: ProjectContext,
+
pub input_folder: PathBuf,
+
pub output_folder: PathBuf,
+
pub global_pre_insert: PathBuf,
+
pub global_post_insert: PathBuf,
+
+
pub filemap: Vec<PathBuf>, // mapped to index
}
pub struct FileGroup {
···
pub convert_html: bool,
}
-
pub struct ProjectContext {
-
pub input_folder: PathBuf,
-
pub output_folder: PathBuf,
-
pub global_pre_insert: PathBuf,
-
pub global_post_insert: PathBuf,
+
// pub struct ProjectContext {
+
// pub input_folder: PathBuf,
+
// pub output_folder: PathBuf,
+
// pub global_pre_insert: PathBuf,
+
// pub global_post_insert: PathBuf,
-
pub filemap: Vec<PathBuf>, // mapped to index
-
}
+
// pub filemap: Vec<PathBuf>, // mapped to index
+
// }
macro_rules! get_table_bool_or_default {
($table:ident, $key:expr, $default:expr) => {
···
let mut project: Project = Project {
filegroups: Vec::new(),
-
context: ProjectContext {
-
input_folder: PathBuf::new(),
-
output_folder: PathBuf::new(),
-
global_pre_insert: PathBuf::new(),
-
global_post_insert: PathBuf::new(),
-
filemap: Vec::new(),
-
},
+
//context: ProjectContext {
+
input_folder: PathBuf::new(),
+
output_folder: PathBuf::new(),
+
global_pre_insert: PathBuf::new(),
+
global_post_insert: PathBuf::new(),
+
filemap: Vec::new(),
+
//},
};
let config = tomlfile
.parse::<Table>()
···
.parent()
.expect("Project file unreadable or missing.");
-
project.context.input_folder = PathBuf::from(get_table_string_or_default!(
+
project.input_folder = PathBuf::from(get_table_string_or_default!(
settings_section,
"inputFolder",
"skid"
));
-
project.context.output_folder = PathBuf::from(get_table_string_or_default!(
+
project.output_folder = PathBuf::from(get_table_string_or_default!(
settings_section,
"outputFolder",
"content"
));
-
project.context.global_pre_insert = project_root.join(get_table_string_or_default!(
+
project.global_pre_insert = project_root.join(get_table_string_or_default!(
settings_section,
"preInsertGlobal",
""
));
-
project.context.global_post_insert = project_root.join(get_table_string_or_default!(
+
project.global_post_insert = project_root.join(get_table_string_or_default!(
settings_section,
"postInsertGlobal",
""
···
let pre_insert = get_table_string_or_default!(filegroup_def, "preInsert", "");
let post_insert = get_table_string_or_default!(filegroup_def, "postInsert", "");
-
let process = get_table_bool_or_default!(filegroup_def, "process", false);
+
let process = get_table_bool_or_default!(filegroup_def, "process", true);
let convert_html = get_table_bool_or_default!(filegroup_def, "convertHTML", true);
let extention = get_table_string_or_default!(filegroup_def, "outputExtention", "html");
···
});
let mut new_file = crate::types::InputFile::new();
-
new_file.file_input = project.context.input_folder.clone();
+
new_file.file_input = project.input_folder.clone();
new_file.file_input.push(filename);
-
new_file.file_out = project.context.output_folder.clone();
+
new_file.file_out = project.output_folder.clone();
new_file.file_out.push(filename);
new_file.file_out.set_extension(extention);
···
// fn section_name_for_index(&self, index: usize) -> String;
}
-
impl Indexing for ProjectContext {
+
impl Indexing for Project {
fn index_of_file(&mut self, f: &PathBuf) -> usize {
let cannonical = f.canonicalize().unwrap();
let mut index = 0;
+7 -7
src/types.rs
···
use crate::{
console::error_skid,
macros::{simple_blocks::macro_comment, template::SkidTemplate},
-
project::ProjectContext,
+
project::Project,
};
pub struct Token {
···
}
type MacroExpansion =
-
fn(usize, usize, &mut ProjectContext, &mut SkidContext, &Vec<String>, &[Token]) -> Vec<Token>;
+
fn(usize, usize, &mut Project, &mut SkidContext, &Vec<String>, &[Token]) -> Vec<Token>;
// (
// origin_index: usize,
// origin_line: usize,
···
pub struct Macro {
pub symbol: &'static str,
pub expansion: MacroExpansion,
-
pub has_scope: bool, //takes blocks of text input as well as parameters using [[{}]]
+
pub takes_block: bool, //takes blocks of text input as well as parameters using [[{}]]
pub min_args: usize,
pub max_args: usize,
}
···
&self,
origin_index: usize,
origin_line: usize,
-
context: &mut ProjectContext,
+
context: &mut Project,
skid_context: &mut SkidContext,
args: &Vec<String>,
scope: &[Token],
···
Macro {
symbol: "default_symbol",
expansion: macro_comment,
-
has_scope: true,
+
takes_block: true,
min_args: 0,
max_args: usize::max_value(),
}
···
&self,
origin_index: usize,
origin_line: usize,
-
proj_context: &mut ProjectContext,
+
proj_context: &mut Project,
skid_context: &mut SkidContext,
args: &Vec<String>,
block: &[Token],
···
impl IsScoped for Macro {
fn is_scoped(&self) -> bool {
-
self.has_scope
+
self.takes_block
}
}