Skip to content

Commit

Permalink
Julia: Added char token (#3223)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Dec 5, 2021
1 parent 5af1601 commit 3a876df
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 31 deletions.
8 changes: 6 additions & 2 deletions components/prism-julia.js
Expand Up @@ -11,11 +11,15 @@ Prism.languages.julia = {
greedy: true
},
'string': {
// https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
// https://docs.julialang.org/en/v1/manual/strings/#String-Basics-1
// https://docs.julialang.org/en/v1/manual/strings/#non-standard-string-literals-1
// https://docs.julialang.org/en/v1/manual/running-external-programs/#Running-External-Programs-1
pattern: /"""[\s\S]+?"""|(?:\b\w+)?"(?:\\.|[^"\\\r\n])*"|(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'|`(?:[^\\`\r\n]|\\.)*`/,
pattern: /"""[\s\S]+?"""|(?:\b\w+)?"(?:\\.|[^"\\\r\n])*"|`(?:[^\\`\r\n]|\\.)*`/,
greedy: true
},
'char': {
// https://docs.julialang.org/en/v1/manual/strings/#man-characters-1
pattern: /(^|[^\w'])'(?:\\[^\r\n][^'\r\n]*|[^\\\r\n])'/,
lookbehind: true,
greedy: true
},
Expand Down
2 changes: 1 addition & 1 deletion components/prism-julia.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions tests/languages/julia/char_feature.test
@@ -0,0 +1,31 @@
'x'
'\''
'\u2200'
'\x80'
'\xe2\x88'
'∀'

# not a character
A'b
A'b''

----------------------------------------------------

[
["char", "'x'"],
["char", "'\\''"],
["char", "'\\u2200'"],
["char", "'\\x80'"],
["char", "'\\xe2\\x88'"],
["char", "'∀'"],

["comment", "# not a character"],

"\r\nA",
["operator", "'"],
"b\r\nA",
["operator", "'"],
"b",
["operator", "'"],
["operator", "'"]
]
29 changes: 1 addition & 28 deletions tests/languages/julia/string_feature.test
Expand Up @@ -2,13 +2,6 @@
"fo\"o"
"\xe2\x88"

'x'
'\''
'\u2200'
'\x80'
'\xe2\x88'
'∀'

"""foo"""
"""fo"o
bar"""
Expand All @@ -22,24 +15,13 @@ b"DATA\xff\u2200"
v"0.3-"
raw"\\ \\\""

# not a character
A'b
A'b''

----------------------------------------------------

[
["string", "\"\""],
["string", "\"fo\\\"o\""],
["string", "\"\\xe2\\x88\""],

["string", "'x'"],
["string", "'\\''"],
["string", "'\\u2200'"],
["string", "'\\x80'"],
["string", "'\\xe2\\x88'"],
["string", "'∀'"],

["string", "\"\"\"foo\"\"\""],
["string", "\"\"\"fo\"o\r\nbar\"\"\""],

Expand All @@ -50,16 +32,7 @@ A'b''
["string", "s\"\\g<0>1\""],
["string", "b\"DATA\\xff\\u2200\""],
["string", "v\"0.3-\""],
["string", "raw\"\\\\ \\\\\\\"\""],

["comment", "# not a character"],
"\r\nA",
["operator", "'"],
"b\r\nA",
["operator", "'"],
"b",
["operator", "'"],
["operator", "'"]
["string", "raw\"\\\\ \\\\\\\"\""]
]

----------------------------------------------------
Expand Down

0 comments on commit 3a876df

Please sign in to comment.