diff --git a/CHANGELOG.md b/CHANGELOG.md index 14b9635b..6725ef6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ## [Unreleased] ### Changed -- Improved syntax highlighting for numeric literals. +- Improved syntax highlighting for operators and numeric literals. ## [2.1.0-beta.2] - 2022-12-26 diff --git a/src/editor/pybricksMicroPython.ts b/src/editor/pybricksMicroPython.ts index 8d1f0df0..ac5e86f8 100644 --- a/src/editor/pybricksMicroPython.ts +++ b/src/editor/pybricksMicroPython.ts @@ -180,13 +180,12 @@ export const language = { { include: '@whitespace' }, { include: '@numbers' }, { include: '@strings' }, - { include: '@operators' }, - - [/[,:;]/, 'delimiter'], - [/[{}[\]()]/, '@brackets'], - [/@[a-zA-Z_]\w*/, 'tag'], - + [/\.\.\./, 'keyword'], + [/->/, 'delimiter'], + { include: '@operators' }, + [/[,:.;=]/, 'delimiter'], + [/[{}[\]()]/, '@brackets'], [ /[a-zA-Z_]\w*/, { @@ -249,7 +248,12 @@ export const language = { [/\\$/, 'string'], ], - operators: [[/[=+\-*/%@&|<>!~^]/, 'keyword.operator']], + operators: [ + [ + /(\*\*|\/\/|<<|>>|:=|<=|>=|==|!=|\+=|-=|\*-|\/=|\.\.=|%=|@=|&=|\|=|\^=|>>=|<<=|\*\*=|[+\-*/%@&|^~<>])/, + 'keyword.operator', + ], + ], attributes: [ [/\b/, '@pop'],