mirror of
https://github.com/AppleCommander/bastools.git
synced 2025-01-03 01:29:28 +00:00
Pulling in AppleCommander tweaks.
This commit is contained in:
parent
f760b8a67b
commit
4c7e1ca530
@ -3,6 +3,8 @@ package com.webcodepro.applecommander.util.applesoft;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StreamTokenizer;
|
||||
import java.util.LinkedList;
|
||||
@ -25,7 +27,17 @@ public class TokenReader {
|
||||
/** A handy method to generate a list of Tokens from a file. */
|
||||
public static Queue<Token> tokenize(String filename) throws FileNotFoundException, IOException {
|
||||
try (FileReader fileReader = new FileReader(filename)) {
|
||||
TokenReader tokenReader = new TokenReader(fileReader);
|
||||
return tokenize(fileReader);
|
||||
}
|
||||
}
|
||||
/** A handy method to generate a list of Tokens from an InputStream. */
|
||||
public static Queue<Token> tokenize(InputStream inputStream) throws IOException {
|
||||
try (InputStreamReader streamReader = new InputStreamReader(inputStream)) {
|
||||
return tokenize(streamReader);
|
||||
}
|
||||
}
|
||||
private static Queue<Token> tokenize(Reader reader) throws IOException {
|
||||
TokenReader tokenReader = new TokenReader(reader);
|
||||
LinkedList<Token> tokens = new LinkedList<>();
|
||||
while (tokenReader.hasMore()) {
|
||||
// Magic number: maximum number of pieces from the StreamTokenizer that may be combined.
|
||||
@ -34,7 +46,6 @@ public class TokenReader {
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
|
||||
public TokenReader(Reader reader) {
|
||||
this.reader = reader;
|
||||
|
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* This package is used by the AppleSoft text file import capabilities of AppleCommander.
|
||||
* It is separate from the other components, primarily due to it being used on the input side,
|
||||
* but also due to the fact that this is the third time AppleSoft tokens have been defined!
|
||||
*
|
||||
* @author rob
|
||||
*/
|
||||
package com.webcodepro.applecommander.util.applesoft;
|
Loading…
Reference in New Issue
Block a user