Skip to content

Commit a3905c0

Browse files
authoredDec 10, 2021
OZ: Improved tokenization (#3240)
1 parent c3f9fb7 commit a3905c0

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed
 

‎components/prism-oz.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Prism.languages.oz = {
2-
'comment': /\/\*[\s\S]*?\*\/|%.*/,
2+
'comment': {
3+
pattern: /\/\*[\s\S]*?\*\/|%.*/,
4+
greedy: true
5+
},
36
'string': {
47
pattern: /"(?:[^"\\]|\\[\s\S])*"/,
58
greedy: true
@@ -18,8 +21,8 @@ Prism.languages.oz = {
1821
}
1922
],
2023
'number': /\b(?:0[bx][\da-f]+|\d+(?:\.\d*)?(?:e~?\d+)?)\b|&(?:[^\\]|\\(?:\d{3}|.))/i,
21-
'variable': /\b[A-Z][A-Za-z\d]*|`(?:[^`\\]|\\.)+`/,
22-
'attr-name': /\b\w+(?=:)/,
24+
'variable': /`(?:[^`\\]|\\.)+`/,
25+
'attr-name': /\b\w+(?=[ \t]*:(?![:=]))/,
2326
'operator': /:(?:=|::?)|<[-:=]?|=(?:=|<?:?)|>=?:?|\\=:?|!!?|[|#+\-*\/,~^@]|\b(?:andthen|div|mod|orelse)\b/,
2427
'punctuation': /[\[\](){}.:;?]/
2528
};

‎components/prism-oz.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+16-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
menubutton(text:'Test' underline:0)
22

3+
% negative example
4+
val:=Value
5+
36
----------------------------------------------------
47

58
[
6-
["function", "menubutton"], ["punctuation", "("],
7-
["attr-name", "text"], ["punctuation", ":"], ["atom", "'Test'"],
8-
["attr-name", "underline"], ["punctuation", ":"], ["number", "0"],
9-
["punctuation", ")"]
9+
["function", "menubutton"],
10+
["punctuation", "("],
11+
["attr-name", "text"],
12+
["punctuation", ":"],
13+
["atom", "'Test'"],
14+
["attr-name", "underline"],
15+
["punctuation", ":"],
16+
["number", "0"],
17+
["punctuation", ")"],
18+
19+
["comment", "% negative example"],
20+
"\r\nval", ["operator", ":="], "Value"
1021
]
1122

1223
----------------------------------------------------
1324

14-
Checks for parameter names.
25+
Checks for parameter names.
+7-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
A
2-
Foobar
3-
Foo42
4-
5-
----------------------------------------------------
6-
7-
[
8-
["variable", "A"],
9-
["variable", "Foobar"],
10-
["variable", "Foo42"]
11-
]
12-
13-
----------------------------------------------------
14-
15-
Checks for variables.
1+
`foo`
2+
3+
----------------------------------------------------
4+
5+
[
6+
["variable", "`foo`"]
7+
]

0 commit comments

Comments
 (0)