From 59547cbe73bb13fa823661519786ee876684b66a Mon Sep 17 00:00:00 2001 From: Brice Fernandes Date: Fri, 26 May 2023 09:27:13 +0100 Subject: [PATCH 1/2] Add formal grammar definition of format --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/README.md b/README.md index 8207f3d..ba3c75d 100644 --- a/README.md +++ b/README.md @@ -194,3 +194,46 @@ Developers should use the format `key:value` to define additional metadata (e.g. Both `key` and `value` must consist of non-whitespace characters, which are not colons. Only one colon separates the `key` and `value`. + +## TODO.txt Formal Grammar + +The Grammar for a TODO.txt file is provided in [Extended Backus-Naur Form (EBNF)](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form). The grammar below uses the conventions defined in [the W3C specification for EBNF](https://www.w3.org/TR/REC-xml/#sec-notation). + +The grammar below assumes that the `digits` and `whitespace` classes have been defined with their obvious definitions. The `printable` class includes all printable characters. + +```EBNF + +context ::= "@" printable+ ; +project ::= "+" printable+ ; +hashTag ::= "#" printable+ ; +kvpair ::= ( [^@+#:] printable* ) ":" printable+ ; +word ::= ( [^@+#] printable* ) | "@" | "+" | "#" ; + +token ::= context | project | hashTag | kvpair | word ; + +day ::= 2 * digits ; +month ::= 2 * digits ; +year ::= 4 * digits ; +date ::= year "-" month "-" day ; + +createdDate ::= date ; +completedDate ::= date ; + +priorityClass ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | + "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | + "U" | "V" | "W" | "X" | "Y" | "Z" ; +priority ::= "(" priorityClass ")" ; + +space ::= whitespace + ; + +completedMark ::= "x" ; + +todoLine ::= ( completedMark space )? + ( priority space )? + ( ( completedDate space createdDate space ) | ( createdDate space ) )? + word+ + whitespace* ; + +todoFile ::= whitespace* todoLine* ; + +``` From 464a4fa3431207c869e2091a98b9ff070f2cbaf1 Mon Sep 17 00:00:00 2001 From: Brice Fernandes Date: Fri, 26 May 2023 09:37:48 +0100 Subject: [PATCH 2/2] Simplify priorities grammar --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index ba3c75d..07ef06e 100644 --- a/README.md +++ b/README.md @@ -219,9 +219,7 @@ date ::= year "-" month "-" day ; createdDate ::= date ; completedDate ::= date ; -priorityClass ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | - "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | - "U" | "V" | "W" | "X" | "Y" | "Z" ; +priorityClass ::= [A-Z] ; priority ::= "(" priorityClass ")" ; space ::= whitespace + ;