org.jclarion.clarion.lang.AbstractLexStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clarion-runtime Show documentation
Show all versions of clarion-runtime Show documentation
JClarion runtime environment
The newest version!
package org.jclarion.clarion.lang;
public abstract class AbstractLexStream {
private StringBuilder token = new StringBuilder();
private int lineCount = 1;
private String name;
public abstract int getEOFPosition(int ofs);
public abstract boolean eof(int ofs);
public abstract char peek(int ofs);
protected abstract char readChar();
public AbstractLexStream() {
super();
}
public void skip(int skip)
{
while (skip>0) {
char c= readChar();
if (c=='\n') lineCount++;
skip--;
}
}
public boolean eof()
{
return eof(0);
}
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
public int getLineCount() {
return lineCount;
}
public void readUntil(char c) {
while (true ) {
if (eof()) break;
if (read()==c) break;
}
}
public void readNumber() {
while ( true ) {
if (eof()) break;
char c = peek(0);
if (c<'0' || c>'9') break;
read();
}
}
public boolean readString(String string) {
return readString(string,false);
}
public boolean readString(String string, boolean ignoreWS) {
if (ignoreWS) string=string.toLowerCase();
for (int scan=0;scan='A' && c<='Z') c=(char)(c-'A'+'a');
if (c!=string.charAt(scan)) return false;
}
skip(string.length());
return true;
}
public char readAny(String bits) {
if (eof()) return (char)0;
char c = peek(0);
for (int scan=0;scan
© 2015 - 2025 Weber Informatics LLC | Privacy Policy