Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add formal grammar definition of format #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,44 @@ 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-Z] ;
priority ::= "(" priorityClass ")" ;

space ::= whitespace + ;

completedMark ::= "x" ;

todoLine ::= ( completedMark space )?
( priority space )?
( ( completedDate space createdDate space ) | ( createdDate space ) )?
word+
whitespace* ;

todoFile ::= whitespace* todoLine* ;

```