org.extex.base.parser
Class ConstantDimenParser

java.lang.Object
  extended by org.extex.base.parser.ConstantDimenParser
All Implemented Interfaces:
DimenParser, Parser<Dimen>

public final class ConstantDimenParser
extends java.lang.Object
implements Parser<Dimen>, DimenParser

This class implements a parser for a dimen value.

Version:
$Revision:5417 $
Author:
Gerd Neugebauer, Michael Niedermair

Constructor Summary
ConstantDimenParser()
          Creates a new object.
 
Method Summary
 Dimen parse(Context context, TokenSource source, Typesetter typesetter)
          Parse a value of the given type
 Dimen parseDimen(Context context, TokenSource source, Typesetter typesetter)
          Acquire a length value and return it in multiples of scaled points.
static Dimen scan(Context context, TokenSource source, Typesetter typesetter)
          Creates a new object from a token stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantDimenParser

public ConstantDimenParser()
Creates a new object.

Method Detail

scan

public static Dimen scan(Context context,
                         TokenSource source,
                         Typesetter typesetter)
                  throws HelpingException,
                         TypesetterException
Creates a new object from a token stream. This method parses the following syntactic entity:
    ⟨dimen⟩
      → ⟨float⟩ ⟨dimen unit⟩
       |  ⟨float⟩ true ⟨dimen unit⟩
       |  ⟨dimen variable⟩

    ⟨float⟩
      → [+-]? [0-9]+
      |  [+-]? [0-9]+[.][0-9]*
      |  [+-]? [.][0-9]+

    ⟨dimen unit⟩
      → pt
      |  in
      |  sp
      |  mm
      |  cm
      |  dm
      |  km
      |  dd
      |  cc
      |  bp  

Parameters:
context - the interpreter context
source - the source for next tokens
typesetter - the typesetter
Returns:
a new instance with the value acquired
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter

parse

public Dimen parse(Context context,
                   TokenSource source,
                   Typesetter typesetter)
            throws HelpingException,
                   TypesetterException
Parse a value of the given type

Specified by:
parse in interface Parser<Dimen>
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the value
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
Parser.parse( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)

parseDimen

public Dimen parseDimen(Context context,
                        TokenSource source,
                        Typesetter typesetter)
                 throws HelpingException,
                        TypesetterException
Acquire a length value and return it in multiples of scaled points.

Specified by:
parseDimen in interface DimenParser
Parameters:
context - the interpreter context
source - the source for new tokens
typesetter - the typesetter
Returns:
the length value
Throws:
HelpingException - in case of an error
TypesetterException - in case of an error in the typesetter
See Also:
DimenParser.parseDimen( org.extex.interpreter.context.Context, org.extex.interpreter.TokenSource, org.extex.typesetter.Typesetter)