[antlr-interest] Novice

Behdad Forghani behdad.forghani at samsarasol.com
Wed Jul 8 13:08:44 PDT 2009


It depends on the language.


In my case, the dependencies would be circular and it was possible that 
the two modules referenced each other. What I did was, I parsed each 
module separately, made a hash table of modules and their identifier. In 
the second pass, I imported the symbols from modules that was imported 
into the hash table of the importing module and then issued errors if 
the references could not been resolved.

This does not work, if you want to do type checking on the fly, or in 
case of C imports that you need to know the type identifiers before hand.


---
Hello,

Currently I'm working on the implementation of a mark-up DSL using ANTLR.
This language makes use of module definitions and import constructs. What
would be the optimal approach to loading contents of dependent modules in my
AST?

The parser grammar is as follows:
module:         'module' moduleId ( imprt | site | function )* 'end' EOF ;
moduleId:      IDENTIFIER ( '.' IDENTIFIER )* ;
imprt:             'import' moduleId ';' ;

Thanks in advance!
Jeroen


More information about the antlr-interest mailing list