Home Download Buy Blog Forum Support

Regular Expression Macro's

Regular Expression Macro's

Postby mark4 on Fri Dec 14, 2012 11:05 pm

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?
mark4
 
Posts: 98
Joined: Sat Feb 11, 2012 3:33 am

Re: Regular Expression Macro's

Postby agibsonsw on Sat Dec 15, 2012 3:51 pm

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

Mmm I wonder if if recognises $SELECTION..? I doubt it..
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Regular Expression Macro's

Postby mark4 on Sat Dec 15, 2012 7:21 pm

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

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

Code: Select all
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
Code: Select all
  match=($start)(obfuscated stuff here)($end)


and i when this language file is loaded the macros are expanded.
mark4
 
Posts: 98
Joined: Sat Feb 11, 2012 3:33 am


Return to Technical Support

Who is online

Users browsing this forum: Alexa [Bot], Exabot [Bot], Google [Bot] and 21 guests