net.sourceforge.czt.parser.z
Class Latex2Unicode

java.lang.Object
  extended by net.sourceforge.czt.parser.z.Latex2Unicode
All Implemented Interfaces:
Lexer, ParsePropertiesKeys, LatexMarkupParser.LatexLexer

public class Latex2Unicode
extends java.lang.Object
implements ParsePropertiesKeys, LatexMarkupParser.LatexLexer

The low-level latex to unicode scanner for Z. See LatexToUnicode for a high level latex to unicode converter.

This is a JFlex generated scanner for translating Z specifications written in the latex mark-up language into unicode. It provides tokens (instances of class Symbol) whos values are unicode strings and which contain line and column number information of the original latex file or stream. See LatexSym for a list of possible token kinds.

In order to work properly, a map containing the latex mark-up function of the current section to be scanned is needed. This map must be updated when a new section header is recognised. The LatexMarkupParser is responsible for this task, and should process the output of an instance of this class before it can be processed further.

Limitations:


Field Summary
static int COMMENT_STATE
           
static int ERROR
           
static int MARKUP
          lexical states
static int YYEOF
          This character denotes the end of file
static int YYINITIAL
           
static int ZED
           
 
Fields inherited from interface net.sourceforge.czt.parser.util.ParsePropertiesKeys
PROP_IGNORE_UNKNOWN_LATEX_COMMANDS
 
Constructor Summary
Latex2Unicode(java.io.InputStream in)
          Creates a new scanner.
Latex2Unicode(java.io.Reader in)
          Creates a new scanner There is also a java.io.InputStream version of this constructor.
Latex2Unicode(net.sourceforge.czt.session.Source source, net.sourceforge.czt.session.SectionInfo sectInfo, java.util.Properties properties)
          Creates a new scanner for the source.
 
Method Summary
 LatexMarkupFunction getMarkupFunction()
          Returns the latex mark-up function.
 net.sourceforge.czt.session.Source getSource()
          The source that is lexed.
 LocToken next()
          Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.
 void setMarkupFunction(LatexMarkupFunction markupFunction)
          Sets the latex mark-up function.
 void yybegin(int newState)
          Enters a new lexical state
 char yycharat(int pos)
          Returns the character at position pos from the matched text.
 void yyclose()
          Closes the input stream.
 int yylength()
          Returns the length of the matched text region.
 void yypushback(int number)
          Pushes the specified amount of characters back into the input stream.
 void yyreset(java.io.Reader reader)
          Resets the scanner to read from a new input stream.
 int yystate()
          Returns the current lexical state.
 java.lang.String yytext()
          Returns the text matched by the current regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YYEOF

public static final int YYEOF
This character denotes the end of file

See Also:
Constant Field Values

MARKUP

public static final int MARKUP
lexical states

See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

COMMENT_STATE

public static final int COMMENT_STATE
See Also:
Constant Field Values

YYINITIAL

public static final int YYINITIAL
See Also:
Constant Field Values

ZED

public static final int ZED
See Also:
Constant Field Values
Constructor Detail

Latex2Unicode

public Latex2Unicode(net.sourceforge.czt.session.Source source,
                     net.sourceforge.czt.session.SectionInfo sectInfo,
                     java.util.Properties properties)
              throws java.io.IOException
Creates a new scanner for the source.

Throws:
java.io.IOException

Latex2Unicode

public Latex2Unicode(java.io.Reader in)
Creates a new scanner There is also a java.io.InputStream version of this constructor.

Parameters:
in - the java.io.Reader to read input from.

Latex2Unicode

public Latex2Unicode(java.io.InputStream in)
Creates a new scanner. There is also java.io.Reader version of this constructor.

Parameters:
in - the java.io.Inputstream to read input from.
Method Detail

getSource

public net.sourceforge.czt.session.Source getSource()
Description copied from interface: Lexer
The source that is lexed.

Specified by:
getSource in interface Lexer

getMarkupFunction

public LatexMarkupFunction getMarkupFunction()
Returns the latex mark-up function.

See Also:
setMarkupFunction(net.sourceforge.czt.parser.util.LatexMarkupFunction)

setMarkupFunction

public void setMarkupFunction(LatexMarkupFunction markupFunction)
Sets the latex mark-up function. This is a mapping from string (representing a latex command) to LatexCommand containing the unicode representation. This map must be kept up to date to ensure proper working of instances of this class.

Specified by:
setMarkupFunction in interface LatexMarkupParser.LatexLexer

yyclose

public final void yyclose()
                   throws java.io.IOException
Closes the input stream.

Throws:
java.io.IOException

yyreset

public final void yyreset(java.io.Reader reader)
Resets the scanner to read from a new input stream. Does not close the old reader. All internal variables are reset, the old input stream cannot be reused (internal buffer is discarded and lost). Lexical state is set to ZZ_INITIAL.

Parameters:
reader - the new input stream

yystate

public final int yystate()
Returns the current lexical state.


yybegin

public final void yybegin(int newState)
Enters a new lexical state

Parameters:
newState - the new lexical state

yytext

public final java.lang.String yytext()
Returns the text matched by the current regular expression.


yycharat

public final char yycharat(int pos)
Returns the character at position pos from the matched text. It is equivalent to yytext().charAt(pos), but faster

Parameters:
pos - the position of the character to fetch. A value from 0 to yylength()-1.
Returns:
the character at position pos

yylength

public final int yylength()
Returns the length of the matched text region.


yypushback

public void yypushback(int number)
Pushes the specified amount of characters back into the input stream. They will be read again by then next call of the scanning method

Parameters:
number - the number of characters to be read again. This number must not be greater than yylength()!

next

public LocToken next()
              throws java.io.IOException
Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.

Specified by:
next in interface Lexer
Returns:
the next token
Throws:
java.io.IOException - if any I/O-Error occurs


Copyright © 2003-2007 Community Z Tools Project. All Rights Reserved.