diff --git a/example b/example index 88ff4a1..9a10fc8 100644 --- a/example +++ b/example @@ -1,19 +1,20 @@ -# Full work plan {5000} +takentaal v0.1.0 +# {5000} Full work plan This is the description of the entire work plan. -## First task {1000} +## {1000} First task This is the description of the first task. This description has # ' " [] symbols and ü © Ð Latin-1 chars. -- First subtask {500} -/ Second subtask {500} +- {500} First subtask +/ {500} Second subtask ## Second task {1000} This is the description of the second task. -* First subtask {500} -- Second subtask {500} +* {500} First subtask +- {500} Second subtask diff --git a/takentaal.g4 b/takentaal.g4 index 0086fcd..6b69b0e 100644 --- a/takentaal.g4 +++ b/takentaal.g4 @@ -1,107 +1,105 @@ grammar takentaal; takentaal - : (line '\n'+)+ EOF + : header + plan ; -line - : plan - | task - | subtask - | description +header + : 'takentaal v0.1.0' EOL ; plan - : PLAN_TOKEN TEXT amount? - ; - -task - : TASK_TOKEN TEXT amount? - ; - -subtask - : subtask_new - | subtask_partial - | subtask_complete - | subtask_obsolete - ; - -subtask_new - : SUBTASK_NEW_TOKEN TEXT amount? - ; - -subtask_partial - : SUBTASK_PARTIAL_TOKEN TEXT amount? - ; - -subtask_complete - : SUBTASK_COMPLETE_TOKEN TEXT amount? - ; - -subtask_obsolete - : SUBTASK_OBSOLETE_TOKEN TEXT amount? - ; - -amount - : '{' INT '}' + : PLAN_TOKEN S* amount TEXT EOL + description + task+ ; description - : TEXT + : (TEXT EOL)* + ; + +task + : TASK_TOKEN S* amount TEXT EOL + description + subtask* + ; + +subtask + : SUBTASK_TOKEN S* amount TEXT EOL + description + ; + +amount + : START_AMOUNT S* INT END_AMOUNT + | ; PLAN_TOKEN - : '# ' + : '#' ; TASK_TOKEN - : '## ' + : '##' + ; + +SUBTASK_TOKEN + : (SUBTASK_NEW_TOKEN | SUBTASK_PARTIAL_TOKEN | SUBTASK_COMPLETE_TOKEN | SUBTASK_OBSOLETE_TOKEN) ; SUBTASK_NEW_TOKEN - : '- ' + : '-' ; SUBTASK_PARTIAL_TOKEN - : '/ ' + : '/' ; SUBTASK_COMPLETE_TOKEN - : '* ' + : '*' ; SUBTASK_OBSOLETE_TOKEN - : '! ' + : '!' ; +S + : ' ' -> skip + ; + + WS - : [ \t]+ -> skip + : [ ] -> skip + ; + +EOL + : '\n'+ ; INT : DIGIT+ ; -TEXT - : TEXTHEAD TEXTBODY* - ; - -fragment LETTER - : [a-zA-Z\u0080-\u00FF_] - ; - -fragment DIGIT +DIGIT : [0-9] ; -fragment TEXTHEAD - : LETTER - | DIGIT +START_AMOUNT + : '{' ; -fragment TEXTBODY - : LETTER - | DIGIT - | [\u0021-\u007A\u007C\u007E ] // ASCII without {} - | [\u00A0-\u33FF] // UNICODE +END_AMOUNT + : '}' + ; + +STARTCHAR + : [ -"$-/:-\u007A\u007C-\u007E] + ; + +CHAR + : [ -\u007E\u00A0-\u33FF] // ASCII and UNICODE + ; + +TEXT + : STARTCHAR CHAR* ;