better number matching

This commit is contained in:
Kelvin Sherlock 2018-09-08 16:11:17 -04:00
parent 835888a663
commit 0692c4a4e8
7 changed files with 49 additions and 30 deletions

View File

@ -114,13 +114,13 @@ contexts:
- include: eol - include: eol
numbers: numbers:
- match: \d+ - match: \b\d+\b
scope: constant.numeric scope: constant.numeric
- match: \$[0-9a-fA-F]+ - match: \$[0-9a-fA-F]+\b
scope: constant.numeric.hex scope: constant.numeric.hex
- match: \%[01]+ - match: \%[01]+\b
scope: constant.numeric.binary scope: constant.numeric.binary
- match: \@[0-7]+ - match: \@[0-7]+\b
scope: constant.numeric.octal scope: constant.numeric.octal
strings: strings:

View File

@ -21,20 +21,20 @@ contexts:
- match: '^({{ident}}){{ws}}((?i)PROC|PROCNAME|FUNC|INIT)\b' - match: '^({{ident}}){{ws}}((?i)PROC|PROCNAME|FUNC|INIT)\b'
captures: captures:
1: entity.name.function 1: entity.name.function
2: keyword.directive 2: meta.opcode keyword.directive
push: operand-proc push: operand-proc
- match: '^({{ident}}){{ws}}((?i)STACKDP)\b' - match: '^({{ident}}){{ws}}((?i)STACKDP)\b'
captures: captures:
1: entity.name.function 1: entity.name.function
2: keyword.directive 2: meta.operand keyword.directive
push: operand-stackdp push: operand-stackdp
- match: '^({{ident}}){{ws}}((?i)RECORD)\b' - match: '^({{ident}}){{ws}}((?i)RECORD)\b'
captures: captures:
1: entity.name.record 1: entity.name.record
2: keyword.directive 2: meta.operand keyword.directive
push: operand-record push: operand-record
@ -53,8 +53,11 @@ contexts:
pop: true pop: true
opcode: opcode:
- meta_content_scope: meta.opcode
- match: '{{ws}}' - match: '{{ws}}'
set: operand set: operand
- include: scope:source.asm.65816#mnemonics-6502 - include: scope:source.asm.65816#mnemonics-6502
- include: scope:source.asm.65816#mnemonics-65c02 - include: scope:source.asm.65816#mnemonics-65c02
- include: scope:source.asm.65816#mnemonics-65816 - include: scope:source.asm.65816#mnemonics-65816
@ -62,6 +65,7 @@ contexts:
- include: mnemonics-65816-alt - include: mnemonics-65816-alt
# toolbox macros # toolbox macros
# matches _ for toolbox completion.
- match: \b_[A-Za-z0-9]+\b - match: \b_[A-Za-z0-9]+\b
scope: support.function.macro.toolbox scope: support.function.macro.toolbox
@ -249,6 +253,8 @@ contexts:
- include: expect-comment - include: expect-comment
operand: operand:
- meta_content_scope: meta.operand
- include: macro-parm - include: macro-parm
- include: numbers - include: numbers
@ -266,13 +272,13 @@ contexts:
numbers: numbers:
- match: \d+ - match: \b\d+\b
scope: constant.numeric scope: constant.numeric
- match: \$[0-9a-fA-F]+ - match: \$[0-9a-fA-F]+\b
scope: constant.numeric.hex scope: constant.numeric.hex
- match: \%[01]+ - match: \%[01]+\b
scope: constant.numeric.binary scope: constant.numeric.binary
- match: \@[0-7]+ - match: \@[0-7]+\b
scope: constant.numeric.octal scope: constant.numeric.octal
strings: strings:

View File

@ -155,16 +155,16 @@ contexts:
pop: true pop: true
numbers: numbers:
- match: 0[0-7]+ - match: \b0[0-7]+\b
scope: constant.numeric.octal scope: constant.numeric.octal
- match: 0[xX][0-9A-Fa-f]+ - match: \b0[xX][0-9A-Fa-f]+\b
scope: constant.numeric.hexadecimal scope: constant.numeric.hexadecimal
- match: 0[qQ][0-3]+ - match: \b0[qQ][0-3]+\b
scope: constant.numeric.quarters scope: constant.numeric.quarters
- match: 0[bB][01]+ - match: \b0[bB][01]+\b
scope: constant.numeric scope: constant.numeric
- match: \d+ - match: \b\d+\b
scope: constant.numeric scope: constant.numeric
- match: \'([^'\n]|\\.)\' - match: \'([^'\n]|\\.)\'

View File

@ -233,14 +233,27 @@ contexts:
scope: keyword.mnemonic.65816.alt scope: keyword.mnemonic.65816.alt
numbers: numbers:
- match: \d+ - match: \b\d+\b
scope: constant.numeric scope: constant.numeric
- match: \$[0-9a-fA-F]+ - match: \$[0-9a-fA-F]+\b
scope: constant.numeric.hex scope: constant.numeric.hex
- match: \%[01_]+ - match: \%[01_]+\b
scope: constant.numeric.binary scope: constant.numeric.binary
strings: 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: "'" - match: "'"
scope: punctuation.definition.string.begin scope: punctuation.definition.string.begin
push: push:

View File

@ -122,15 +122,15 @@ contexts:
numbers: numbers:
- match: \d+ - match: \b\d+\b
scope: constant.numeric scope: constant.numeric
- match: \$[0-9a-fA-F]+ - match: \$[0-9a-fA-F]+\b
scope: constant.numeric.hex scope: constant.numeric.hex
- match: \%[01]+ - match: \%[01]+\b
scope: constant.numeric.binary scope: constant.numeric.binary
macro-parm: macro-parm:
- match: '&\d' - match: '&\d\b'
scope: variable.other scope: variable.other
strings: strings:

View File

@ -286,13 +286,13 @@ contexts:
numbers: numbers:
- match: \d+ - match: \b\d+\b
scope: constant.numeric scope: constant.numeric
- match: \$[0-9a-fA-F]+ - match: \$[0-9a-fA-F]+\b
scope: constant.numeric.hex scope: constant.numeric.hex
- match: \%[01]+ - match: \%[01]+\b
scope: constant.numeric.binary scope: constant.numeric.binary
- match: \@[0-7]+ - match: \@[0-7]+\b
scope: constant.numeric.octal scope: constant.numeric.octal
strings: strings:

View File

@ -191,11 +191,11 @@ contexts:
numbers: numbers:
- match: \d+ - match: \b\d+\b
scope: constant.numeric scope: constant.numeric
- match: \$[0-9a-fA-F]+ - match: \$[0-9a-fA-F]+\b
scope: constant.numeric.hex scope: constant.numeric.hex
- match: \%[01]+ - match: \%[01]+\b
scope: constant.numeric.binary scope: constant.numeric.binary
strings: strings: