mkjs-cli
Version:
Make-inspired build tool
78 lines (62 loc) • 1.32 kB
JavaScript
const assembler = require('./assembler');
module.exports = {
push(a_list, z_item) {
if(undefined === z_item && !a_list.length) return a_list;
a_list.push(z_item);
return a_list;
},
append(a_appendage, a_primary) {
return a_primary.concat(a_appendage);
},
merge(h_a, h_b) {
for(let s_key in h_a) {
h_b[s_key] = h_a[s_key];
}
return h_b;
},
option(h_pass, z_if, s_key) {
if(z_if) h_pass[s_key] = true;
return h_pass;
},
Inline: (a_codes, b_suppress) => ({
type: 'inline',
code: a_codes.join(''),
suppress: b_suppress,
}),
MacroCall: (s_macro, a_args) => ({
type: 'call',
macro: s_macro,
args: a_args,
}),
Macro: (s_def, a_body) => ({
type: 'macro',
macro: s_def,
body: a_body,
}),
Assignment: (s_name, h_expression) => ({
type: 'assignment',
name: s_name,
expression: h_expression,
}),
If: (s_condition, a_then_body, a_elseifs, a_else_body) => ({
type: 'if',
if: s_condition,
then: a_then_body,
elseifs: a_elseifs,
else: a_else_body,
}),
Elseif: (s_condition, a_then_body) => ({
type: 'elseif',
if: s_condition,
then: a_then_body,
}),
Include: (h_file) => ({
type: 'include',
file: h_file,
}),
Verbatim: (s_verbatim) => ({
type: 'verbatim',
value: s_verbatim,
}),
Program: (a_sections) => assembler(a_sections),
};