mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-16 17:32:06 +01:00
Allow injection of different syntax into PDA
This commit is contained in:
parent
ad75b03b91
commit
824b3dcafa
1 changed files with 14 additions and 4 deletions
|
@ -8,6 +8,7 @@ import org.pgpainless.exception.MalformedOpenPgpMessageException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,15 +24,24 @@ public class PDA {
|
||||||
// right now we implement what rfc4880 specifies.
|
// right now we implement what rfc4880 specifies.
|
||||||
// TODO: Consider implementing what we proposed here:
|
// TODO: Consider implementing what we proposed here:
|
||||||
// https://mailarchive.ietf.org/arch/msg/openpgp/uepOF6XpSegMO4c59tt9e5H1i4g/
|
// https://mailarchive.ietf.org/arch/msg/openpgp/uepOF6XpSegMO4c59tt9e5H1i4g/
|
||||||
private final Syntax syntax = new OpenPgpMessageSyntax();
|
private final Syntax syntax;
|
||||||
private final Stack<StackSymbol> stack = new Stack<>();
|
private final Stack<StackSymbol> stack = new Stack<>();
|
||||||
private final List<InputSymbol> inputs = new ArrayList<>(); // Track inputs for debugging / error reporting
|
private final List<InputSymbol> inputs = new ArrayList<>(); // Track inputs for debugging / error reporting
|
||||||
private State state;
|
private State state;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public PDA() {
|
public PDA() {
|
||||||
state = State.OpenPgpMessage;
|
this(new OpenPgpMessageSyntax(), State.OpenPgpMessage, terminus, msg);
|
||||||
pushStack(terminus);
|
}
|
||||||
pushStack(msg);
|
|
||||||
|
public PDA(@Nonnull Syntax syntax, @Nonnull State initialState, @Nonnull StackSymbol... initialStack) {
|
||||||
|
this.syntax = syntax;
|
||||||
|
this.state = initialState;
|
||||||
|
for (StackSymbol symbol : initialStack) {
|
||||||
|
pushStack(symbol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void next(InputSymbol input) throws MalformedOpenPgpMessageException {
|
public void next(InputSymbol input) throws MalformedOpenPgpMessageException {
|
||||||
|
|
Loading…
Reference in a new issue