title: ANTLR - specifying multiple directories to search in for included grammars
body: <p>I am extending an existing open-source project, which already has a very advanced Lexer/Parser/TreeParser in ANTLR. I would like to adhere to the current directory structure, so I created my own directory where I would like to put my new (already written) grammar files. They are importing these three original grammar files and to compile the code, I can use java org.antlr.Tool, where I can specify one directory to search for imported grammars with -lib option argument.</p>
  
  <p>My problem is that these three original imported grammar files have some imports themselves and again in different directory. To illustrate (inheritance/importing going to top):</p>
  
  <pre><code>Abstract syntax directory: lexer           parser           tree parser
  Original syntax directory: lexer           parser           tree parser
  My new   syntax directory: lexer           parser           tree parser
  </code></pre>
  
  <p>This is the hierarchy. The trouble I am encountering is how to specify "Abstract syntax directory" and also "Original syntax directory" at once with the -lib option on the command line for the ANTLR tool (or any other solution which would allow me to compile my grammar importing the original one with the given directories structure).</p>
  
  <p>I tried -lib directory1 directory2, that just appears to ignore the directory2 (and then tries to compile it, which it cannot, because it is a directory, not an ANTLR grammar). I tried specifying "-lib directory1 -lib directory2", the "-lib directory2" just overwrites the "-lib directory1" then.</p>
  
  <p>It is what I believe a fairly basic need to specify multiple directories to search in, in any more complicated system of grammars, therefore I am sure I missed something. I just cannot google anything useful out.</p>
  
  <p>IF you need any more details, I am happy to provide them, it is my master thesis extending an open source project, so I do not need to keep anything secret. :) If it is not possible, I can live without it, but would really like to keep the consistency of the original project.</p>