Class PDA
java.lang.Object
org.pgpainless.decryption_verification.syntax_check.PDA
Pushdown Automaton for validating context-free languages.
In PGPainless, this class is used to validate OpenPGP message packet sequences against the allowed syntax.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPDA()Default constructor which initializes the PDA to work with theOpenPgpMessageSyntax.PDA(Syntax syntax, State initialState, StackSymbol... initialStack) -
Method Summary
Modifier and TypeMethodDescriptionvoidThrow aMalformedOpenPgpMessageExceptionif the pda is not in a valid state right now.getState()Return the current state of the PDA.booleanisValid()Return true, if the PDA is in a valid state (the OpenPGP message is valid).voidnext(InputSymbol input) Process the nextInputSymbol.Peek at the stack, returning the topmost stack item without changing the stack.toString()
-
Constructor Details
-
PDA
public PDA()Default constructor which initializes the PDA to work with theOpenPgpMessageSyntax. -
PDA
public PDA(@Nonnull Syntax syntax, @Nonnull State initialState, @Nonnull StackSymbol... initialStack) - Parameters:
syntax- syntaxinitialState- initial stateinitialStack- zero or more initial stack items (get pushed onto the stack in order of appearance)
-
-
Method Details
-
next
Process the nextInputSymbol. This will either leave the PDA in the next state, or throw aMalformedOpenPgpMessageExceptionif the input symbol is rejected.- Parameters:
input- input symbol- Throws:
MalformedOpenPgpMessageException- if the input symbol is rejected
-
getState
Return the current state of the PDA.- Returns:
- state
-
peekStack
Peek at the stack, returning the topmost stack item without changing the stack.- Returns:
- topmost stack item, or null if stack is empty
-
isValid
public boolean isValid()Return true, if the PDA is in a valid state (the OpenPGP message is valid).- Returns:
- true if valid, false otherwise
-
assertValid
Throw aMalformedOpenPgpMessageExceptionif the pda is not in a valid state right now.- Throws:
MalformedOpenPgpMessageException- if the pda is not in an acceptable state
-
toString
-