Last active
March 9, 2018 03:42
-
-
Save zhongsheng94/55427f644f88416b57eb64c804722726 to your computer and use it in GitHub Desktop.
This is a sublime-syntax file for *Sublime Text 3* which highlights the MAP FILE generated by Keil MDK-ARM, you can just put it into Packages/User folder to apply it :-)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%YAML 1.2 | |
--- | |
# See http://www.sublimetext.com/docs/3/syntax.html | |
name: ARM Map | |
file_extensions: | |
- map | |
scope: text.map | |
# first_line_match: | |
variables: | |
file_path: '[-\w\:\.\/\\]+' | |
obj_file: '[\w\.]+\.o' | |
func_name: '[_a-zA-Z]\w*' | |
symbol_ref: '[~\$\.\:\w]+' | |
# match string that contains word,parentheses,point,space | |
# and don't contain continuous two spaces | |
one_spc_name: '([a-zA-Z\.\(\)]+ ?)+' | |
hex: '0[x|X][0-9a-fA-F]+' | |
number: '\d+' | |
contexts: | |
# The prototype context is prepended to all contexts but those setting | |
# meta_include_prototype: false. | |
# prototype: | |
# - include: comments | |
main: | |
# The main context is the initial starting point of our syntax. | |
# Include other contexts from here (or specify them directly). | |
- match: '.+\n' | |
scope: comment.block | |
push: body | |
body: | |
# match the body of map file | |
- match: '^=+$' | |
scope: comment.line | |
push: | |
- match: '^Section Cross References$' | |
scope: entity.name.namespace | |
push: references | |
- match: '^(Removing Unused input sections).+$' | |
captures: | |
1: entity.name.namespace | |
push: remove_comments | |
- match: '^Image Symbol Table$' | |
scope: entity.name.namespace | |
push: symbol_table | |
- match: '^Memory Map.+$' | |
scope: entity.name.namespace | |
push: memory_map | |
- match: '^Image component sizes.*$' | |
scope: entity.name.namespace | |
push: component_sizes | |
references: | |
- include: symbol_ref | |
- match: \brefers\b | |
scope: keyword.operator.word | |
- match: \bto\b | |
scope: keyword.operator.word | |
- match: \bfor\b | |
scope: keyword.operator.word | |
- match: '{{func_name}}' | |
scope: string | |
- match: '^=+$' | |
scope: comment.line | |
pop: true | |
symbol_ref: | |
- match: '{{obj_file}}' | |
scope: variable.other.constant | |
push: | |
- match: '\(({{symbol_ref}})\)' | |
captures: | |
1: variable.parameter | |
pop: true | |
remove_comments: | |
- match: 'Removing.+$' | |
scope: comment.block | |
- match: '=+$' | |
scope: comment.line | |
pop: true | |
symbol_table: | |
- match: '^ *{{one_spc_name}}$' | |
scope: entity.name.section | |
- include: table_header | |
- match: '^ *(({{symbol_ref}})|({{file_path}})|(!!!?\w+)) + | |
({{hex}}) +(([a-zA-Z\.\(\)]+ ?)+) {2,}({{number}}) {2,}(\S+)( \S+)?$' | |
captures: | |
2: entity.name.class | |
3: entity.name.class | |
4: keyword.important | |
5: constant.numeric.hex | |
6: storage.type | |
8: constant.numeric.integer | |
9: entity.name.class | |
10: variable.parameter | |
- match: '^=+$' | |
scope: comment.line | |
pop: true | |
memory_map: | |
- match: '^(\s*\w+ Region \w+) *\(.+\)$' | |
captures: | |
1: entity.name.section | |
- include: table_header | |
- match: '^ *({{hex}}) +({{hex}}) +(\S+) +(\S+) + | |
({{number}}) +(\*? +)(\S+) +(\S+) *$' | |
captures: | |
1: constant.numeric.hex | |
2: constant.numeric.hex | |
3: storage.type | |
4: entity.other.attribute-name | |
5: constant.numeric.integer | |
7: variable.parameter | |
8: entity.name.class | |
- match: ' *({{hex}}) +({{hex}}) +(\S+) *$' | |
captures: | |
1: constant.numeric.hex | |
2: constant.numeric.hex | |
3: storage.type | |
- match: '^=+$' | |
scope: comment.line | |
pop: true | |
component_sizes: | |
- include: image_size_section | |
- match: '=+$' | |
scope: comment.line | |
push: tail_2 | |
image_size_section: | |
- include: table_header | |
- match: ' *({{number}}) +({{number}}) +({{number}}) + | |
({{number}}) +({{number}}) +({{number}}) +' | |
captures: | |
1: constant.numeric.integer | |
2: constant.numeric.integer | |
3: constant.numeric.integer | |
4: constant.numeric.integer | |
5: constant.numeric.integer | |
6: constant.numeric.integer | |
push: | |
- match: '{{obj_file}} *$' | |
scope: entity.name.class | |
pop: true | |
- match: '.+$' | |
scope: entity.name | |
pop: true | |
- match: ' *-+$' | |
scope: comment.line | |
table_header: | |
- match: '^ *({{one_spc_name}}( {2,})?)+$' | |
scope: entity.name.struct | |
tail_2: | |
- include: image_size_section | |
- match: '^=+$' | |
scope: comment.line | |
push: tail_1 | |
tail_1: | |
- match: '^ *(Total +\w+ +Size)[\([a-zA-Z]\+\) ]+ | |
({{number}}) *\( *([0-9\.]+\wB) *\)$' | |
captures: | |
1: keyword.summary | |
2: keyword.number | |
3: keyword.number | |
- match: '^=+$' | |
scope: comment.line | |
pop: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment