From 0692c4a4e81dc3561e099afacf005b2ba83972d4 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sat, 8 Sep 2018 16:11:17 -0400 Subject: [PATCH] better number matching --- Syntaxes/EDAsm.sublime-syntax | 8 ++++---- Syntaxes/MPW Asm IIgs.sublime-syntax | 20 +++++++++++++------- Syntaxes/Macross.sublime-syntax | 10 +++++----- Syntaxes/Merlin.sublime-syntax | 19 ++++++++++++++++--- Syntaxes/NinjaForce assembler.sublime-syntax | 8 ++++---- Syntaxes/ORCA-M.sublime-syntax | 8 ++++---- Syntaxes/WDC.sublime-syntax | 6 +++--- 7 files changed, 49 insertions(+), 30 deletions(-) diff --git a/Syntaxes/EDAsm.sublime-syntax b/Syntaxes/EDAsm.sublime-syntax index 8ddaa67..e608881 100644 --- a/Syntaxes/EDAsm.sublime-syntax +++ b/Syntaxes/EDAsm.sublime-syntax @@ -114,13 +114,13 @@ contexts: - include: eol numbers: - - match: \d+ + - match: \b\d+\b scope: constant.numeric - - match: \$[0-9a-fA-F]+ + - match: \$[0-9a-fA-F]+\b scope: constant.numeric.hex - - match: \%[01]+ + - match: \%[01]+\b scope: constant.numeric.binary - - match: \@[0-7]+ + - match: \@[0-7]+\b scope: constant.numeric.octal strings: diff --git a/Syntaxes/MPW Asm IIgs.sublime-syntax b/Syntaxes/MPW Asm IIgs.sublime-syntax index cce1a39..a46ef83 100644 --- a/Syntaxes/MPW Asm IIgs.sublime-syntax +++ b/Syntaxes/MPW Asm IIgs.sublime-syntax @@ -21,20 +21,20 @@ contexts: - match: '^({{ident}}){{ws}}((?i)PROC|PROCNAME|FUNC|INIT)\b' captures: 1: entity.name.function - 2: keyword.directive + 2: meta.opcode keyword.directive push: operand-proc - match: '^({{ident}}){{ws}}((?i)STACKDP)\b' captures: 1: entity.name.function - 2: keyword.directive + 2: meta.operand keyword.directive push: operand-stackdp - match: '^({{ident}}){{ws}}((?i)RECORD)\b' captures: 1: entity.name.record - 2: keyword.directive + 2: meta.operand keyword.directive push: operand-record @@ -53,8 +53,11 @@ contexts: pop: true opcode: + - meta_content_scope: meta.opcode + - match: '{{ws}}' set: operand + - include: scope:source.asm.65816#mnemonics-6502 - include: scope:source.asm.65816#mnemonics-65c02 - include: scope:source.asm.65816#mnemonics-65816 @@ -62,6 +65,7 @@ contexts: - include: mnemonics-65816-alt # toolbox macros + # matches _ for toolbox completion. - match: \b_[A-Za-z0-9]+\b scope: support.function.macro.toolbox @@ -249,6 +253,8 @@ contexts: - include: expect-comment operand: + - meta_content_scope: meta.operand + - include: macro-parm - include: numbers @@ -266,13 +272,13 @@ contexts: numbers: - - match: \d+ + - match: \b\d+\b scope: constant.numeric - - match: \$[0-9a-fA-F]+ + - match: \$[0-9a-fA-F]+\b scope: constant.numeric.hex - - match: \%[01]+ + - match: \%[01]+\b scope: constant.numeric.binary - - match: \@[0-7]+ + - match: \@[0-7]+\b scope: constant.numeric.octal strings: diff --git a/Syntaxes/Macross.sublime-syntax b/Syntaxes/Macross.sublime-syntax index 2fc0911..0379e07 100644 --- a/Syntaxes/Macross.sublime-syntax +++ b/Syntaxes/Macross.sublime-syntax @@ -155,16 +155,16 @@ contexts: pop: true numbers: - - match: 0[0-7]+ + - match: \b0[0-7]+\b scope: constant.numeric.octal - - match: 0[xX][0-9A-Fa-f]+ + - match: \b0[xX][0-9A-Fa-f]+\b scope: constant.numeric.hexadecimal - - match: 0[qQ][0-3]+ + - match: \b0[qQ][0-3]+\b scope: constant.numeric.quarters - - match: 0[bB][01]+ + - match: \b0[bB][01]+\b scope: constant.numeric - - match: \d+ + - match: \b\d+\b scope: constant.numeric - match: \'([^'\n]|\\.)\' diff --git a/Syntaxes/Merlin.sublime-syntax b/Syntaxes/Merlin.sublime-syntax index 7f810aa..9a5ac5d 100644 --- a/Syntaxes/Merlin.sublime-syntax +++ b/Syntaxes/Merlin.sublime-syntax @@ -233,14 +233,27 @@ contexts: scope: keyword.mnemonic.65816.alt numbers: - - match: \d+ + - match: \b\d+\b scope: constant.numeric - - match: \$[0-9a-fA-F]+ + - match: \$[0-9a-fA-F]+\b scope: constant.numeric.hex - - match: \%[01_]+ + - match: \%[01_]+\b scope: constant.numeric.binary strings: + # special case for ''' and """ + - match: "(')'(')" + captures: + 0: string.quoted.single + 1: punctuation.definition.string.begin + 2: punctuation.definition.string.end + + - match: '(")"(")' + captures: + 0: string.quoted.double + 1: punctuation.definition.string.begin + 2: punctuation.definition.string.end + - match: "'" scope: punctuation.definition.string.begin push: diff --git a/Syntaxes/NinjaForce assembler.sublime-syntax b/Syntaxes/NinjaForce assembler.sublime-syntax index a2d7220..f993642 100644 --- a/Syntaxes/NinjaForce assembler.sublime-syntax +++ b/Syntaxes/NinjaForce assembler.sublime-syntax @@ -122,15 +122,15 @@ contexts: numbers: - - match: \d+ + - match: \b\d+\b scope: constant.numeric - - match: \$[0-9a-fA-F]+ + - match: \$[0-9a-fA-F]+\b scope: constant.numeric.hex - - match: \%[01]+ + - match: \%[01]+\b scope: constant.numeric.binary macro-parm: - - match: '&\d' + - match: '&\d\b' scope: variable.other strings: diff --git a/Syntaxes/ORCA-M.sublime-syntax b/Syntaxes/ORCA-M.sublime-syntax index 9297fae..3210512 100644 --- a/Syntaxes/ORCA-M.sublime-syntax +++ b/Syntaxes/ORCA-M.sublime-syntax @@ -286,13 +286,13 @@ contexts: numbers: - - match: \d+ + - match: \b\d+\b scope: constant.numeric - - match: \$[0-9a-fA-F]+ + - match: \$[0-9a-fA-F]+\b scope: constant.numeric.hex - - match: \%[01]+ + - match: \%[01]+\b scope: constant.numeric.binary - - match: \@[0-7]+ + - match: \@[0-7]+\b scope: constant.numeric.octal strings: diff --git a/Syntaxes/WDC.sublime-syntax b/Syntaxes/WDC.sublime-syntax index 0534114..a911ebd 100644 --- a/Syntaxes/WDC.sublime-syntax +++ b/Syntaxes/WDC.sublime-syntax @@ -191,11 +191,11 @@ contexts: numbers: - - match: \d+ + - match: \b\d+\b scope: constant.numeric - - match: \$[0-9a-fA-F]+ + - match: \$[0-9a-fA-F]+\b scope: constant.numeric.hex - - match: \%[01]+ + - match: \%[01]+\b scope: constant.numeric.binary strings: