summaryrefslogtreecommitdiffstats
path: root/openpgp/src/message/grammar.lalrpop
diff options
context:
space:
mode:
Diffstat (limited to 'openpgp/src/message/grammar.lalrpop')
-rw-r--r--openpgp/src/message/grammar.lalrpop67
1 files changed, 67 insertions, 0 deletions
diff --git a/openpgp/src/message/grammar.lalrpop b/openpgp/src/message/grammar.lalrpop
new file mode 100644
index 00000000..4eebd18b
--- /dev/null
+++ b/openpgp/src/message/grammar.lalrpop
@@ -0,0 +1,67 @@
+// -*- mode: Rust; -*-
+
+use message::lexer;
+
+grammar;
+
+pub Message: () = {
+ LITERAL,
+ CompressedData,
+ EncryptedPart,
+ SignedPart,
+ OPAQUE_CONTENT,
+};
+
+CompressedData: () = {
+ COMPRESSED_DATA Message POP
+};
+
+SeipPart: () = {
+ SEIP Message POP,
+}
+
+// An encrypted part is 0 or more ESKs followed by a SEIP packet.
+EncryptedPart: () = {
+ SeipPart,
+ ESKS SeipPart,
+};
+
+ESKS: () = {
+ ESK,
+ ESKS ESK,
+};
+
+ESK: () = {
+ PKESK,
+ SKESK,
+};
+
+// Signatures bracket a message like so:
+//
+// OPS OPS Message SIG SIG
+//
+// or, there are 1 or more signatures preceding a Message (this is an
+// artifact of old PGP versions):
+//
+// SIG SIG Message
+SignedPart: () = {
+ SIG Message,
+ OPS Message SIG,
+}
+
+extern {
+ type Location = usize;
+ type Error = lexer::LexicalError;
+
+ enum lexer::Token {
+ LITERAL => lexer::Token::Literal,
+ COMPRESSED_DATA => lexer::Token::CompressedData,
+ SKESK => lexer::Token::SKESK,
+ PKESK => lexer::Token::PKESK,
+ SEIP => lexer::Token::SEIP,
+ OPS => lexer::Token::OPS,
+ SIG => lexer::Token::SIG,
+ POP => lexer::Token::Pop,
+ OPAQUE_CONTENT => lexer::Token::OpaqueContent,
+ }
+}