projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0e3b4b1
)
Drop macro set from most function arguments.
author
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 4 Jul 2021 20:23:20 +0000
(13:23 -0700)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Sun, 4 Jul 2021 20:23:20 +0000
(13:23 -0700)
src/language/lexer/macro.c
patch
|
blob
|
history
diff --git
a/src/language/lexer/macro.c
b/src/language/lexer/macro.c
index ce6ee620462fcf9cfedf00b7f51ec28a0a354aa0..ea3a7042487057fef1b22905ca7be03982e5a930 100644
(file)
--- a/
src/language/lexer/macro.c
+++ b/
src/language/lexer/macro.c
@@
-891,7
+891,6
@@
struct parse_macro_function_ctx
const struct macro_token *input;
size_t n_input;
int nesting_countdown;
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;
const struct macro_expander *me;
const struct macro_expansion_stack *stack;
struct string_map *vars;
@@
-900,7
+899,6
@@
struct parse_macro_function_ctx
static void
macro_expand (const struct macro_tokens *, int nesting_countdown,
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_,
const struct macro_expander *, struct string_map *vars,
const struct macro_expansion_stack *stack,
bool *expand, bool *break_,
@@
-978,7
+976,6
@@
parse_function_arg (struct parse_macro_function_ctx *ctx,
.input = &ctx->input[i],
.n_input = ctx->n_input - i,
.nesting_countdown = ctx->nesting_countdown,
.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,
.me = ctx->me,
.stack = ctx->stack,
.vars = ctx->vars,
@@
-1255,8
+1252,7
@@
expand_macro_function (struct parse_macro_function_ctx *ctx,
macro_tokens_from_string__ (&mts, ss_cstr (args.strings[0]),
ctx->me->segmenter_mode, ctx->stack);
struct macro_tokens exp = { .n = 0 };
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 macro_expansion_stack) {
.name = "!EVAL",
.next = ctx->stack,
@@
-1282,7
+1278,6
@@
expand_macro_function (struct parse_macro_function_ctx *ctx,
struct expr_context
{
int nesting_countdown;
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;
const struct macro_expander *me;
const struct macro_expansion_stack *stack;
struct string_map *vars;
@@
-1329,7
+1324,6
@@
macro_evaluate_literal (const struct expr_context *ctx,
.input = p,
.n_input = end - p,
.nesting_countdown = ctx->nesting_countdown,
.input = p,
.n_input = end - p,
.nesting_countdown = ctx->nesting_countdown,
- .macros = ctx->macros,
.me = ctx->me,
.stack = ctx->stack,
.vars = ctx->vars,
.me = ctx->me,
.stack = ctx->stack,
.vars = ctx->vars,
@@
-1528,14
+1522,12
@@
macro_evaluate_or (const struct expr_context *ctx,
static char *
macro_evaluate_expression (const struct macro_token **tokens, size_t n_tokens,
int nesting_countdown,
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,
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,
.me = me,
.stack = stack,
.vars = vars,
@@
-1547,14
+1539,13
@@
macro_evaluate_expression (const struct macro_token **tokens, size_t n_tokens,
static bool
macro_evaluate_number (const struct macro_token **tokens, size_t n_tokens,
int nesting_countdown,
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,
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,
- m
acros, m
e, stack, vars, expand);
+ me, stack, vars, expand);
if (!s)
return false;
if (!s)
return false;
@@
-1601,8
+1592,7
@@
find_ifend_clause (const struct macro_token *p, const struct macro_token *end)
static size_t
macro_expand_if (const struct macro_token *tokens, size_t n_tokens,
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)
const struct macro_expansion_stack *stack,
struct string_map *vars,
bool *expand, bool *break_, struct macro_tokens *exp)
@@
-1614,10
+1604,8
@@
macro_expand_if (const struct macro_token *tokens, size_t n_tokens,
return 0;
p++;
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");
if (!result)
return 0;
bool b = strcmp (result, "0");
@@
-1684,7
+1672,7
@@
macro_expand_if (const struct macro_token *tokens, size_t n_tokens,
.mts = CONST_CAST (struct macro_token *, start),
.n = n,
};
.mts = CONST_CAST (struct macro_token *, start),
.n = n,
};
- macro_expand (&mts, nesting_countdown, m
acros, m
e, vars,
+ macro_expand (&mts, nesting_countdown, me, vars,
&(struct macro_expansion_stack) {
.name = "!IF",
.next = stack,
&(struct macro_expansion_stack) {
.name = "!IF",
.next = stack,
@@
-1696,8
+1684,7
@@
macro_expand_if (const struct macro_token *tokens, size_t n_tokens,
static size_t
macro_parse_let (const struct macro_token *tokens, size_t n_tokens,
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)
{
const struct macro_expansion_stack *stack,
struct string_map *vars, bool *expand)
{
@@
-1735,7
+1722,7
@@
macro_parse_let (const struct macro_token *tokens, size_t n_tokens,
p++;
char *value = macro_evaluate_expression (&p, end - p, nesting_countdown,
p++;
char *value = macro_evaluate_expression (&p, end - p, nesting_countdown,
- m
acros, m
e, stack, vars, expand);
+ me, stack, vars, expand);
if (!value)
return 0;
if (!value)
return 0;
@@
-1768,8
+1755,7
@@
find_doend (const struct macro_expansion_stack *stack,
static size_t
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
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)
const struct macro_expansion_stack *stack,
struct string_map *vars,
bool *expand, struct macro_tokens *exp)
@@
-1806,7
+1792,7
@@
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
{
p++;
char *list = macro_evaluate_expression (&p, end - p, nesting_countdown,
{
p++;
char *list = macro_evaluate_expression (&p, end - p, nesting_countdown,
- m
acros, m
e, &next_stack, vars,
+ me, &next_stack, vars,
expand);
if (!list)
return 0;
expand);
if (!list)
return 0;
@@
-1842,7
+1828,7
@@
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
ss_xstrdup (items.mts[i].representation));
bool break_ = false;
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;
me, vars, &next_stack, expand, &break_, exp);
if (break_)
break;
@@
-1854,8
+1840,7
@@
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
p++;
double first;
if (!macro_evaluate_number (&p, end - p, nesting_countdown,
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
return 0;
if (p >= end || p->token.type != T_MACRO_ID
@@
-1869,8
+1854,7
@@
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
double last;
if (!macro_evaluate_number (&p, end - p, nesting_countdown,
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;
return 0;
double by = 1.0;
@@
-1879,8
+1863,7
@@
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
{
p++;
if (!macro_evaluate_number (&p, end - p, nesting_countdown,
{
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)
return 0;
if (by == 0.0)
@@
-1922,8
+1905,7
@@
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
bool break_ = false;
macro_expand (&inner, nesting_countdown,
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;
}
if (break_)
break;
}
@@
-1941,7
+1923,6
@@
macro_expand_do (const struct macro_token *tokens, size_t n_tokens,
static void
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
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)
const struct macro_expander *me, struct string_map *vars,
const struct macro_expansion_stack *stack,
bool *expand, bool *break_, struct macro_tokens *exp)
@@
-1979,8
+1960,7
@@
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
.args = NULL,
.segmenter_mode = me->segmenter_mode,
};
.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,
&(struct macro_expansion_stack) {
.name = param->name,
.next = stack,
@@
-2009,8
+1989,7
@@
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
.args = NULL,
.segmenter_mode = me->segmenter_mode,
};
.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,
&(struct macro_expansion_stack) {
.name = "!*",
.next = stack,
@@
-2025,8
+2004,7
@@
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
}
size_t n = macro_expand_if (&mts->mts[i], mts->n - i,
}
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)
{
vars, expand, break_, exp);
if (n > 0)
{
@@
-2050,7
+2028,7
@@
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
if (*expand)
{
struct macro_call *submc;
if (*expand)
{
struct macro_call *submc;
- int retval = macro_call_create (macros, token, &submc);
+ int retval = macro_call_create (m
e->m
acros, token, &submc);
for (size_t j = 1; !retval; j++)
{
const struct macro_token endcmd
for (size_t j = 1; !retval; j++)
{
const struct macro_token endcmd
@@
-2068,8
+2046,7
@@
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
.segmenter_mode = me->segmenter_mode,
};
macro_expand (&submc->macro->body, nesting_countdown - 1,
.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,
.name = submc->macro->name,
.file_name = submc->macro->file_name,
.first_line = submc->macro->first_line,
@@
-2104,7
+2081,6
@@
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
.input = &mts->mts[i],
.n_input = mts->n - i,
.nesting_countdown = nesting_countdown,
.input = &mts->mts[i],
.n_input = mts->n - i,
.nesting_countdown = nesting_countdown,
- .macros = macros,
.me = me,
.stack = stack,
.vars = vars,
.me = me,
.stack = stack,
.vars = vars,
@@
-2125,16
+2101,15
@@
macro_expand (const struct macro_tokens *mts, int nesting_countdown,
size_t n = macro_parse_let (&mts->mts[i], mts->n - i,
nesting_countdown,
size_t n = macro_parse_let (&mts->mts[i], mts->n - i,
nesting_countdown,
- m
acros, m
e, stack, vars, expand);
+ me, stack, vars, expand);
if (n > 0)
{
i += n - 1;
continue;
}
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;
if (n > 0)
{
i += n - 1;
@@
-2173,6
+2148,6
@@
macro_call_expand (struct macro_call *mc, enum segmenter_mode segmenter_mode,
.last_line = mc->macro->last_line,
};
macro_expand (&mc->macro->body, settings_get_mnest (),
.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);
}
}