Author Topic: Adding new language support  (Read 5893 times)

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Adding new language support
« on: January 14, 2009, 05:01:36 PM »
Hello,

Since my new language is quite basic-like, I was hoping to expedite the process of adding support by copying vbscript.e to basicLike.e, and adjusting as necessary.  I have also copied the VB section from vslick.vlx into basicLike.vlx, and load that in basicLike.e.

Generally, the support is working; I have removed support for tokens my language doesn't have, and added tokens my language does.
However, I have run in to a problem with 'Define', as in:

Define monster 666

I have added 'Global' as a keyword for a variable, and those variables are getting tagged.
Global witch as String

I can't figure out how to get 'Define' tokens recognized, though.  I suspect that 'define' already has some sort of meaning in vbscript.e, but I can't figure out where it is used.

Any help would be appreciated...

UPDATE:
I think the problem is in lang_proc_search():
         _str signature_re='[ \t]*([(]{#1[^)]*}[)_][ \t]*|)(as[ \t]*{#2'variable_re'}|=|$)';

I suspect I have to accommodate, in this regex, the 'define' syntax.

UPDATE_2:
Attempt to make the 'as' optional:

#define LANG_WORD_CHARS  'a-zA-Z0-9_$'

         _str signature_re='[ \t]*([(]{#1[^)]*}[)_][ \t]*|)((as[ \t]*{#2'variable_re'}|=|$)|([ \t]*['LANG_WORD_CHARS']*))';

This tags correctly:
Define Move 1
Sub Move()

but does not tag:
Define Move_To  1
Sub Move_To()

In the Defs toolbar,
Define IDS_STRING_1   1
appears as:
IDS
« Last Edit: January 14, 2009, 07:01:33 PM by Wanderer »

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: Adding new language support
« Reply #1 on: January 14, 2009, 10:03:27 PM »
It would appear that your 'variable_re' is not matching underscore.  Have you changed VBS_WORD_CHARS or variable_re?  In VBScript, underscore can be a line continuation.
« Last Edit: January 14, 2009, 10:05:19 PM by Dennis »

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Adding new language support
« Reply #2 on: January 14, 2009, 10:23:36 PM »
It seems I did corrupt variable_re somehow; when I restored it from vbscript.e, my modified signature_re seems to be working as desired.

However, I am not getting tagging of local variables, and can't figure out why; local variables are tagged in a .vb file.

Thanks for the reply.  Having this language support -- particularly context tagging -- is very handy.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: Adding new language support
« Reply #3 on: January 16, 2009, 06:55:54 PM »
However, I am not getting tagging of local variables, and can't figure out why; local variables are tagged in a .vb file.

Ack.  It appears 'Dim' statements are not being tagged...

Dennis

  • Senior Community Member
  • Posts: 3954
  • Hero Points: 515
Re: Adding new language support
« Reply #4 on: January 20, 2009, 09:04:59 PM »
Local variable tagging requires a different callback.  The way tagging works, is we gather basic global symbol information using either a simple proc_search callback, like we have for vbscript, or a list_tags callback, like we do for higher tier languages, such as visual basic or C++.  Local variable tagging is done through a list_locals callback.  Generally, we only do this for languages that have a proc_search, where we can really, reliable determine the context that we are trying to local local variables in.