-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(erlang) highlight character literals (#3970)
* highlight erlang character literals * fix regex, add extra markup test cases * 3 digits are only allowed after backslash * add char literal into basic modes to fix nesting issues * adopt modern code standard * improve markup tests
- Loading branch information
1 parent
14a5dcf
commit e964bec
Showing
3 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Character = <span class="hljs-string">$a</span> | ||
TabCharacter = <span class="hljs-string">$\t</span> | ||
TabCharacterDecimal = <span class="hljs-string">$\011</span> | ||
TextWithDollar = <span class="hljs-string">"This is just a normal text with a $ in the middle"</span> | ||
StringStart = <span class="hljs-string">$"</span> | ||
Backslash = <span class="hljs-string">$\\</span> | ||
ListStart = <span class="hljs-string">$[</span> | ||
ListEnd = <span class="hljs-string">$]</span> | ||
SpaceChar = <span class="hljs-string">$ </span> <span class="hljs-comment">% yes, that works</span> | ||
<span class="hljs-function"><span class="hljs-title">fun_takes_literal</span><span class="hljs-params">(<span class="hljs-string">$a</span>)</span> -></span> ok. | ||
<span class="hljs-function"><span class="hljs-title">fun_takes_literal_list</span><span class="hljs-params">([<span class="hljs-string">$a</span>|Rest])</span> -></span> ok. | ||
<span class="hljs-function"><span class="hljs-title">fun_takes_literal_binary</span><span class="hljs-params">(<<<span class="hljs-string">$a</span>, Rest/binary>>)</span> -></span> ok. | ||
<span class="hljs-function"><span class="hljs-title">convert_escape_sequence</span><span class="hljs-params">(<<<span class="hljs-string">$\\</span>, Escaped, Rest/binary>>)</span> -></span> | ||
C = <span class="hljs-keyword">case</span> Escaped <span class="hljs-keyword">of</span> | ||
<span class="hljs-string">$b</span> -> <span class="hljs-string">$\b</span>; | ||
<span class="hljs-string">$f</span> -> <span class="hljs-string">$\f</span>; | ||
<span class="hljs-string">$n</span> -> <span class="hljs-string">$\n</span>; | ||
<span class="hljs-string">$r</span> -> <span class="hljs-string">$\r</span>; | ||
<span class="hljs-string">$t</span> -> <span class="hljs-string">$\t</span>; | ||
<span class="hljs-string">$"</span> -> <span class="hljs-string">$"</span>; | ||
<span class="hljs-string">$\\</span> -> <span class="hljs-string">$\\</span>; | ||
_ -> error | ||
<span class="hljs-keyword">end</span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Character = $a | ||
TabCharacter = $\t | ||
TabCharacterDecimal = $\011 | ||
TextWithDollar = "This is just a normal text with a $ in the middle" | ||
StringStart = $" | ||
Backslash = $\\ | ||
ListStart = $[ | ||
ListEnd = $] | ||
SpaceChar = $ % yes, that works | ||
fun_takes_literal($a) -> ok. | ||
fun_takes_literal_list([$a|Rest]) -> ok. | ||
fun_takes_literal_binary(<<$a, Rest/binary>>) -> ok. | ||
convert_escape_sequence(<<$\\, Escaped, Rest/binary>>) -> | ||
C = case Escaped of | ||
$b -> $\b; | ||
$f -> $\f; | ||
$n -> $\n; | ||
$r -> $\r; | ||
$t -> $\t; | ||
$" -> $"; | ||
$\\ -> $\\; | ||
_ -> error | ||
end |