I have to write a syntax highligthing script for a new language. And
there is a great difficulty :
You have to recognize identifiers with this regex : "[a-z][a-z0-9_]*"
the difficulty resides in the fact that :
- You have two kind of identifiers : global and local
- All global identifiers have to be colored
- All local identifiers, and their occurences have NOT to be colored
- All global identifiers recognized within a function body have to be
colored *
There is an example written in this new language called Lisaac (http://
www.lisaac.org).
Please take care of comment to understand my problem :
Section Header
+ name := FILE_SYSTEM;
- copyright := "2003-2005 Jérome Boutet, 2003-2007 Benoit
Sonntag";
- comment := "File System manager for Unix.";
- external := `#include <unistd.h>`;
// In the above code "name", "copyright", "comment" and "external"
have to be colored
Section Inherit
// "parent_directory" has to be colored
+ parent_directory:DIRECTORY <-
(
// "cwd" and "result" have NOT to be colored because they are local
declaration
+ cwd:NATIVE_ARRAY(CHARACTER);
+ result:DIRECTORY;
// In the above code all occurences of "cwd" and "result" have NOT to
be colored because they have a local declaration
DIRECTORY.string_tmp.clear;
cwd := DIRECTORY.string_tmp.to_external;
`getcwd(@cwd,255)`;
DIRECTORY.string_tmp.from_external cwd;
result ?= DIRECTORY_UNIX.physical_get_entry
(DIRECTORY.string_tmp);
DIRECTORY.alias.put result to (result.path);
? {result != NULL};
// "parent_directory" have to be colored be cause it has a global
declaration in the above code
parent_directory := result // Parent is a data now!
);
So you see that all theses identifiers matches the regex but they have
or have not to be colored depending
on their declaration context
The use of a function like emacs permit us to handle each identifiers
differently depending on its context.
So i have no idea to achieve this feature !