Exemplo n.º 1
0
  /**
   * Scan the next tokens (between braces) and put the value (as text) on the log. In fact only the
   * source is informed that there is something to write out. This is done using the observer
   * pattern.
   *
   * @see de.dante.extex.interpreter.type.Code#execute( de.dante.extex.interpreter.Flags,
   *     de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource,
   *     de.dante.extex.typesetter.Typesetter)
   */
  public void execute(
      final Flags prefix,
      final Context context,
      final TokenSource source,
      final Typesetter typesetter)
      throws InterpreterException {

    boolean log = false;

    if (source.getKeyword(context, "to")) {

      if (source.getKeyword(context, "log")) {
        log = true;
      } else {
        throw new HelpingException(getLocalizer(), "logMissing");
      }
    }

    Tokens toks = source.scanUnprotectedTokens(context, true, false, getName());
    if (log) {
      logger.fine(" " + toks.toText());
    } else {
      logger.severe(" " + toks.toText());
    }
  }
Exemplo n.º 2
0
  /**
   * @see de.dante.extex.interpreter.type.Code#execute( de.dante.extex.interpreter.Flags,
   *     de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource,
   *     de.dante.extex.typesetter.Typesetter)
   */
  public void execute(
      final Flags prefix,
      final Context context,
      final TokenSource source,
      final Typesetter typesetter)
      throws InterpreterException {

    CodeToken cs = source.getControlSequence(context);
    Code code = context.getCode(cs);

    if (code == null) {
      throw new UndefinedControlSequenceException(printable(context, cs));
    }

    boolean horizontal;

    Node node = null;
    if (code instanceof Boxable) {
      Box b = ((Boxable) code).getBox(context, source, typesetter);
      node = b.getNodes();
      horizontal = b.isHbox();
    } else if (code instanceof RuleConvertible) {
      node = ((RuleConvertible) code).getRule(context, source, typesetter);
      horizontal = ((RuleNode) node).isHorizontal();
    } else {
      throw new HelpingException(getLocalizer(), "TTP.BoxExpected");
    }

    CodeToken vskip = source.getControlSequence(context);
    code = context.getCode(vskip);

    if (code == null) {
      throw new UndefinedControlSequenceException( //
          context.esc(vskip.getName()));
    }

    FixedGlue skip;

    if (horizontal) {
      if (!(code instanceof HorizontalSkip)) {
        throw new HelpingException(getLocalizer(), "TTP.BadGlueAfterLeaders");
      }
      skip = ((HorizontalSkip) code).getGlue(context, source, typesetter);
    } else {
      if (!(code instanceof VerticalSkip)) {
        throw new HelpingException(getLocalizer(), "TTP.BadGlueAfterLeaders");
      }
      skip = ((VerticalSkip) code).getGlue(context, source, typesetter);
    }

    try {
      typesetter.add(new CenteredLeadersNode(node, skip, horizontal));
    } catch (TypesetterException e) {
      throw new InterpreterException(e);
    } catch (ConfigurationException e) {
      throw new InterpreterException(e);
    }
  }
Exemplo n.º 3
0
  /**
   * @see de.dante.extex.interpreter.type.Code#execute( de.dante.extex.interpreter.Flags,
   *     de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource,
   *     de.dante.extex.typesetter.Typesetter)
   */
  public void execute(
      final Flags prefix,
      final Context context,
      final TokenSource source,
      final Typesetter typesetter)
      throws InterpreterException {

    Mode mode = typesetter.getMode();
    if (!mode.isHmode()) {
      throw new CantUseInException(printableControlSequence(context), mode.toString());
    }
    Flags flags = prefix.copy();
    prefix.clear();
    Box b =
        new Box(
            context, source, typesetter, false, null, GroupType.VBOX_GROUP, source.getLastToken());

    try {
      typesetter.add(new AdjustNode(b.getNodes()));
    } catch (TypesetterException e) {
      throw new InterpreterException(e);
    } catch (ConfigurationException e) {
      throw new InterpreterException(e);
    }
    prefix.set(flags);
  }
Exemplo n.º 4
0
  /**
   * @see de.dante.extex.interpreter.type.Code#execute( de.dante.extex.interpreter.Flags,
   *     de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource,
   *     de.dante.extex.typesetter.Typesetter)
   */
  public void execute(
      final Flags prefix,
      final Context context,
      final TokenSource source,
      final Typesetter typesetter)
      throws InterpreterException {

    Token t = source.getToken(context);
    if (t == null) {
      throw new EofException(printableControlSequence(context));
    }
    Token token = source.getToken(context);
    if (token == null) {
      throw new EofException(printableControlSequence(context));
    }
    source.execute(token, context, typesetter);
    source.push(t);
  }
Exemplo n.º 5
0
  /**
   * @see de.dante.extex.interpreter.primitives.conditional.AbstractIf#conditional(
   *     de.dante.extex.interpreter.context.Context, de.dante.extex.interpreter.TokenSource,
   *     de.dante.extex.typesetter.Typesetter)
   */
  protected boolean conditional(
      final Context context, final TokenSource source, final Typesetter typesetter)
      throws InterpreterException {

    long value = ScaledNumber.parse(context, source, typesetter);
    Token rel = source.getToken(context);
    if (rel == null) {
      throw new EofException(printableControlSequence(context));
    }
    if (rel.getCatcode() == Catcode.OTHER) {
      switch (rel.getChar().getCodePoint()) {
        case '<':
          return (value < ScaledNumber.parse(context, source, typesetter));
        case '=':
          return (value == ScaledNumber.parse(context, source, typesetter));
        case '>':
          return (value > ScaledNumber.parse(context, source, typesetter));
        default:
          // fall-through
      }
    }

    throw new HelpingException(getLocalizer(), "IllegalOp");
  }