Sublime Forum

Regular Expression Macro's

#1

I’m currently working on a language plugin for the Forth programming language. I kind of mostly have the syntax highlighting for this completed, just a few tidy ups to do. I hope to eventually be able to add what codewright called code sense (how the editor recognized functions/variables) so that goto anything will work for Forth too.

However, hers my “issue”?

My syntax file has a lot of repeated regular expressions. For example, almost every single match entry is preceded by (?<=\s) and ends with (?=\s). I.E. a Forth function (called a word) can start at the beginning of a line or after a space and the end of the definitions name can be coincident with an end of line or a space.

Would it somehow be possible to plug those two regular expressions (and others) into a snippet and refer to them by name within my Forth.tmLanguage file?

0 Likes

#2

AFAIK we cannot reference snippets in language files, or even other variables.

Mmm I wonder if if recognises $SELECTION…? I doubt it…

0 Likes

#3

it wouldnt have to be a snippet exatly i used the term snippet in the english context not the sublime context :smile:

i have a file that contains a macro defnitions for various regular expression as follows maybe…

start =&lt;=^|\s
end = &gt=\s|^

or maybe they are in the language file itself with macro start= or i have macrofile= or both?

Now in my language definition file all i have to do is

  match=($start)(obfuscated stuff here)($end)

and i when this language file is loaded the macros are expanded.

0 Likes