mirror of
https://codeberg.org/NLnet/takentaal.git
synced 2025-08-29 22:10:07 +00:00
Reorganize the grammar
- Use START_AMOUNT instead of "{" so it is parsed before TEXT - Allow only one plan and make the structure hierarchical - Add a header with version number - Put the amount at the start of the line to simplify parsing and make it easier to align amounts
This commit is contained in:
parent
5298c9e97a
commit
6a68ed3140
2 changed files with 68 additions and 69 deletions
13
example
13
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
|
||||
|
|
112
takentaal.g4
112
takentaal.g4
|
@ -1,53 +1,38 @@
|
|||
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
|
||||
|
@ -58,6 +43,10 @@ TASK_TOKEN
|
|||
: '##'
|
||||
;
|
||||
|
||||
SUBTASK_TOKEN
|
||||
: (SUBTASK_NEW_TOKEN | SUBTASK_PARTIAL_TOKEN | SUBTASK_COMPLETE_TOKEN | SUBTASK_OBSOLETE_TOKEN)
|
||||
;
|
||||
|
||||
SUBTASK_NEW_TOKEN
|
||||
: '-'
|
||||
;
|
||||
|
@ -74,34 +63,43 @@ 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*
|
||||
;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue