takentaal/takentaal.g4
Jos van den Oever 6a68ed3140 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
2024-08-29 17:47:12 +02:00

105 lines
1.1 KiB
ANTLR

grammar takentaal;
takentaal
: header
plan
;
header
: 'takentaal v0.1.0' EOL
;
plan
: PLAN_TOKEN S* amount TEXT EOL
description
task+
;
description
: (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
: [ ] -> skip
;
EOL
: '\n'+
;
INT
: DIGIT+
;
DIGIT
: [0-9]
;
START_AMOUNT
: '{'
;
END_AMOUNT
: '}'
;
STARTCHAR
: [ -"$-/:-\u007A\u007C-\u007E]
;
CHAR
: [ -\u007E\u00A0-\u33FF] // ASCII and UNICODE
;
TEXT
: STARTCHAR CHAR*
;