Skip to content

Commit a4ca56c

Browse files
jneenjneen
andauthored
remove proprietary builtins list from ISBL (#2236)
* remove proprietary builtins list from ISBL * fix numeric literals in ISBL --------- Co-authored-by: jneen <[email protected]>
1 parent 1e3f8f9 commit a4ca56c

File tree

2 files changed

+7
-60
lines changed

2 files changed

+7
-60
lines changed

lib/rouge/lexers/isbl.rb

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,6 @@ class ISBL < RegexLexer
99
tag 'isbl'
1010
filenames '*.isbl'
1111

12-
lazy do
13-
require_relative 'isbl/builtins'
14-
end
15-
16-
def self.constants
17-
@constants ||= BUILTINS["const"].merge(BUILTINS["enum"]).collect!(&:downcase)
18-
end
19-
20-
def self.interfaces
21-
@interfaces ||= BUILTINS["interface"].collect!(&:downcase)
22-
end
23-
24-
def self.globals
25-
@globals ||= BUILTINS["global"].collect!(&:downcase)
26-
end
27-
2812
def self.keywords
2913
@keywords = Set.new %w(
3014
and и else иначе endexcept endfinally endforeach конецвсе endif конецесли endwhile
@@ -40,30 +24,16 @@ def self.keywords
4024

4125
state :dotted do
4226
mixin :whitespace
43-
rule %r/[a-zа-яё_0-9]+/i do |m|
44-
name = m[0]
45-
if self.class.constants.include? name.downcase
46-
token Name::Builtin
47-
elsif in_state? :type
48-
token Keyword::Type
49-
else
50-
token Name
51-
end
27+
rule %r/\p{Alnum}+/i do |m|
28+
token(in_state?(:type) ? Keyword::Type : Name)
29+
5230
pop!
5331
end
5432
end
5533

5634
state :type do
5735
mixin :whitespace
58-
rule %r/[a-zа-яё_0-9]+/i do |m|
59-
name = m[0]
60-
if self.class.interfaces.include? name.downcase
61-
token Keyword::Type
62-
else
63-
token Name
64-
end
65-
pop!
66-
end
36+
rule %r/\p{Word}+/, Name, :pop!
6737
rule %r/[.]/, Punctuation, :dotted
6838
rule(//) { pop! }
6939
end
@@ -74,15 +44,10 @@ def self.keywords
7444
rule %r/[.]/, Punctuation, :dotted
7545
rule %r/[\[\]();]/, Punctuation
7646
rule %r([&*+=<>/-]), Operator
77-
rule %r/\b[a-zа-яё_][a-zа-яё_0-9]*(?=[(])/i, Name::Function
78-
rule %r/[a-zа-яё_!][a-zа-яё_0-9]*/i do |m|
79-
name = m[0]
80-
if self.class.keywords.include? name.downcase
47+
rule %r/[\p{Alpha}_!]\p{Word}*(?=[(])/i, Name::Function
48+
rule %r/[\p{Alpha}_!]\p{Word}*/i do |m|
49+
if self.class.keywords.include?(m[0].downcase)
8150
token Keyword
82-
elsif self.class.constants.include? name.downcase
83-
token Name::Builtin
84-
elsif self.class.globals.include? name.downcase
85-
token Name::Variable::Global
8651
else
8752
token Name::Variable
8853
end

0 commit comments

Comments
 (0)