class Type1Lexer
extends java.lang.Object
The PostScript language, of which Type 1 fonts are a subset, has a
somewhat awkward lexical structure. It is neither regular nor
context-free, and the execution of the program can modify the
the behaviour of the lexer/parser.
Nevertheless, this class represents an attempt to artificially separate
the PostScript parsing process into separate lexing and parsing phases
in order to reduce the complexity of the parsing phase.
,
"PostScript Language Reference 3rd ed, Adobe Systems (1999)"Modifier and Type | Field and Description |
---|---|
private Token |
aheadToken |
private java.nio.ByteBuffer |
buffer |
private static org.apache.commons.logging.Log |
LOG
Log instance.
|
private int |
openParens |
Constructor and Description |
---|
Type1Lexer(byte[] bytes)
Constructs a new Type1Lexer given a header-less .pfb segment.
|
Modifier and Type | Method and Description |
---|---|
private char |
getChar()
Reads an ASCII char from the buffer.
|
Token |
nextToken()
Returns the next token and consumes it.
|
Token |
peekToken()
Returns the next token without consuming it.
|
private Token |
readCharString(int length)
Reads a binary CharString.
|
private java.lang.String |
readComment()
Reads a line comment.
|
private java.lang.String |
readRegular()
Reads a sequence of regular characters, i.e.
|
private Token |
readString()
Reads a (string).
|
private Token |
readToken(Token prevToken)
Reads a single token.
|
private Token |
tryReadNumber()
Reads a number or returns null.
|
private static final org.apache.commons.logging.Log LOG
private final java.nio.ByteBuffer buffer
private Token aheadToken
private int openParens
Type1Lexer(byte[] bytes) throws java.io.IOException
bytes
- Header-less .pfb segmentjava.io.IOException
public Token nextToken() throws java.io.IOException
java.io.IOException
public Token peekToken()
private char getChar()
private Token readToken(Token prevToken) throws java.io.IOException
prevToken
- the previous tokenjava.io.IOException
private Token tryReadNumber()
private java.lang.String readRegular()
private java.lang.String readComment()
private Token readString()
private Token readCharString(int length)