const struct macro_token *input;
size_t n_input;
int nesting_countdown;
- const struct macro_set *macros;
const struct macro_expander *me;
const struct macro_expansion_stack *stack;
struct string_map *vars;
static void
macro_expand (const struct macro_tokens *, int nesting_countdown,
- const struct macro_set *,
const struct macro_expander *, struct string_map *vars,
const struct macro_expansion_stack *stack,
bool *expand, bool *break_,
.input = &ctx->input[i],
.n_input = ctx->n_input - i,
.nesting_countdown = ctx->nesting_countdown,
- .macros = ctx->macros,
.me = ctx->me,
.stack = ctx->stack,
.vars = ctx->vars,
macro_tokens_from_string__ (&mts, ss_cstr (args.strings[0]),
ctx->me->segmenter_mode, ctx->stack);
struct macro_tokens exp = { .n = 0 };
- macro_expand (&mts, ctx->nesting_countdown - 1,
- ctx->macros, ctx->me, ctx->vars,
+ macro_expand (&mts, ctx->nesting_countdown - 1, ctx->me, ctx->vars,
&(struct macro_expansion_stack) {
.name = "!EVAL",
.next = ctx->stack,
struct expr_context
{
int nesting_countdown;
- const struct macro_set *macros;
const struct macro_expander *me;
const struct macro_expansion_stack *stack;
struct string_map *vars;
.input = p,
.n_input = end - p,
.nesting_countdown = ctx->nesting_countdown,
- .macros = ctx->macros,
.me = ctx->me,
.stack = ctx->stack,
.vars = ctx->vars,
static char *
macro_evaluate_expression (const struct macro_token **tokens, size_t n_tokens,
int nesting_countdown,
- const struct macro_set *macros,
const struct macro_expander *me,
const struct macro_expansion_stack *stack,
struct string_map *vars, bool *expand)
{
const struct expr_context ctx = {
.nesting_countdown = nesting_countdown,
- .macros = macros,
.me = me,
.stack = stack,
.vars = vars,
static bool
macro_evaluate_number (const struct macro_token **tokens, size_t n_tokens,
int nesting_countdown,
- const struct macro_set *macros,
const struct macro_expander *me,
const struct macro_expansion_stack *stack,
struct string_map *vars,
bool *expand, double *number)
{
char *s = macro_evaluate_expression (tokens, n_tokens, nesting_countdown,
- macros, me, stack, vars, expand);
+ me, stack, vars, expand);
if (!s)
return false;
static size_t
macro_expand_if (const struct macro_token *tokens, size_t n_tokens,
- int nesting_countdown, const struct macro_set *macros,
- const struct macro_expander *me,
+ int nesting_countdown, const struct macro_expander *me,
const struct macro_expansion_stack *stack,
struct string_map *vars,
bool *expand, bool *break_, struct macro_tokens *exp)
return 0;
p++;
- char *result = macro_evaluate_expression (&p, end - p,
- nesting_countdown,
- macros, me,
- stack, vars, expand);
+ char *result = macro_evaluate_expression (&p, end - p, nesting_countdown,
+ me, stack, vars, expand);
if (!result)
return 0;
bool b = strcmp (result, "0");
.mts = CONST_CAST (struct macro_token *, start),
.n = n,
};
- macro_expand (&mts, nesting_countdown, macros, me, vars,
+ macro_expand (&mts, nesting_countdown, me, vars,
&(struct macro_expansion_stack) {
.name = "!IF",
.next = stack,
static size_t
macro_parse_let (const struct macro_token *tokens, size_t n_tokens,
- int nesting_countdown, const struct macro_set *macros,
- const struct macro_expander *me,
+ int nesting_countdown, const struct macro_expander *me,
const struct macro_expansion_stack *stack,
struct string_map *vars, bool *expand)
{
p++;
char *value = macro_evaluate_expression (&p, end - p, nesting_countdown,
- macros, me, stack, vars, expand);
+ me, stack, vars, expand);
if (!value)
return 0;
static size_t
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
- int nesting_countdown, const struct macro_set *macros,
- const struct macro_expander *me,
+ int nesting_countdown, const struct macro_expander *me,
const struct macro_expansion_stack *stack,
struct string_map *vars,
bool *expand, struct macro_tokens *exp)
{
p++;
char *list = macro_evaluate_expression (&p, end - p, nesting_countdown,
- macros, me, &next_stack, vars,
+ me, &next_stack, vars,
expand);
if (!list)
return 0;
ss_xstrdup (items.mts[i].representation));
bool break_ = false;
- macro_expand (&inner, nesting_countdown, macros,
+ macro_expand (&inner, nesting_countdown,
me, vars, &next_stack, expand, &break_, exp);
if (break_)
break;
p++;
double first;
if (!macro_evaluate_number (&p, end - p, nesting_countdown,
- macros, me, &next_stack,
- vars, expand, &first))
+ me, &next_stack, vars, expand, &first))
return 0;
if (p >= end || p->token.type != T_MACRO_ID
double last;
if (!macro_evaluate_number (&p, end - p, nesting_countdown,
- macros, me, &next_stack,
- vars, expand, &last))
+ me, &next_stack, vars, expand, &last))
return 0;
double by = 1.0;
{
p++;
if (!macro_evaluate_number (&p, end - p, nesting_countdown,
- macros, me, &next_stack,
- vars, expand, &by))
+ me, &next_stack, vars, expand, &by))
return 0;
if (by == 0.0)
bool break_ = false;
macro_expand (&inner, nesting_countdown,
- macros, me, vars, &next_stack, expand, &break_,
- exp);
+ me, vars, &next_stack, expand, &break_, exp);
if (break_)
break;
}
static void
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
- const struct macro_set *macros,
const struct macro_expander *me, struct string_map *vars,
const struct macro_expansion_stack *stack,
bool *expand, bool *break_, struct macro_tokens *exp)
.args = NULL,
.segmenter_mode = me->segmenter_mode,
};
- macro_expand (arg, nesting_countdown,
- macros, &subme, NULL,
+ macro_expand (arg, nesting_countdown, &subme, NULL,
&(struct macro_expansion_stack) {
.name = param->name,
.next = stack,
.args = NULL,
.segmenter_mode = me->segmenter_mode,
};
- macro_expand (arg, nesting_countdown,
- macros, &subme, NULL,
+ macro_expand (arg, nesting_countdown, &subme, NULL,
&(struct macro_expansion_stack) {
.name = "!*",
.next = stack,
}
size_t n = macro_expand_if (&mts->mts[i], mts->n - i,
- nesting_countdown,
- macros, me, stack,
+ nesting_countdown, me, stack,
vars, expand, break_, exp);
if (n > 0)
{
if (*expand)
{
struct macro_call *submc;
- int retval = macro_call_create (macros, token, &submc);
+ int retval = macro_call_create (me->macros, token, &submc);
for (size_t j = 1; !retval; j++)
{
const struct macro_token endcmd
.segmenter_mode = me->segmenter_mode,
};
macro_expand (&submc->macro->body, nesting_countdown - 1,
- macros, &subme, NULL,
- &(struct macro_expansion_stack) {
+ &subme, NULL, &(struct macro_expansion_stack) {
.name = submc->macro->name,
.file_name = submc->macro->file_name,
.first_line = submc->macro->first_line,
.input = &mts->mts[i],
.n_input = mts->n - i,
.nesting_countdown = nesting_countdown,
- .macros = macros,
.me = me,
.stack = stack,
.vars = vars,
size_t n = macro_parse_let (&mts->mts[i], mts->n - i,
nesting_countdown,
- macros, me, stack, vars, expand);
+ me, stack, vars, expand);
if (n > 0)
{
i += n - 1;
continue;
}
- n = macro_expand_do (&mts->mts[i], mts->n - i,
- nesting_countdown, macros, me, stack,
- vars, expand, exp);
+ n = macro_expand_do (&mts->mts[i], mts->n - i, nesting_countdown, me,
+ stack, vars, expand, exp);
if (n > 0)
{
i += n - 1;
.last_line = mc->macro->last_line,
};
macro_expand (&mc->macro->body, settings_get_mnest (),
- mc->macros, &me, NULL, &stack, &expand, NULL, exp);
+ &me, NULL, &stack, &expand, NULL, exp);
}