[antlr-interest] Path for tokenVocab

David Holroyd dave at badgers-in-foil.co.uk
Mon Aug 13 14:01:31 PDT 2007


In a multi-grammar project, I might have grammars under,

  org/example/SomeGrammar.g
  com/bigcorp/OtherGrammar.g

They are located in folders like this so that their folder structure
matches the package structure for the generated classes (i.e.
org.example.SomeGrammarParser and com.bigcorp.OtherGrammarParser).

However, I need to use the 'tokenVocab' option in OtherGrammar.g to get
at SomeGrammar.g's token definitions.  The difficulty is that in order
to set the '-lib' option to a reasonable value to find SomeGrammar.tokens
when processing OtherGrammar.g, the build tool will need to do some
fairly fiddly path munging, or the user will have to explicitly tell the
build tool to look in 'org/example' (and a good build tool should just
know these things, really).

The generated files all get put under the folder
target/generated-sources/antlr, so it super easy for the build tool to
set the option "-lib target/generated-sources/antlr".  However the
folder structure created there matches the folder structure of the
source grammars, i.e.

  target/generated-sources/antlr/org/example/SomeGrammar.*
  target/generated-sources/antlr/com/bigcorp/OtherGrammar.*

so this isn't enough on its own.


So, it would be *really* nice if the tokenVocab option value could take
a 'package prefix',

e.g.
  tokenVocab=org/example/SomeGrammar;
or
  tokenVocab=org.example.SomeGrammar;


Is a change like this possible?  Should I try to implement it?



thanks!
dave

-- 
http://david.holroyd.me.uk/


More information about the antlr-interest mailing list