|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object goldengine.java.LookAheadStream
public class LookAheadStream
Copy of original goldengine.java.LookAheadStream,
with modified readLine()
method.
Field Summary | |
---|---|
private int |
bufferPos
|
private java.io.PushbackReader |
buffR
|
private int |
kMaxBufferSize
|
private int |
multiplier
|
private char[] |
unreadme
|
Constructor Summary | |
---|---|
LookAheadStream()
|
Method Summary | |
---|---|
boolean |
closeFile()
closeFile This method will close the source file. |
boolean |
done()
done This method checks the next character to see if it is the end of the file. |
private void |
doubleArray()
|
java.lang.String |
nextChar()
nextChar This method will read one character (int) from the stream. |
boolean |
nextCharNotWhitespace()
nextCharNotWhitespace A quick checker method which checks to see if the next character is whitespace. |
boolean |
openFile(java.lang.String file)
openFile This method will open the source file to read. |
java.lang.String |
read(int size)
read This method will return a String of length size . |
java.lang.String |
readLine()
As of today, 08/12/2005, Java engine featured on the GOLD site (http://www.devincook.com/goldparser/doc/index.htm#Engine) does NOT handle languages that use EOL as a statement separator (such as VBS). |
private void |
unreadChars(int size)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.io.PushbackReader buffR
private char[] unreadme
private final int kMaxBufferSize
private int multiplier
private int bufferPos
Constructor Detail |
---|
public LookAheadStream()
Method Detail |
---|
public boolean openFile(java.lang.String file) throws goldengine.java.ParserException
- name>
- Returns:
- True if the file was opened. It will not return false, as an
exception should be thrown beforehand.
- Throws:
ParserException
- If the PushbackReader was not initialised.
public boolean closeFile() throws goldengine.java.ParserException
ParserException
- if the file could not be closed.private void doubleArray()
private void unreadChars(int size)
public boolean done() throws goldengine.java.ParserException
ParserException
- if the stream could not be read.public boolean nextCharNotWhitespace() throws goldengine.java.ParserException
ParserException
- if the stream could not be read.public java.lang.String nextChar() throws goldengine.java.ParserException
ParserException
- if the stream could not be read.public java.lang.String read(int size) throws goldengine.java.ParserException
size
. The
String is contained in the buffer of read characters.
size
- The number of characters to read from the buffer.
ParserException
- if the stream could not be read.public java.lang.String readLine() throws goldengine.java.ParserException
IF x>0 THEN ' X is positiveThe workaround is to this method with the following:
public String readLine() throws ParserException { int charSpace = 0; boolean endReached = false; String text = "", ch; while (!endReached & !done()) { ch = nextChar(); if (ch.charAt(0) == '\r' || ch.charAt(0) == '\n') { break; } charSpace++; text += ch; } unreadChars(charSpace); return text; }Notice that this does not really readLine, it reads UP TO EOL. However, the languages for which EOL is whitespace won't care, and the languages which care about EOL will just get it and handle it appropriately otherwise. This second behavior is exactly what I needed. Furthermore, this method is only called in one place -- precisely to handle line comments. This bug fix may already have made it into that package by the time you read this. But if not, here you go.
goldengine.java.ParserException
http://www.devincook.com/GOLDParser/engine/java-hawkins/doc/LookAheadStream.html#readLine()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |