version 1.62, 2017/03/11 15:43:04 |
version 1.63, 2017/06/20 17:24:35 |
|
|
|
|
this_tok: |
this_tok: |
switch (tok) { |
switch (tok) { |
case (EQN_TOK_UNDEF): |
case EQN_TOK_UNDEF: |
eqn_undef(ep); |
eqn_undef(ep); |
break; |
break; |
case (EQN_TOK_NDEFINE): |
case EQN_TOK_NDEFINE: |
case (EQN_TOK_DEFINE): |
case EQN_TOK_DEFINE: |
eqn_def(ep); |
eqn_def(ep); |
break; |
break; |
case (EQN_TOK_TDEFINE): |
case EQN_TOK_TDEFINE: |
if (eqn_nextrawtok(ep, NULL) == NULL || |
if (eqn_nextrawtok(ep, NULL) == NULL || |
eqn_next(ep, ep->data[(int)ep->cur], NULL, 0) == NULL) |
eqn_next(ep, ep->data[(int)ep->cur], NULL, 0) == NULL) |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
ep->eqn.ln, ep->eqn.pos, "tdefine"); |
ep->eqn.ln, ep->eqn.pos, "tdefine"); |
break; |
break; |
case (EQN_TOK_DELIM): |
case EQN_TOK_DELIM: |
eqn_delim(ep); |
eqn_delim(ep); |
break; |
break; |
case (EQN_TOK_GFONT): |
case EQN_TOK_GFONT: |
if (eqn_nextrawtok(ep, NULL) == NULL) |
if (eqn_nextrawtok(ep, NULL) == NULL) |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
ep->eqn.ln, ep->eqn.pos, eqn_toks[tok]); |
ep->eqn.ln, ep->eqn.pos, eqn_toks[tok]); |
break; |
break; |
case (EQN_TOK_MARK): |
case EQN_TOK_MARK: |
case (EQN_TOK_LINEUP): |
case EQN_TOK_LINEUP: |
/* Ignore these. */ |
/* Ignore these. */ |
break; |
break; |
case (EQN_TOK_DYAD): |
case EQN_TOK_DYAD: |
case (EQN_TOK_VEC): |
case EQN_TOK_VEC: |
case (EQN_TOK_UNDER): |
case EQN_TOK_UNDER: |
case (EQN_TOK_BAR): |
case EQN_TOK_BAR: |
case (EQN_TOK_TILDE): |
case EQN_TOK_TILDE: |
case (EQN_TOK_HAT): |
case EQN_TOK_HAT: |
case (EQN_TOK_DOT): |
case EQN_TOK_DOT: |
case (EQN_TOK_DOTDOT): |
case EQN_TOK_DOTDOT: |
if (parent->last == NULL) { |
if (parent->last == NULL) { |
mandoc_msg(MANDOCERR_EQN_NOBOX, ep->parse, |
mandoc_msg(MANDOCERR_EQN_NOBOX, ep->parse, |
ep->eqn.ln, ep->eqn.pos, eqn_toks[tok]); |
ep->eqn.ln, ep->eqn.pos, eqn_toks[tok]); |
|
|
parent->type = EQN_LISTONE; |
parent->type = EQN_LISTONE; |
parent->expectargs = 1; |
parent->expectargs = 1; |
switch (tok) { |
switch (tok) { |
case (EQN_TOK_DOTDOT): |
case EQN_TOK_DOTDOT: |
strlcpy(sym, "\\[ad]", sizeof(sym)); |
strlcpy(sym, "\\[ad]", sizeof(sym)); |
break; |
break; |
case (EQN_TOK_VEC): |
case EQN_TOK_VEC: |
strlcpy(sym, "\\[->]", sizeof(sym)); |
strlcpy(sym, "\\[->]", sizeof(sym)); |
break; |
break; |
case (EQN_TOK_DYAD): |
case EQN_TOK_DYAD: |
strlcpy(sym, "\\[<>]", sizeof(sym)); |
strlcpy(sym, "\\[<>]", sizeof(sym)); |
break; |
break; |
case (EQN_TOK_TILDE): |
case EQN_TOK_TILDE: |
strlcpy(sym, "\\[a~]", sizeof(sym)); |
strlcpy(sym, "\\[a~]", sizeof(sym)); |
break; |
break; |
case (EQN_TOK_UNDER): |
case EQN_TOK_UNDER: |
strlcpy(sym, "\\[ul]", sizeof(sym)); |
strlcpy(sym, "\\[ul]", sizeof(sym)); |
break; |
break; |
case (EQN_TOK_BAR): |
case EQN_TOK_BAR: |
strlcpy(sym, "\\[rl]", sizeof(sym)); |
strlcpy(sym, "\\[rl]", sizeof(sym)); |
break; |
break; |
case (EQN_TOK_DOT): |
case EQN_TOK_DOT: |
strlcpy(sym, "\\[a.]", sizeof(sym)); |
strlcpy(sym, "\\[a.]", sizeof(sym)); |
break; |
break; |
case (EQN_TOK_HAT): |
case EQN_TOK_HAT: |
strlcpy(sym, "\\[ha]", sizeof(sym)); |
strlcpy(sym, "\\[ha]", sizeof(sym)); |
break; |
break; |
default: |
default: |
|
|
} |
} |
|
|
switch (tok) { |
switch (tok) { |
case (EQN_TOK_DOTDOT): |
case EQN_TOK_DOTDOT: |
case (EQN_TOK_VEC): |
case EQN_TOK_VEC: |
case (EQN_TOK_DYAD): |
case EQN_TOK_DYAD: |
case (EQN_TOK_TILDE): |
case EQN_TOK_TILDE: |
case (EQN_TOK_BAR): |
case EQN_TOK_BAR: |
case (EQN_TOK_DOT): |
case EQN_TOK_DOT: |
case (EQN_TOK_HAT): |
case EQN_TOK_HAT: |
parent->top = mandoc_strdup(sym); |
parent->top = mandoc_strdup(sym); |
break; |
break; |
case (EQN_TOK_UNDER): |
case EQN_TOK_UNDER: |
parent->bottom = mandoc_strdup(sym); |
parent->bottom = mandoc_strdup(sym); |
break; |
break; |
default: |
default: |
|
|
} |
} |
parent = parent->parent; |
parent = parent->parent; |
break; |
break; |
case (EQN_TOK_FWD): |
case EQN_TOK_FWD: |
case (EQN_TOK_BACK): |
case EQN_TOK_BACK: |
case (EQN_TOK_DOWN): |
case EQN_TOK_DOWN: |
case (EQN_TOK_UP): |
case EQN_TOK_UP: |
subtok = eqn_tok_parse(ep, NULL); |
subtok = eqn_tok_parse(ep, NULL); |
if (subtok != EQN_TOK__MAX) { |
if (subtok != EQN_TOK__MAX) { |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
|
|
goto this_tok; |
goto this_tok; |
} |
} |
break; |
break; |
case (EQN_TOK_FAT): |
case EQN_TOK_FAT: |
case (EQN_TOK_ROMAN): |
case EQN_TOK_ROMAN: |
case (EQN_TOK_ITALIC): |
case EQN_TOK_ITALIC: |
case (EQN_TOK_BOLD): |
case EQN_TOK_BOLD: |
while (parent->args == parent->expectargs) |
while (parent->args == parent->expectargs) |
parent = parent->parent; |
parent = parent->parent; |
/* |
/* |
|
|
parent->type = EQN_LISTONE; |
parent->type = EQN_LISTONE; |
parent->expectargs = 1; |
parent->expectargs = 1; |
switch (tok) { |
switch (tok) { |
case (EQN_TOK_FAT): |
case EQN_TOK_FAT: |
parent->font = EQNFONT_FAT; |
parent->font = EQNFONT_FAT; |
break; |
break; |
case (EQN_TOK_ROMAN): |
case EQN_TOK_ROMAN: |
parent->font = EQNFONT_ROMAN; |
parent->font = EQNFONT_ROMAN; |
break; |
break; |
case (EQN_TOK_ITALIC): |
case EQN_TOK_ITALIC: |
parent->font = EQNFONT_ITALIC; |
parent->font = EQNFONT_ITALIC; |
break; |
break; |
case (EQN_TOK_BOLD): |
case EQN_TOK_BOLD: |
parent->font = EQNFONT_BOLD; |
parent->font = EQNFONT_BOLD; |
break; |
break; |
default: |
default: |
abort(); |
abort(); |
} |
} |
break; |
break; |
case (EQN_TOK_SIZE): |
case EQN_TOK_SIZE: |
case (EQN_TOK_GSIZE): |
case EQN_TOK_GSIZE: |
/* Accept two values: integral size and a single. */ |
/* Accept two values: integral size and a single. */ |
if (NULL == (start = eqn_nexttok(ep, &sz))) { |
if (NULL == (start = eqn_nexttok(ep, &sz))) { |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
mandoc_msg(MANDOCERR_REQ_EMPTY, ep->parse, |
|
|
parent->expectargs = 1; |
parent->expectargs = 1; |
parent->size = size; |
parent->size = size; |
break; |
break; |
case (EQN_TOK_FROM): |
case EQN_TOK_FROM: |
case (EQN_TOK_TO): |
case EQN_TOK_TO: |
case (EQN_TOK_SUB): |
case EQN_TOK_SUB: |
case (EQN_TOK_SUP): |
case EQN_TOK_SUP: |
/* |
/* |
* We have a left-right-associative expression. |
* We have a left-right-associative expression. |
* Repivot under a positional node, open a child scope |
* Repivot under a positional node, open a child scope |
|
|
break; |
break; |
} |
} |
switch (tok) { |
switch (tok) { |
case (EQN_TOK_FROM): |
case EQN_TOK_FROM: |
pos = EQNPOS_FROM; |
pos = EQNPOS_FROM; |
break; |
break; |
case (EQN_TOK_TO): |
case EQN_TOK_TO: |
pos = EQNPOS_TO; |
pos = EQNPOS_TO; |
break; |
break; |
case (EQN_TOK_SUP): |
case EQN_TOK_SUP: |
pos = EQNPOS_SUP; |
pos = EQNPOS_SUP; |
break; |
break; |
case (EQN_TOK_SUB): |
case EQN_TOK_SUB: |
pos = EQNPOS_SUB; |
pos = EQNPOS_SUB; |
break; |
break; |
default: |
default: |
|
|
} |
} |
parent = eqn_box_makebinary(ep, pos, parent); |
parent = eqn_box_makebinary(ep, pos, parent); |
break; |
break; |
case (EQN_TOK_SQRT): |
case EQN_TOK_SQRT: |
while (parent->args == parent->expectargs) |
while (parent->args == parent->expectargs) |
parent = parent->parent; |
parent = parent->parent; |
/* |
/* |
|
|
parent->pos = EQNPOS_SQRT; |
parent->pos = EQNPOS_SQRT; |
parent->expectargs = 1; |
parent->expectargs = 1; |
break; |
break; |
case (EQN_TOK_OVER): |
case EQN_TOK_OVER: |
/* |
/* |
* We have a right-left-associative fraction. |
* We have a right-left-associative fraction. |
* Close out anything that's currently open, then |
* Close out anything that's currently open, then |
|
|
parent = parent->parent; |
parent = parent->parent; |
parent = eqn_box_makebinary(ep, EQNPOS_OVER, parent); |
parent = eqn_box_makebinary(ep, EQNPOS_OVER, parent); |
break; |
break; |
case (EQN_TOK_RIGHT): |
case EQN_TOK_RIGHT: |
case (EQN_TOK_BRACE_CLOSE): |
case EQN_TOK_BRACE_CLOSE: |
/* |
/* |
* Close out the existing brace. |
* Close out the existing brace. |
* FIXME: this is a shitty sentinel: we should really |
* FIXME: this is a shitty sentinel: we should really |
|
|
parent->args == parent->expectargs) |
parent->args == parent->expectargs) |
parent = parent->parent; |
parent = parent->parent; |
break; |
break; |
case (EQN_TOK_BRACE_OPEN): |
case EQN_TOK_BRACE_OPEN: |
case (EQN_TOK_LEFT): |
case EQN_TOK_LEFT: |
/* |
/* |
* If we already have something in the stack and we're |
* If we already have something in the stack and we're |
* in an expression, then rewind til we're not any more |
* in an expression, then rewind til we're not any more |
|
|
parent->left = mandoc_strndup(start, sz); |
parent->left = mandoc_strndup(start, sz); |
} |
} |
break; |
break; |
case (EQN_TOK_PILE): |
case EQN_TOK_PILE: |
case (EQN_TOK_LPILE): |
case EQN_TOK_LPILE: |
case (EQN_TOK_RPILE): |
case EQN_TOK_RPILE: |
case (EQN_TOK_CPILE): |
case EQN_TOK_CPILE: |
case (EQN_TOK_CCOL): |
case EQN_TOK_CCOL: |
case (EQN_TOK_LCOL): |
case EQN_TOK_LCOL: |
case (EQN_TOK_RCOL): |
case EQN_TOK_RCOL: |
while (parent->args == parent->expectargs) |
while (parent->args == parent->expectargs) |
parent = parent->parent; |
parent = parent->parent; |
parent = eqn_box_alloc(ep, parent); |
parent = eqn_box_alloc(ep, parent); |
parent->type = EQN_PILE; |
parent->type = EQN_PILE; |
parent->expectargs = 1; |
parent->expectargs = 1; |
break; |
break; |
case (EQN_TOK_ABOVE): |
case EQN_TOK_ABOVE: |
for (cur = parent; cur != NULL; cur = cur->parent) |
for (cur = parent; cur != NULL; cur = cur->parent) |
if (cur->type == EQN_PILE) |
if (cur->type == EQN_PILE) |
break; |
break; |
|
|
parent = eqn_box_alloc(ep, cur); |
parent = eqn_box_alloc(ep, cur); |
parent->type = EQN_LIST; |
parent->type = EQN_LIST; |
break; |
break; |
case (EQN_TOK_MATRIX): |
case EQN_TOK_MATRIX: |
while (parent->args == parent->expectargs) |
while (parent->args == parent->expectargs) |
parent = parent->parent; |
parent = parent->parent; |
parent = eqn_box_alloc(ep, parent); |
parent = eqn_box_alloc(ep, parent); |
parent->type = EQN_MATRIX; |
parent->type = EQN_MATRIX; |
parent->expectargs = 1; |
parent->expectargs = 1; |
break; |
break; |
case (EQN_TOK_EOF): |
case EQN_TOK_EOF: |
/* |
/* |
* End of file! |
* End of file! |
* TODO: make sure we're not in an open subexpression. |
* TODO: make sure we're not in an open subexpression. |