aboutsummaryrefslogtreecommitdiff
path: root/lexers/apl.lua
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-12-07 16:49:29 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-12-07 20:11:32 +0100
commit3570869c9ae2c4df14b15423789919e514322916 (patch)
tree6b990c9ec59fbdc7abce89c1307d22e66d0fd88a /lexers/apl.lua
parent098504f67aea8a862840d58c69e8f6360eef3073 (diff)
downloadvis-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/apl.lua')
-rw-r--r--lexers/apl.lua69
1 files changed, 0 insertions, 69 deletions
diff --git a/lexers/apl.lua b/lexers/apl.lua
deleted file mode 100644
index 4fa492e..0000000
--- a/lexers/apl.lua
+++ /dev/null
@@ -1,69 +0,0 @@
--- Copyright 2015-2016 David B. Lamkins <david@lamkins.net>. See LICENSE.
--- APL 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 = 'apl'}
-
--- Whitespace.
-local ws = token(l.WHITESPACE, l.space^1)
-
--- Comments.
-local comment = token(l.COMMENT, (P('⍝') + P('#')) * l.nonnewline^0)
-
--- Strings.
-local sq_str = l.delimited_range("'", false, true)
-local dq_str = l.delimited_range('"')
-
-local string = token(l.STRING, sq_str + dq_str)
-
--- Numbers.
-local dig = R('09')
-local rad = P('.')
-local exp = S('eE')
-local img = S('jJ')
-local sgn = P('¯')^-1
-local float = sgn * (dig^0 * rad * dig^1 + dig^1 * rad * dig^0 + dig^1) *
- (exp * sgn *dig^1)^-1
-local number = token(l.NUMBER, float * img * float + float)
-
--- Keywords.
-local keyword = token(l.KEYWORD, P('⍞') + P('χ') + P('⍺') + P('⍶') + P('⍵') +
- P('⍹') + P('⎕') * R('AZ', 'az')^0)
-
--- Names.
-local n1l = R('AZ', 'az')
-local n1b = P('_') + P('∆') + P('⍙')
-local n2l = n1l + R('09')
-local n2b = n1b + P('¯')
-local n1 = n1l + n1b
-local n2 = n2l + n2b
-local name = n1 * n2^0
-
--- Labels.
-local label = token(l.LABEL, name * P(':'))
-
--- Variables.
-local variable = token(l.VARIABLE, name)
-
--- Special.
-local special = token(l.TYPE, S('{}[]();') + P('←') + P('→') + P('◊'))
-
--- Nabla.
-local nabla = token(l.PREPROCESSOR, P('∇') + P('⍫'))
-
-M._rules = {
- {'whitespace', ws},
- {'comment', comment},
- {'string', string},
- {'number', number},
- {'keyword', keyword},
- {'label', label},
- {'variable', variable},
- {'special', special},
- {'nabla', nabla},
-}
-
-return M