Trouble creating a CLM

124 views
Skip to first unread message

Joaquin Adiego

unread,
Jan 14, 2024, 12:59:54 PM1/14/24
to BBEdit Talk
Hi,

I'm developing a codeless language module for Boriel ZX Basic. Everything works fine except the labels (which can be the old Basic line numbers, at the beginning of the line, or an identifier ending with ':' also at the beginning of a line).  I have used regular expressions to recognize all language elements (see file attached). Numeric tags are recognized well (appearing in green, see the screenshot attached), but text tags are not, recognizing strings that are not at the beginning of a line as tags as well.  The two regular expressions are similar, so I don't understand very well why it works well in one case and doesn't work in the other.  I have tried rewriting the regular expression in different ways but have not been successful, so I deduce that the problem must lie in the module specification, but I am not able to locate it.

Can anyone help me with this?

Regards


Captura de pantalla 2024-01-14 a las 11.17.03.png
BorielBasic.plist

Maarten Sneep

unread,
Jan 14, 2024, 2:09:34 PM1/14/24
to bbe...@googlegroups.com
Hi,

I think you need to anchor the whole expression:

(?x:
^(([a-zA-Z_]{1}[a-zA-Z0-9_]*:)|
([1-9]{1}[0-9]*))
)

(I have not tested this yet).

Maarten

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/cf17d86a-e9dc-4851-bfb3-e82ae386008an%40googlegroups.com.
<Captura de pantalla 2024-01-14 a las 11.17.03.png><BorielBasic.plist>

Joaquin Adiego

unread,
Jan 15, 2024, 11:42:48 AM1/15/24
to BBEdit Talk
Hi Maarten,

Thank you for your kind reply. I have already tested the expression you suggest (I haven't tried that variant yet) and the result is the same. The fact is that it is a bit strange that it works for one subexpression and not for another very similar one.

Regards.

jj

unread,
Jan 15, 2024, 3:17:38 PM1/15/24
to BBEdit Talk
Hi Joaquin,

My guess is that keywords are whitespace separated character runs – they don't contain whitespace.
BBEdit probably chunks the keywords "before" matching against the regular expression chunk by chunk.
For example what your regular expression matches against is the string "label2:", not the whole line. Thus the start of line anchor always applies.

The Numeric Tags appear correctly because they are excluded from the "Number Pattern" not because of the start of line anchor.

I fear that keyword patterns won't let you do what you want. You will have to use the other patterns that are whitespace aware… but there is a limited number of those.

HTH,

Jean Jourdain

Maarten Sneep

unread,
Jan 15, 2024, 3:46:15 PM1/15/24
to bbe...@googlegroups.com
Hi Joaquin,


On 15 Jan 2024, at 16:29, Joaquin Adiego <jad...@gmail.com> wrote:

Hi Maarten,

Thank you for your kind reply. I have already tested the expression you suggest (I haven't tried that variant yet) and the result is the same. The fact is that it is a bit strange that it works for one subexpression and not for another very similar one.

In that case I suggest that you ask support at Bare Bones for help. As jj suggested, this pattern may be used in a different way that requires you to use a different category for this label.

Best,

Maarten.

Joaquin Adiego

unread,
Jan 16, 2024, 10:59:55 AM1/16/24
to BBEdit Talk
Hi,

JJ I think your point is very well taken and explains the behavior. As Maarten comments, I will contact Bare Bones sport explaining the case.

It's the first CLM I'm doing and I seem to have chosen a "unruly" language for it. 😅

Regards.

Reply all
Reply to author
Forward
0 new messages