diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-10-05 10:25:33 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-10-05 10:48:29 +0200 |
| commit | 6cf931355b264618879b5bb3ada36067bf246882 (patch) | |
| tree | d9de896398a6948d6deb3422f6925c5e2d4ee787 /lexers | |
| parent | f44d8a006edb84e55108df472d532922db95e614 (diff) | |
| download | vis-6cf931355b264618879b5bb3ada36067bf246882.tar.gz vis-6cf931355b264618879b5bb3ada36067bf246882.tar.xz | |
lexers: sync language lexers with scintillua rev 568 id 55b15760cd31
Adds a taskpaper lexer.
Diffstat (limited to 'lexers')
| -rw-r--r-- | lexers/pico8.lua | 3 | ||||
| -rw-r--r-- | lexers/taskpaper.lua | 59 |
2 files changed, 60 insertions, 2 deletions
diff --git a/lexers/pico8.lua b/lexers/pico8.lua index 5e95948..44364f3 100644 --- a/lexers/pico8.lua +++ b/lexers/pico8.lua @@ -12,8 +12,7 @@ local M = {_NAME = 'pico8'} local ws = token(l.WHITESPACE, l.space^1) -- Comments -local line_comment = '//' * l.nonnewline_esc^0 -local comment = token(l.COMMENT, line_comment) +local comment = token(l.COMMENT, '//' * l.nonnewline_esc^0) -- Numbers local number = token(l.NUMBER, l.integer) diff --git a/lexers/taskpaper.lua b/lexers/taskpaper.lua new file mode 100644 index 0000000..5652f3a --- /dev/null +++ b/lexers/taskpaper.lua @@ -0,0 +1,59 @@ +-- Copyright (c) 2016 Larry Hynes. See LICENSE. +-- Taskpaper LPeg lexer + +local l = require('lexer') +local token = l.token +local P, R, S = lpeg.P, lpeg.R, lpeg.S + +local M = {_NAME = 'taskpaper'} + +local delimiter = P(' ') + P('\t') + +-- Whitespace +local ws = token(l.WHITESPACE, l.space^1) + +-- Tags +local day_tag = token('day_tag', (P('@today') + P('@tomorrow'))) + +local overdue_tag = token('overdue_tag', P('@overdue')) + +local plain_tag = token('plain_tag', P('@') * l.word) + +local extended_tag = token('extended_tag', + P('@') * l.word * P('(') * + (l.word + R('09') + P('-'))^1 * P(')')) + +-- Projects +local project = token('project', + l.nested_pair(l.starts_line(l.alnum), ':') * l.newline) + +-- Notes +local note = token('note', delimiter^1 * l.alnum * l.nonnewline^0) + +-- Tasks +local task = token('task', delimiter^1 * P('-') + l.newline) + +M._rules = { + {'note', note}, + {'task', task}, + {'project', project}, + {'extended_tag', extended_tag}, + {'day_tag', day_tag}, + {'overdue_tag', overdue_tag}, + {'plain_tag', plain_tag}, + {'whitespace', ws}, +} + +M._tokenstyles = { + note = l.STYLE_CONSTANT, + task = l.STYLE_FUNCTION, + project = l.STYLE_TAG, + extended_tag = l.STYLE_COMMENT, + day_tag = l.STYLE_CLASS, + overdue_tag = l.STYLE_PREPROCESSOR, + plain_tag = l.STYLE_COMMENT, +} + +M._LEXBYLINE = true + +return M |
