From c6c98d68ecc06a12cda93690af4dd16b0e46cbab Mon Sep 17 00:00:00 2001 From: orbitalquark <70453897+orbitalquark@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:42:10 -0400 Subject: [PATCH] Renamed 'ansi_c', 'dmd', and 'rstats' lexers to 'c', 'd', and 'r', respectively. Originally this was to prevent clashes with Textadept's language-specific key handling, but this is no longer applicable. --- docs/api.md | 3 --- docs/changelog.md | 2 +- docs/manual.md | 12 ++++++------ gen_lexer_props.lua | 5 +---- lexers/{ansi_c.lua => c.lua} | 0 lexers/{dmd.lua => d.lua} | 0 lexers/glsl.lua | 2 +- lexers/lexer.lua | 12 ++++-------- lexers/output.lua | 2 +- lexers/{rstats.lua => r.lua} | 2 +- scintillua.properties | 6 +++--- tests.lua | 6 +++--- 12 files changed, 21 insertions(+), 31 deletions(-) rename lexers/{ansi_c.lua => c.lua} (100%) rename lexers/{dmd.lua => d.lua} (100%) rename lexers/{rstats.lua => r.lua} (98%) diff --git a/docs/api.md b/docs/api.md index cbcdb6fc..ba83da7e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -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 diff --git a/docs/changelog.md b/docs/changelog.md index 29e9d9cd..d4bcb143 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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 diff --git a/docs/manual.md b/docs/manual.md index 6cda5c3e..67c6dd1d 100644 --- a/docs/manual.md +++ b/docs/manual.md @@ -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 diff --git a/gen_lexer_props.lua b/gen_lexer_props.lua index d5d3b628..c8aba52d 100755 --- a/gen_lexer_props.lua +++ b/gen_lexer_props.lua @@ -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') diff --git a/lexers/ansi_c.lua b/lexers/c.lua similarity index 100% rename from lexers/ansi_c.lua rename to lexers/c.lua diff --git a/lexers/dmd.lua b/lexers/d.lua similarity index 100% rename from lexers/dmd.lua rename to lexers/d.lua diff --git a/lexers/glsl.lua b/lexers/glsl.lua index 878ca967..3999a1a5 100644 --- a/lexers/glsl.lua +++ b/lexers/glsl.lua @@ -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, { diff --git a/lexers/lexer.lua b/lexers/lexer.lua index cbd3c1a2..76ab1c41 100644 --- a/lexers/lexer.lua +++ b/lexers/lexer.lua @@ -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 @@ -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', @@ -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', -- @@ -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', -- diff --git a/lexers/output.lua b/lexers/output.lua index 9408ab17..58b25c5d 100644 --- a/lexers/output.lua +++ b/lexers/output.lua @@ -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) diff --git a/lexers/rstats.lua b/lexers/r.lua similarity index 98% rename from lexers/rstats.lua rename to lexers/r.lua index 98832978..7ac801ea 100644 --- a/lexers/rstats.lua +++ b/lexers/r.lua @@ -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)) diff --git a/scintillua.properties b/scintillua.properties index 38c8f9f8..d6680fab 100644 --- a/scintillua.properties +++ b/scintillua.properties @@ -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 @@ -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 @@ -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 diff --git a/tests.lua b/tests.lua index 8e37798e..60f73e80 100644 --- a/tests.lua +++ b/tests.lua @@ -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. @@ -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'))