The language I'm currently implementing contains import constructs. So far
I've used the standard import implementation from the ANTLR wiki which goes:

import: 'import' moduleId -> 'import' moduleId ^( {
parseFile($moduleId.path) } ) ;

However this implementation will hang on circular dependancies and reduce my
parser performance when having multiple imports to the same module. So I
decided to keep a list of all the modules I've parsed so far, meaning I only
have to parse each module once. This has resulted in the following
implementation:

imprt: 'import' moduleId {
if(! modules.contains($moduleId.path)) {
Object dependancy = adaptor.becomeRoot(parseFile($moduleId.path), (Object)
adaptor.nil());
adaptor.addChild(root_0, dependancy);
}
}

@member { CommonTree parseFile(String path) { ... } }

The implementation works, however I would like a cleaner solution,
preferably using a rewrite rule. Any suggestions?

Thanks in advance!
Jeroen

--~--~---------~--~----~------------~-------~--~----~
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