There are a large number of ways to implement what you want and the devil is in 
the details. I will assume that you will be dealing with a file system similar 
to that on Window's/Linux/Mac and not an embedded system, or an old style 
mainframe with an unusual file system.

Your implementation will need a small library of routines to automatically 
traverse directories, find source code files, and read them. If you have an IDE 
the code should also automatically time stamps of  files to check whether they 
have been modified since the last time they were processed and reprocess them 
if necessary. In the long run in addition to source code files you may also 
want byte code files or other compressed forms of the source code files that 
are quicker to process. 

You will need to provide a means of defining the search path for the code. All 
of the following is possible
1. A tree based on the file location of your processor. This is typically where 
the language defined code is located (though some of the language defined 
"imports" are often implemented directly in the processor than as external code 
as this can allow additional optimizations and error reporting)
2. The directory or a tree based on the directory where you invoke your 
processor. If you have an IDE this might be changed dynamically through change 
directories calls.
3. directories or trees passed in through the command line
4. directories specified on the prompt of an IDE
5. paths specified in a preferences database file. A preferences file should be 
a high priority item.
6. paths specified through system variables. System variables are over used and 
awkward to change so I suggest using one only to specify the path to the 
database file. 
7. Normally your users will want all of the above, but I suggest start with the 
tree based on your processor then implement the preferences file.

You will need to define a default mapping of the language identifiers: 
functions, procedures, modules, classes, etc, to file and/or directory names. 
You will also in the long run want a language defined means of overriding that 
default in case of naming conflicts.

You will need to define the order in which you search the file space of the 
files of interest. Some implementations stop when they find a file whose name 
is compatible with the desired file. I find that that can hide naming conflicts 
and unintentionally result in the wrong file being called. I suggest you search 
the entire file tree at the start and always report any conflicts.

On Dec 16, 2009, at 4:52 AM, Bujji wrote:

> Hi all 
> 
> how to implement import statement (like in python: import sys) using 
> antlr grammar 
> i have got syntax recognition in examples but how the action should be 
> performed. 
> 
> how the language is able to find that that file is there or not in the 
> library 
> 
> any clues ? 
> 
> help me 
> 
> Thanks in advance 
> 
> Siva 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: 
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--

You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to