Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ package com.progmasoft.xide.syntax
* - a comment whose text starts with `|` or `!` is a documentation comment;
* - `[[` and `[=[` start a raw string with the same long-bracket rule, in which nothing is an escape;
* - a quoted string may continue over line breaks and has backslash escapes;
* - `'` separates digit groups inside a number and otherwise starts a character literal.
* - `'` separates digit groups inside a number and otherwise starts a character literal;
* - `::` is one sign, the method reference of `Type::Method`, and not two colons.
*/
object VisualXSharpTokenizer : Tokenizer {
/** The reserved words of the language, as the compiler's lexer lists them. */
Expand All @@ -32,7 +33,7 @@ object VisualXSharpTokenizer : Tokenizer {
private val operators: List<String> =
listOf(
"...", "<<=", ">>=", "**=", "//=", "??=",
"+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "??", "?:", "==", "\\=", "<=", ">=", "&&", "||", "//", "->",
"+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "??", "?:", "::", "==", "\\=", "<=", ">=", "&&", "||", "//", "->",
"**", "++",
"=", "+", "-", "*", "/", "%", "&", "|", "^", "<", ">", "!", "?", "\\",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,30 @@ class VisualXSharpTokenizerTest {
tokenizer.assertPieces("!mask", O to "!", I to "mask")
}

@Test
fun aMethodReferenceIsOneSignBetweenTwoNames() {
tokenizer.assertPieces(
"auto next = Counter::Next;",
K to "auto", I to "next", O to "=", I to "Counter", O to "::", I to "Next", P to ";",
)
tokenizer.assertPieces(
"Apply(Demo.Counter::Next)",
I to "Apply", P to "(", I to "Demo", P to ".", I to "Counter", O to "::", I to "Next", P to ")",
)
// One colon is still the punctuation of a conditional.
tokenizer.assertPieces("a ? b : c", I to "a", O to "?", I to "b", P to ":", I to "c")
tokenizer.assertPieces("a :: : b", I to "a", O to "::", P to ":", I to "b")
}

@Test
fun aConditionalSelectsStrings() {
tokenizer.assertPieces(
"String kind = count > 0 ? \"some\" : \"none\";",
I to "String", I to "kind", O to "=", I to "count", O to ">", N to "0", O to "?", S to "\"some\"",
P to ":", S to "\"none\"", P to ";",
)
}

@Test
fun everyCompilerKeywordIsAKeyword() {
for (keyword in VisualXSharpTokenizer.keywords) {
Expand Down
Loading