hightlight syntax problem

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

hightlight syntax problem

Ni Va
Hi all,

Considering this kind of line:

      SPB   ERR2; 



With in my syntax file these syntax pattern recognition:

syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/
syn match s7JumpsLabel         /^\(\s\+SPB\s\+\)\zs\([^;]\+\)\ze;/

HiLink s7JumpsOperand        JumpsColorDarkRed
HiLink s7JumpsLabel             JumpsColorDarkRed



Why it highlights only first SPB Operand and no ERR2 like that ?

      SPB   ERR2; 


Thank you

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/dd52a334-200f-4d48-b754-c1dd4c68de76%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: hightlight syntax problem

Christian Brabandt

On Mo, 02 Dez 2019, Ni Va wrote:

> Hi all,
>
> Considering this kind of line:
>
>       SPB   ERR2; 
>
>
>
> With in my syntax file these syntax pattern recognition:
>
> syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|
> SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/
> syn match s7JumpsLabel         /^\(\s\+SPB\s\+\)\zs\([^;]\+\)\ze;/
>
> HiLink s7JumpsOperand        JumpsColorDarkRed
> HiLink s7JumpsLabel             JumpsColorDarkRed
>
>
>
> Why it highlights only first SPB Operand and no ERR2 like that ?
>
>       SPB   ERR2; 

They both try to match at the same location, because you implicitly
anchored your match. For that kind of thing you can use nextgroup e.g.

:syn match s7JumpsOperand /SPB\ze\s\+/ nextgroup=s7JumpLabel
:syn match s7JumpLabel    /ERR2\ze;$/


Best,
Christian
--
So verblaßt das Abwesende, und eine neue Liebe tritt ein.
                -- Ovid (Liebeskunst)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20191202144822.GB28132%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: hightlight syntax problem

Ni Va
 i tried this 

syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/ nextgroup=s7JumpLabel
syn match s7JumpsLabel      /^\s\+\S\+\s\+\zs\([^;]\+\)\ze;/


It does not highlight second group s7JumLabel because of same location ... how to avoid this ?

Le lundi 2 décembre 2019 15:48:28 UTC+1, Christian Brabandt a écrit :

On Mo, 02 Dez 2019, Ni Va wrote:

> Hi all,
>
> Considering this kind of line:
>
>       SPB   ERR2; 
>
>
>
> With in my syntax file these syntax pattern recognition:
>
> syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|
> SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/
> syn match s7JumpsLabel         /^\(\s\+SPB\s\+\)\zs\([^;]\+\)\ze;/
>
> HiLink s7JumpsOperand        JumpsColorDarkRed
> HiLink s7JumpsLabel             JumpsColorDarkRed
>
>
>
> Why it highlights only first SPB Operand and no ERR2 like that ?
>
>       SPB   ERR2; 

They both try to match at the same location, because you implicitly
anchored your match. For that kind of thing you can use nextgroup e.g.

:syn match s7JumpsOperand /SPB\ze\s\+/ nextgroup=s7JumpLabel
:syn match s7JumpLabel    /ERR2\ze;$/


Best,
Christian
--
So verblaßt das Abwesende, und eine neue Liebe tritt ein.
                -- Ovid (Liebeskunst)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/00ad9c6d-660f-4783-aff7-3d29922e2eb2%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: hightlight syntax problem

Christian Brabandt

On Mo, 02 Dez 2019, Ni Va wrote:

>  i tried this 
>
> syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|
> SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/ nextgroup
> =s7JumpLabel
> syn match s7JumpsLabel      /^\s\+\S\+\s\+\zs\([^;]\+\)\ze;/
>
>
> It does not highlight second group s7JumLabel because of same location ... how
> to avoid this ?

Remove the anchoring at the start of the line for Label group


Mit freundlichen Grüßen
Christian
--
Man verliert die meiste Zeit damit, daß man Zeit gewinnen will.
                -- John Ernst Steinbeck

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20191202151538.GC28132%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: hightlight syntax problem

Ni Va
Tried with 
syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/ nextgroup=s7JumpLabel
syn match s7JumpsLabel      /\s\+\S\+\s\+\zs\([^;]\+\)\ze;/

do that:

Capture.PNG



Le lundi 2 décembre 2019 16:15:43 UTC+1, Christian Brabandt a écrit :

On Mo, 02 Dez 2019, Ni Va wrote:

>  i tried this 
>
> syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|
> SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/ nextgroup
> =s7JumpLabel
> syn match s7JumpsLabel      /^\s\+\S\+\s\+\zs\([^;]\+\)\ze;/
>
>
> It does not highlight second group s7JumLabel because of same location ... how
> to avoid this ?

Remove the anchoring at the start of the line for Label group


Mit freundlichen Grüßen
Christian
--
Man verliert die meiste Zeit damit, daß man Zeit gewinnen will.
                -- John Ernst Steinbeck

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/def55ba9-0832-4ccd-8519-4c29fad806ef%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: hightlight syntax problem

Christian Brabandt

On Mo, 02 Dez 2019, Ni Va wrote:

> Tried with 
> syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|
> SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/ nextgroup
> =s7JumpLabel
> syn match s7JumpsLabel      /\s\+\S\+\s\+\zs\([^;]\+\)\ze;/
>
> do that:

well, also remove the matching from the previous group. s7JumpsOperand
already matched the part before the \zs of the s7Jumpslabel, so why add
it here again? That cannot happen to match.

> Capture.PNG

please do not attach png pictures.

Best,
Christian
--
Selbst ißt der Mann.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20191202153602.GD28132%40256bit.org.
Reply | Threaded
Open this post in threaded view
|

Re: hightlight syntax problem

Ni Va
Effectively,  just want to match and highlight with two colors the two sentence like above:


      SPB _003;

So, the first no need to specify nextgroup I thought:
syn match s7JumpsOperand   /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/

the second has to know if it is preceeded by the first to highlight:
for example: syn match s7JumpsLabels    \(SPBNB\s\+\)\@<=\([^;]\+\)\ze;  but it has same location......


Le lundi 2 décembre 2019 16:36:08 UTC+1, Christian Brabandt a écrit :

On Mo, 02 Dez 2019, Ni Va wrote:

> Tried with 
> syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|
> SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/ nextgroup
> =s7JumpLabel
> syn match s7JumpsLabel      /\s\+\S\+\s\+\zs\([^;]\+\)\ze;/
>
> do that:

well, also remove the matching from the previous group. s7JumpsOperand
already matched the part before the \zs of the s7Jumpslabel, so why add
it here again? That cannot happen to match.

> Capture.PNG

please do not attach png pictures.

Best,
Christian
--
Selbst ißt der Mann.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a4628289-8220-4fc9-bb98-4744fdacb2e0%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: hightlight syntax problem

Ni Va
This seems to work

Capture.PNG

syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/
syn match s7JumpsLabel      /\(SPB\s\+\)\@<=\([^; ]\+\)\ze;/




Le lundi 2 décembre 2019 16:48:10 UTC+1, Ni Va a écrit :
Effectively,  just want to match and highlight with two colors the two sentence like above:


      SPB _003;

So, the first no need to specify nextgroup I thought:
syn match s7JumpsOperand   /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/

the second has to know if it is preceeded by the first to highlight:
for example: syn match s7JumpsLabels    \(SPBNB\s\+\)\@<=\([^;]\+\)\ze;  but it has same location......


Le lundi 2 décembre 2019 16:36:08 UTC+1, Christian Brabandt a écrit :

On Mo, 02 Dez 2019, Ni Va wrote:

> Tried with 
> syn match s7JumpsOperand    /^\s\+\zs\(SPA\|SPL\|SPBNB\|SPBN\|SPBB\|SPB\|SPBI\|
> SPBIN\|SLW\|SPO\|SPS\|SPZ\|SPN\|SPP\|SPM\|SPPZ\|SPMZ\|SPU\|LOOP\)\ze/ nextgroup
> =s7JumpLabel
> syn match s7JumpsLabel      /\s\+\S\+\s\+\zs\([^;]\+\)\ze;/
>
> do that:

well, also remove the matching from the previous group. s7JumpsOperand
already matched the part before the \zs of the s7Jumpslabel, so why add
it here again? That cannot happen to match.

> Capture.PNG

please do not attach png pictures.

Best,
Christian
--
Selbst ißt der Mann.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/86e7c540-3091-405a-a37b-ee669bf8dab9%40googlegroups.com.