Skip to content

Commit

Permalink
Fix highlight of hex numbers in Pascal lexer (#1840)
Browse files Browse the repository at this point in the history
  • Loading branch information
tancnle committed Jun 26, 2022
1 parent 303943c commit 7aab31c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rouge/lexers/pascal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class Pascal < RegexLexer
mixin :whitespace

rule %r{((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?}, Num
rule %r/\$[0-9A-Fa-f]+/, Num::Hex
rule %r{[~!@#\$%\^&\*\(\)\+`\-={}\[\]:;<>\?,\.\/\|\\]}, Punctuation
rule %r{'([^']|'')*'}, Str
rule %r/(true|false|nil)\b/i, Name::Builtin
Expand Down
15 changes: 15 additions & 0 deletions spec/visual/samples/pascal
Original file line number Diff line number Diff line change
Expand Up @@ -487,3 +487,18 @@ PROGRAM a1 (input,output);
ReadString(Command)
END
END.

-- Hex numbers
function UnicodeToISO_8859_9(Unicode: cardinal): integer;
begin
case Unicode of
0..255: Result:=Unicode;
$011E: Result:= $D0;
$0130: Result:= $DD;
$015E: Result:= $DE;
$011F: Result:= $F0;
$0131: Result:= $FD;
$015F: Result:= $FE;
else Result:=-1;
end;
end;

0 comments on commit 7aab31c

Please sign in to comment.