diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-07 16:49:29 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-07 20:11:32 +0100 |
| commit | 3570869c9ae2c4df14b15423789919e514322916 (patch) | |
| tree | 6b990c9ec59fbdc7abce89c1307d22e66d0fd88a /lexers/scheme.lua | |
| parent | 098504f67aea8a862840d58c69e8f6360eef3073 (diff) | |
| download | vis-3570869c9ae2c4df14b15423789919e514322916.tar.gz vis-3570869c9ae2c4df14b15423789919e514322916.tar.xz | |
Move all lua related files to lua/ subfolder
Also remove the lexers sub directory from the Lua search path.
As a result we attempt to open fewer files during startup:
$ strace -e open -o log ./vis +q config.h && wc -l log
In order to avoid having to modifiy all lexers which `require('lexer')`
we instead place a symlink in the top level directory.
$ ./configure --disable-lua
$ rm -rf lua
Should result in a source tree with most lua specifc functionality
removed.
Diffstat (limited to 'lexers/scheme.lua')
| -rw-r--r-- | lexers/scheme.lua | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/lexers/scheme.lua b/lexers/scheme.lua deleted file mode 100644 index dba2d48..0000000 --- a/lexers/scheme.lua +++ /dev/null @@ -1,105 +0,0 @@ --- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE. --- Scheme LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'scheme'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local line_comment = ';' * l.nonnewline^0 -local block_comment = '#|' * (l.any - '|#')^0 * P('|#')^-1 -local comment = token(l.COMMENT, line_comment + block_comment) - --- Strings. -local literal = (P("'") + '#' * S('\\bdox')) * l.word -local dq_str = l.delimited_range('"') -local string = token(l.STRING, literal + dq_str) - --- Numbers. -local number = token(l.NUMBER, P('-')^-1 * l.digit^1 * (S('./') * l.digit^1)^-1) - --- Keywords. -local keyword = token(l.KEYWORD, word_match({ - 'and', 'begin', 'case', 'cond', 'cond-expand', 'define', 'define-macro', - 'delay', 'do', 'else', 'fluid-let', 'if', 'lambda', 'let', 'let*', 'letrec', - 'or', 'quasiquote', 'quote', 'set!', -}, '-*!')) - --- Functions. -local func = token(l.FUNCTION, word_match({ - 'abs', 'acos', 'angle', 'append', 'apply', 'asin', 'assoc', 'assq', 'assv', - 'atan', 'car', 'cdr', 'caar', 'cadr', 'cdar', 'cddr', 'caaar', 'caadr', - 'cadar', 'caddr', 'cdaar', 'cdadr', 'cddar', 'cdddr', - 'call-with-current-continuation', 'call-with-input-file', - 'call-with-output-file', 'call-with-values', 'call/cc', 'catch', 'ceiling', - 'char->integer', 'char-downcase', 'char-upcase', 'close-input-port', - 'close-output-port', 'cons', 'cos', 'current-input-port', - 'current-output-port', 'delete-file', 'display', 'dynamic-wind', 'eval', - 'exit', 'exact->inexact', 'exp', 'expt', 'file-or-directory-modify-seconds', - 'floor', 'force', 'for-each', 'gcd', 'gensym', 'get-output-string', 'getenv', - 'imag-part', 'integer->char', 'lcm', 'length', 'list', 'list->string', - 'list->vector', 'list-ref', 'list-tail', 'load', 'log', 'magnitude', - 'make-polar', 'make-rectangular', 'make-string', 'make-vector', 'map', 'max', - 'member', 'memq', 'memv', 'min', 'modulo', 'newline', 'nil', 'not', - 'number->string', 'open-input-file', 'open-input-string', 'open-output-file', - 'open-output-string', 'peek-char', 'quotient', 'read', 'read-char', - 'read-line', 'real-part', 'remainder', 'reverse', 'reverse!', 'round', - 'set-car!', 'set-cdr!', 'sin', 'sqrt', 'string', 'string->list', - 'string->number', 'string->symbol', 'string-append', 'string-copy', - 'string-fill!', 'string-length', 'string-ref', 'string-set!', 'substring', - 'symbol->string', 'system', 'tan', 'truncate', 'values', 'vector', - 'vector->list', 'vector-fill!', 'vector-length', 'vector-ref', 'vector-set!', - 'with-input-from-file', 'with-output-to-file', 'write', 'write-char', - 'boolean?', 'char-alphabetic?', 'char-ci<=?', 'char-ci<?', 'char-ci=?', - 'char-ci>=?', 'char-ci>?', 'char-lower-case?', 'char-numeric?', 'char-ready?', - 'char-upper-case?', 'char-whitespace?', 'char<=?', 'char<?', 'char=?', - 'char>=?', 'char>?', 'char?', 'complex?', 'eof-object?', 'eq?', 'equal?', - 'eqv?', 'even?', 'exact?', 'file-exists?', 'inexact?', 'input-port?', - 'integer?', 'list?', 'negative?', 'null?', 'number?', 'odd?', 'output-port?', - 'pair?', 'port?', 'positive?', 'procedure?', 'rational?', 'real?', - 'string-ci<=?', 'string-ci<?', 'string-ci=?', 'string-ci>=?', 'string-ci>?', - 'string<=?', 'string<?', 'string=?', 'string>=?', 'string>?', 'string?', - 'symbol?', 'vector?', 'zero?', - '#t', '#f' -}, '-/<>!?=#')) - --- Identifiers. -local word = (l.alpha + S('-!?')) * (l.alnum + S('-!?'))^0 -local identifier = token(l.IDENTIFIER, word) - --- Operators. -local operator = token(l.OPERATOR, S('<>=*/+-`@%:()')) - --- Entity. -local entity = token('entity', '&' * word) - -M._rules = { - {'func', func}, - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'string', string}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, - {'entity', entity}, -} - -M._tokenstyles = { - entity = l.STYLE_VARIABLE -} - -M._foldsymbols = { - _patterns = {'[%(%)%[%]{}]', '#|', '|#', ';'}, - [l.OPERATOR] = { - ['('] = 1, [')'] = -1, ['['] = 1, [']'] = -1, ['{'] = 1, ['}'] = -1 - }, - [l.COMMENT] = {['#|'] = 1, ['|#'] = -1, [';'] = l.fold_line_comments(';')} -} - -return M |
