Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OZ: Improved tokenization #3240

Merged
merged 2 commits into from Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions components/prism-oz.js
@@ -1,5 +1,8 @@
Prism.languages.oz = {
'comment': /\/\*[\s\S]*?\*\/|%.*/,
'comment': {
pattern: /\/\*[\s\S]*?\*\/|%.*/,
greedy: true
},
'string': {
pattern: /"(?:[^"\\]|\\[\s\S])*"/,
greedy: true
Expand All @@ -18,8 +21,8 @@ Prism.languages.oz = {
}
],
'number': /\b(?:0[bx][\da-f]+|\d+(?:\.\d*)?(?:e~?\d+)?)\b|&(?:[^\\]|\\(?:\d{3}|.))/i,
'variable': /\b[A-Z][A-Za-z\d]*|`(?:[^`\\]|\\.)+`/,
'attr-name': /\b\w+(?=:)/,
'variable': /`(?:[^`\\]|\\.)+`/,
'attr-name': /\b\w+(?=[ \t]*:(?![:=]))/,
'operator': /:(?:=|::?)|<[-:=]?|=(?:=|<?:?)|>=?:?|\\=:?|!!?|[|#+\-*\/,~^@]|\b(?:andthen|div|mod|orelse)\b/,
'punctuation': /[\[\](){}.:;?]/
};
2 changes: 1 addition & 1 deletion components/prism-oz.min.js

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

21 changes: 16 additions & 5 deletions tests/languages/oz/attr-name_feature.test
@@ -1,14 +1,25 @@
menubutton(text:'Test' underline:0)

% negative example
val:=Value

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

[
["function", "menubutton"], ["punctuation", "("],
["attr-name", "text"], ["punctuation", ":"], ["atom", "'Test'"],
["attr-name", "underline"], ["punctuation", ":"], ["number", "0"],
["punctuation", ")"]
["function", "menubutton"],
["punctuation", "("],
["attr-name", "text"],
["punctuation", ":"],
["atom", "'Test'"],
["attr-name", "underline"],
["punctuation", ":"],
["number", "0"],
["punctuation", ")"],

["comment", "% negative example"],
"\r\nval", ["operator", ":="], "Value"
]

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

Checks for parameter names.
Checks for parameter names.
22 changes: 7 additions & 15 deletions tests/languages/oz/variable_feature.test
@@ -1,15 +1,7 @@
A
Foobar
Foo42

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

[
["variable", "A"],
["variable", "Foobar"],
["variable", "Foo42"]
]

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

Checks for variables.
`foo`

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

[
["variable", "`foo`"]
]