Skip to content

Commit

Permalink
Renamed 'ansi_c', 'dmd', and 'rstats' lexers to 'c', 'd', and 'r', re…
Browse files Browse the repository at this point in the history
…spectively.

Originally this was to prevent clashes with Textadept's language-specific key handling, but this is
no longer applicable.
  • Loading branch information
orbitalquark committed Sep 18, 2024
1 parent 6636aa8 commit c6c98d6
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 31 deletions.
3 changes: 0 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ and modify, or inherit from that lexer, saving some time and effort. The filenam
lexer should be the name of your programming language in lower case followed by a *.lua*
extension. For example, a new Lua lexer has the name *lua.lua*.

Note: Try to refrain from using one-character language names like "c", "d", or "r". For
example, Scintillua uses "ansi_c", "dmd", and "rstats", respectively.

#### New Lexer Template

There is a *lexers/template.txt* file that contains a simple template for a new lexer. Feel
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ Bugfixes:
Changes:

* Do not match '..' on the trailing end of `lexer.float`.
* Updated dmd lexer.
* Updated D lexer.

[Scintilla 3.10.3]: https://sourceforge.net/projects/scintilla/files/scintilla/3.10.3/scintilla3103.zip/download

Expand Down
12 changes: 6 additions & 6 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,22 @@ doing this:
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> lexer_path = '/home/mitchell/code/scintillua/lexers/?.lua'
> package.path = package.path .. ';' .. lexer_path
> c = require('lexer').load('ansi_c')
> c = require('lexer').load('c')
> tokens = c:lex('int main() { return 0; }')
> for i = 1, #tokens, 2 do print(tokens[i], tokens[i+1]) end
type 4
whitespace.ansi_c 5
whitespace.c 5
function 9
operator 10
operator 11
whitespace.ansi_c 12
whitespace.c 12
operator 13
whitespace.ansi_c 14
whitespace.c 14
keyword 20
whitespace.ansi_c 21
whitespace.c 21
number 22
operator 23
whitespace.ansi_c 24
whitespace.c 24
operator 25

If you are unsure of which lexer to use for a given filename and/or content line (e.g. shebang line), you can
Expand Down
5 changes: 1 addition & 4 deletions gen_lexer_props.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ local noglobs = {
['Rout.save'] = true, ['Rout.fail'] = true, fstab = true, ['meson.build'] = true
}

local alt_name = {
actionscript = 'flash', ansi_c = 'c', dmd = 'd', javascript = 'js', python = 'py', rstats = 'r',
ruby = 'rb'
}
local alt_name = {actionscript = 'flash', javascript = 'js', python = 'py', ruby = 'rb'}

-- Process file patterns and lexer definitions.
local f = io.open('lexers/lexer.lua')
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lexers/glsl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
local lexer = lexer
local P, S = lpeg.P, lpeg.S

local lex = lexer.new(..., {inherit = lexer.load('ansi_c')})
local lex = lexer.new(..., {inherit = lexer.load('c')})

-- Word lists.
lex:set_word_list(lexer.KEYWORD, {
Expand Down
12 changes: 4 additions & 8 deletions lexers/lexer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@
-- lexer should be the name of your programming language in lower case followed by a *.lua*
-- extension. For example, a new Lua lexer has the name *lua.lua*.
--
-- Note: Try to refrain from using one-character language names like "c", "d", or "r". For
-- example, Scintillua uses "ansi_c", "dmd", and "rstats", respectively.
--
-- #### New Lexer Template
--
-- There is a *lexers/template.txt* file that contains a simple template for a new lexer. Feel
Expand Down Expand Up @@ -1612,8 +1609,8 @@ function M.detect(filename, line)
bib = 'bibtex', --
boo = 'boo', --
cs = 'csharp', --
c = 'ansi_c', C = 'ansi_c', cc = 'cpp', cpp = 'cpp', cxx = 'cpp', ['c++'] = 'cpp', h = 'cpp',
hh = 'cpp', hpp = 'cpp', hxx = 'cpp', ['h++'] = 'cpp', --
c = 'c', C = 'c', cc = 'cpp', cpp = 'cpp', cxx = 'cpp', ['c++'] = 'cpp', h = 'cpp', hh = 'cpp',
hpp = 'cpp', hxx = 'cpp', ['h++'] = 'cpp', --
ck = 'chuck', --
clj = 'clojure', cljs = 'clojure', cljc = 'clojure', edn = 'clojure', --
['CMakeLists.txt'] = 'cmake', cmake = 'cmake', ['cmake.in'] = 'cmake', ctest = 'cmake',
Expand All @@ -1622,7 +1619,7 @@ function M.detect(filename, line)
cr = 'crystal', --
css = 'css', --
cu = 'cuda', cuh = 'cuda', --
d = 'dmd', di = 'dmd', --
d = 'd', di = 'd', --
dart = 'dart', --
desktop = 'desktop', --
diff = 'diff', patch = 'diff', --
Expand Down Expand Up @@ -1700,8 +1697,7 @@ function M.detect(filename, line)
proto = 'protobuf', --
pure = 'pure', --
sc = 'python', py = 'python', pyw = 'python', --
R = 'rstats', Rout = 'rstats', Rhistory = 'rstats', Rt = 'rstats', ['Rout.save'] = 'rstats',
['Rout.fail'] = 'rstats', --
R = 'r', Rout = 'r', Rhistory = 'r', Rt = 'r', ['Rout.save'] = 'r', ['Rout.fail'] = 'r', --
re = 'reason', --
r = 'rebol', reb = 'rebol', --
rst = 'rest', --
Expand Down
2 changes: 1 addition & 1 deletion lexers/output.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ lex:add_rule('python',
local lparen, rparen = text('('), text(')')
local d_filename = filename((lexer.nonnewline - '(')^1)
local d_error = message(lexer.to_eol(S('Ee') * 'rror')) * mark_error
lex:add_rule('dmd', starts_line(d_filename) * lparen * line * rparen * colon * d_error)
lex:add_rule('d', starts_line(d_filename) * lparen * line * rparen * colon * d_error)

-- "filename" line X: message (gnuplot)
local gp_filename = filename((lexer.nonnewline - '"')^1)
Expand Down
2 changes: 1 addition & 1 deletion lexers/rstats.lua → lexers/r.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local lexer = require('lexer')
local token, word_match = lexer.token, lexer.word_match
local P, S = lpeg.P, lpeg.S

local lex = lexer.new('rstats')
local lex = lexer.new('r')

-- Whitespace.
lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
Expand Down
6 changes: 3 additions & 3 deletions scintillua.properties
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ keywords7.$(file.patterns.csharp)=scintillua
keywords8.$(file.patterns.csharp)=scintillua
keywords9.$(file.patterns.csharp)=scintillua
file.patterns.c=*.c;*.C
lexer.$(file.patterns.c)=scintillua.ansi_c
lexer.$(file.patterns.c)=scintillua.c
keywords.$(file.patterns.c)=scintillua
keywords2.$(file.patterns.c)=scintillua
keywords3.$(file.patterns.c)=scintillua
Expand Down Expand Up @@ -287,7 +287,7 @@ keywords7.$(file.patterns.cuda)=scintillua
keywords8.$(file.patterns.cuda)=scintillua
keywords9.$(file.patterns.cuda)=scintillua
file.patterns.d=*.d;*.di
lexer.$(file.patterns.d)=scintillua.dmd
lexer.$(file.patterns.d)=scintillua.d
keywords.$(file.patterns.d)=scintillua
keywords2.$(file.patterns.d)=scintillua
keywords3.$(file.patterns.d)=scintillua
Expand Down Expand Up @@ -1123,7 +1123,7 @@ keywords7.$(file.patterns.py)=scintillua
keywords8.$(file.patterns.py)=scintillua
keywords9.$(file.patterns.py)=scintillua
file.patterns.r=*.R;*.Rout;*.Rhistory;*.Rt;Rout.save;Rout.fail
lexer.$(file.patterns.r)=scintillua.rstats
lexer.$(file.patterns.r)=scintillua.r
keywords.$(file.patterns.r)=scintillua
keywords2.$(file.patterns.r)=scintillua
keywords3.$(file.patterns.r)=scintillua
Expand Down
6 changes: 3 additions & 3 deletions tests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ end

-- Tests the C lexer.
function test_c()
local c = lexer.load('ansi_c')
assert(c._name == 'ansi_c')
local c = lexer.load('c')
assert(c._name == 'c')
assert_default_tags(c)

-- Lexing tests.
Expand Down Expand Up @@ -1686,7 +1686,7 @@ end

function test_detect()
assert(lexer.detect('foo.lua') == 'lua')
assert(lexer.detect('foo.c') == 'ansi_c')
assert(lexer.detect('foo.c') == 'c')
assert(not lexer.detect('foo.txt'))
assert(lexer.detect('foo', '#!/bin/sh') == 'bash')
assert(not lexer.detect('foo', '/bin/sh'))
Expand Down

0 comments on commit c6c98d6

Please sign in to comment.