use of de.be4.classicalb.core.parser.lexer.LexerException in project probparsers by bendisposto.
the class PreLexer method collectRhs.
private void collectRhs() throws LexerException, IOException {
if (state.equals(State.DEFINITIONS_RHS) || (previousState != null && previousState.equals(State.DEFINITIONS_RHS))) {
if (rhsToken == null) {
// starting a new definition rhs
rhsToken = new TRhsBody("", -1, -1);
rhsBuffer = new StringBuilder();
} else {
final State nextState = getNextState();
// end of rhs reached?
if (nextState != null) {
// push current token back into reader
try {
unread(token);
} catch (IOException e) {
throw new IOException("Pushback buffer overflow on Token: " + token.getText());
}
// prepare rhs_body token to be the current one
((Token) rhsToken).setText(rhsBuffer.toString());
token = rhsToken;
rhsToken = null;
rhsBuffer = null;
state = nextState;
} else {
// first token after "==" sets start position
if (rhsToken.getLine() == -1) {
rhsToken.setLine(token.getLine());
rhsToken.setPos(token.getPos());
}
rhsBuffer.append(token.getText());
token = null;
}
}
}
}
use of de.be4.classicalb.core.parser.lexer.LexerException in project probparsers by bendisposto.
the class EBLexer method filter.
@Override
protected void filter() throws LexerException, IOException {
super.filter();
if (token != null && token instanceof TIdentifierLiteral && v.get(token.getText())) {
Queue<IToken> ts = getNextList();
List<IToken> toks = getTokenList();
int l = token.getLine();
int p = token.getPos();
TLeftPar t1 = new TLeftPar(l, p);
ts.add(t1);
toks.add(t1);
ts.add(token);
toks.add(token);
TEqual t2 = new TEqual("=", l, p);
ts.add(t2);
toks.add(t2);
TTrue t3 = new TTrue("TRUE", l, p);
ts.add(t3);
toks.add(t3);
TRightPar t4 = new TRightPar(l, p);
ts.add(t4);
toks.add(t4);
token = null;
}
}
use of de.be4.classicalb.core.parser.lexer.LexerException in project probparsers by bendisposto.
the class EventBLexer method endStringToken.
private void endStringToken() throws LexerException {
try {
/*
* Push back current token. We are going to insert our own string
* token into the token stream just before the current token. Reset
* state so that unread token can be recognized again in next lexer
* step.
*/
unread(token);
state = State.NORMAL;
// create text for string token
string.setText(createString());
} catch (final IOException e) {
throw new LexerException("IOException occured: " + e.getLocalizedMessage());
}
token = string;
string = null;
stringBuffer = null;
}
use of de.be4.classicalb.core.parser.lexer.LexerException in project probparsers by bendisposto.
the class SatProblem method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException, LexerException, IOException {
final BParser parser = new BParser("testcase");
Start ast = parser.eparse(testMachine, new Definitions());
final Ast2String ast2String = new Ast2String();
ast.apply(ast2String);
final String string = ast2String.toString();
return string;
}
use of de.be4.classicalb.core.parser.lexer.LexerException in project probparsers by bendisposto.
the class PredVarsTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException, LexerException, IOException {
final BParser parser = new BParser("testcase");
Start ast = parser.eparse(testMachine, new Definitions());
final Ast2String ast2String = new Ast2String();
ast.apply(ast2String);
final String string = ast2String.toString();
return string;
}
Aggregations