facelessuser / BracketHighlighter

Bracket and tag highlighter for Sublime Text
https://facelessuser.github.io/BracketHighlighter/
1.75k stars 244 forks source link

Failing on IF...ENDIF in `SINUMERIK 840D SL RunMyHmi` scope #637

Open ramooon1 opened 3 hours ago

ramooon1 commented 3 hours ago

Description

For SINUMERIK 840D SL RunMyHmi scope BH is unable to match end tag if IF-condition is used in a code.

image image Working if it is out its scope. image

Without IF it is working fine: image

Proposal

Regex for open/close for SINUMERIK 840D SL RunMyHmi: There is no END_IF in this syntax. Therefore, the first thing I tried to do was to change that - unfortunately, no success. I also added some minor improvements.

{
            "name": "s840d_hmi",
            "open": "(?i)(?:^ *)(//[ABGMS]|ACTIVATE|CHANGE|FOCUS|IF|LOAD|UNLOAD|OUTPUT|PRESS|SUB)\\b",
            "close": "(?i)(?:^ *)(//END|\\bEND_(?:ACTIVATE|CHANGE|FOCUS|LOAD|UNLOAD|OUTPUT|PRESS|SUB)|ENDIF)\\b",
            "style": "tag",
            "scope_exclude": ["string", "comment"],
            "plugin_library": "bh_modules.s840d_hmi",
            "language_filter": "allowlist",
            "language_list": ["s840d_hmi"],
            "enabled": true,
}

Support Info

facelessuser commented 3 hours ago

@ramooon1 It sounds like the IF rule should get fixed, not removed. Can you provide a copy/pastable code sample for testing? I do not use this language and I have no interested transcribing the example from a photo.

ramooon1 commented 3 hours ago

@facelessuser I just removed IF from non-capturing group of close member and added ENDIF to the end of regex because of END_.

Here is a code for this language (with IF):

//M(WsW_or_WsRaus/"Move Z-Axis to Softlimit"/ /30,10///)
   DEF info    =(S///"","Werkstück wechseln oder Werkstück raus ?"," "/WR1,FS2/ /""/20,50,500/,,/)  
   DEF infoJa  =(S///"","Wechseln:    Werkstück gegebenenfalls entladen und aus Beladestation beladen"," "/WR1/ /""/80,180,500/,,/)  
   DEF infoNein=(S///"","Entladen:    Werkstück aus der Maschine zur Beladestation"                  ," ",/WR1/ /""/80,220,500/,,/)  

   vs7=("wechseln",,Se1) 
   vs8=("entladen",,Se1) 

   LOAD  
   END_LOAD

   PRESS(VS7)
      IF true
         DLGL("asdf")
      ENDIF
      wnp("$R[7]",1)
      exit 
   END_PRESS

   PRESS(VS8)
      wnp("$R[7]",2)
      exit 
   END_PRESS
//END
facelessuser commented 3 hours ago

If you already have a solution, you can issue a pull request.

ramooon1 commented 2 hours ago

It's not a solution, with this regex I'm able to find every  ENDIF e.g. python. But it doesn't work with BH.--Mit freundlichen Grüßen / Best regardsRoman Bondarenko Von: Isaac Muse @.>Gesendet: Donnerstag, Oktober 24, 2024 6:28:23 PMAn: facelessuser/BracketHighlighter @.>Cc: ramooon1 @.>; Mention @.>Betreff: Re: [facelessuser/BracketHighlighter] Failing on IF...ENDIF in SINUMERIK 840D SL RunMyHmi scope (Issue #637) If you already have a solution, you can issue a pull request.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

facelessuser commented 1 hour ago

Alright, I'll take a look sometime soon.