From c35211231148fca7522c3e0a766b87b9b9717f5d Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Tue, 25 Oct 2016 19:37:00 +0200 Subject: [PATCH 1/6] Add support for "SINUMERIK 840D language support" package. --- bh_core.sublime-settings | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bh_core.sublime-settings b/bh_core.sublime-settings index 9d3b8c65..49ce8cc1 100755 --- a/bh_core.sublime-settings +++ b/bh_core.sublime-settings @@ -559,6 +559,26 @@ "language_filter": "whitelist", "language_list": ["CMake"], "enabled": true + }, + // SINUMERIK 840D SL G-Code + { + "name": "s840d_gcode", + "open": "(?i)\\b(IF(?!.*GOTO)|FOR|WHILE|REPEAT(?!.*GOTO))\\b", + "close": "(?i)\\b(END(?:IF|FOR|WHILE)|UNTIL)\\b", + "style": "tag", + "language_filter": "whitelist", + "language_list": ["s840d_gcode"], + "enabled": true + }, + // SINUMERIK 840D SL RunMyHmi + { + "name": "s840d_hmi_method", + "open": "(?i)^\\s*(ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB)\\b", + "close": "(?i)^\\s*(END_(?:ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB))\\b", + "style": "tag", + "language_filter": "whitelist", + "language_list": ["s840d_hmi"], + "enabled": true } ], From 6724cefc02017b8035a297f107d209afc086761e Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 26 Oct 2016 19:36:44 +0200 Subject: [PATCH 2/6] Add bh_modules for matching of opening and closing tags for "CNC SINUMERIK 840D language support" --- bh_core.sublime-settings | 12 +++++++----- bh_modules/s840d_gcode.py | 19 +++++++++++++++++++ bh_modules/s840d_hmi.py | 22 ++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 bh_modules/s840d_gcode.py create mode 100644 bh_modules/s840d_hmi.py diff --git a/bh_core.sublime-settings b/bh_core.sublime-settings index 49ce8cc1..165231ab 100755 --- a/bh_core.sublime-settings +++ b/bh_core.sublime-settings @@ -563,19 +563,21 @@ // SINUMERIK 840D SL G-Code { "name": "s840d_gcode", - "open": "(?i)\\b(IF(?!.*GOTO)|FOR|WHILE|REPEAT(?!.*GOTO))\\b", - "close": "(?i)\\b(END(?:IF|FOR|WHILE)|UNTIL)\\b", + "open": "\\b(IF(?!.*GOTO)|FOR|WHILE|REPEAT(?!.*GOTO))\\b", + "close": "\\b(END(?:IF|FOR|WHILE)|UNTIL)\\b", "style": "tag", + "plugin_library": "bh_modules.s840d_gcode", "language_filter": "whitelist", "language_list": ["s840d_gcode"], "enabled": true }, // SINUMERIK 840D SL RunMyHmi { - "name": "s840d_hmi_method", - "open": "(?i)^\\s*(ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB)\\b", - "close": "(?i)^\\s*(END_(?:ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB))\\b", + "name": "s840d_hmi", + "open": "^\\s*(//[ABGMS]|ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB)\\b", + "close": "^\\s*(//END|END_(?:ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB))\\b", "style": "tag", + "plugin_library": "bh_modules.s840d_hmi", "language_filter": "whitelist", "language_list": ["s840d_hmi"], "enabled": true diff --git a/bh_modules/s840d_gcode.py b/bh_modules/s840d_gcode.py new file mode 100644 index 00000000..f91efcfd --- /dev/null +++ b/bh_modules/s840d_gcode.py @@ -0,0 +1,19 @@ +""" +BracketHighlighter. + +Copyright (c) 2013 - 2016 Deathaxe +License: MIT +""" + +def compare(name, first, second, bfr): + """Ensure correct open is paired with correct close.""" + + o = bfr[first.begin:first.end].lower() + c = bfr[second.begin:second.end].lower() + + match = False + if o == "repeat" and c == "until": + match = True + elif c == "end" + o: + match = True + return match diff --git a/bh_modules/s840d_hmi.py b/bh_modules/s840d_hmi.py new file mode 100644 index 00000000..c5fdf568 --- /dev/null +++ b/bh_modules/s840d_hmi.py @@ -0,0 +1,22 @@ +""" +BracketHighlighter. + +Copyright (c) 2013 - 2016 Deathaxe +License: MIT +""" + +def compare(name, first, second, bfr): + """Ensure correct open is paired with correct close.""" + + o = bfr[first.begin:first.end].lower() + c = bfr[second.begin:second.end].lower() + + match = False + # classes + if o in ["//a", "//b", "//g", "//m", "//s"] and c == "//end": + match = True + # methods + elif c == "end_" + o: + match = True + return match + From 9ca5c88371e8e46853408cf1a3d978180116fc3f Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 26 Oct 2016 19:42:34 +0200 Subject: [PATCH 3/6] Satisfy coding style guidelines for bh_modules of "CNC SINUMERIK 840D language support" package --- bh_modules/s840d_gcode.py | 1 + bh_modules/s840d_hmi.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bh_modules/s840d_gcode.py b/bh_modules/s840d_gcode.py index f91efcfd..042e3b5a 100644 --- a/bh_modules/s840d_gcode.py +++ b/bh_modules/s840d_gcode.py @@ -5,6 +5,7 @@ License: MIT """ + def compare(name, first, second, bfr): """Ensure correct open is paired with correct close.""" diff --git a/bh_modules/s840d_hmi.py b/bh_modules/s840d_hmi.py index c5fdf568..78d8685e 100644 --- a/bh_modules/s840d_hmi.py +++ b/bh_modules/s840d_hmi.py @@ -5,6 +5,7 @@ License: MIT """ + def compare(name, first, second, bfr): """Ensure correct open is paired with correct close.""" @@ -19,4 +20,3 @@ def compare(name, first, second, bfr): elif c == "end_" + o: match = True return match - From baaab5eefd5fcdc94b10270b1f59a18c7ce7c2d7 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Wed, 26 Oct 2016 20:27:45 +0200 Subject: [PATCH 4/6] Exclude "string" and "comment" scope from matching tags for "CNC SINUMERIK 840D language support" package --- bh_core.sublime-settings | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bh_core.sublime-settings b/bh_core.sublime-settings index 165231ab..f66e05d6 100755 --- a/bh_core.sublime-settings +++ b/bh_core.sublime-settings @@ -566,6 +566,7 @@ "open": "\\b(IF(?!.*GOTO)|FOR|WHILE|REPEAT(?!.*GOTO))\\b", "close": "\\b(END(?:IF|FOR|WHILE)|UNTIL)\\b", "style": "tag", + "scope_exclude": ["string", "comment"], "plugin_library": "bh_modules.s840d_gcode", "language_filter": "whitelist", "language_list": ["s840d_gcode"], @@ -577,6 +578,7 @@ "open": "^\\s*(//[ABGMS]|ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB)\\b", "close": "^\\s*(//END|END_(?:ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB))\\b", "style": "tag", + "scope_exclude": ["string", "comment"], "plugin_library": "bh_modules.s840d_hmi", "language_filter": "whitelist", "language_list": ["s840d_hmi"], From 6efb75d3931b857854c00605487dbc4fdb15e475 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 27 Oct 2016 18:28:51 +0200 Subject: [PATCH 5/6] Use static tubles for keyword lists in bh_modules. --- bh_modules/bashsupport.py | 5 ++++- bh_modules/s840d_hmi.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bh_modules/bashsupport.py b/bh_modules/bashsupport.py index b05d1396..58b86da3 100644 --- a/bh_modules/bashsupport.py +++ b/bh_modules/bashsupport.py @@ -8,6 +8,9 @@ lowercase = import_module("bh_modules.lowercase") +BASH_KEYWORDS = ("select", "for", "while", "until") + + def validate(*args): """Check if bracket is lowercase.""" return lowercase.validate(*args) @@ -22,7 +25,7 @@ def compare(name, first, second, bfr): match = False if o == "if" and c == "fi": match = True - elif o in ["select", "for", "while", "until"] and c == "done": + elif o in BASH_KEYWORDS and c == "done": match = True elif o == "case" and c == "esac": match = True diff --git a/bh_modules/s840d_hmi.py b/bh_modules/s840d_hmi.py index 78d8685e..0b1ee405 100644 --- a/bh_modules/s840d_hmi.py +++ b/bh_modules/s840d_hmi.py @@ -6,6 +6,9 @@ """ +S840D_HMI_CLASSES = ("//a", "//b", "//g", "//m", "//s") + + def compare(name, first, second, bfr): """Ensure correct open is paired with correct close.""" @@ -14,7 +17,7 @@ def compare(name, first, second, bfr): match = False # classes - if o in ["//a", "//b", "//g", "//m", "//s"] and c == "//end": + if o in S840D_HMI_CLASSES and c == "//end": match = True # methods elif c == "end_" + o: From 173da651c47a2af2c19a3fcd5d79e517a577410c Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Thu, 27 Oct 2016 20:03:16 +0200 Subject: [PATCH 6/6] Remove unneeded blank lines in bh_modules to satisfy the coding style guidelines. --- bh_modules/bashsupport.py | 1 - bh_modules/s840d_hmi.py | 1 - 2 files changed, 2 deletions(-) diff --git a/bh_modules/bashsupport.py b/bh_modules/bashsupport.py index 58b86da3..ba07aa1a 100644 --- a/bh_modules/bashsupport.py +++ b/bh_modules/bashsupport.py @@ -7,7 +7,6 @@ from BracketHighlighter.bh_plugin import import_module lowercase = import_module("bh_modules.lowercase") - BASH_KEYWORDS = ("select", "for", "while", "until") diff --git a/bh_modules/s840d_hmi.py b/bh_modules/s840d_hmi.py index 0b1ee405..8f47c05a 100644 --- a/bh_modules/s840d_hmi.py +++ b/bh_modules/s840d_hmi.py @@ -5,7 +5,6 @@ License: MIT """ - S840D_HMI_CLASSES = ("//a", "//b", "//g", "//m", "//s")