- String fileName = path+(String)stringifyChildren(t.child(0));
- try {
- String newPrefix = (String)walk(t.child(1));
- if (newPrefix.length() > 0) newPrefix += ".";
- FileInputStream fis = new FileInputStream(fileName);
- Tree tr = new CharParser(MetaGrammar.newInstance()).parse(fis).expand1();
- return (GrammarNode)new GrammarBuilder(path, newPrefix).walk(tr);
- } catch (Exception e) {
- throw new RuntimeException("while parsing " + fileName, e);
+ String fileName = (String)stringifyChildren(t.child(0));
+ for(File f : includes) {
+ File file = new File(f.getAbsolutePath()+File.separatorChar+fileName);
+ if (!file.exists()) continue;
+ try {
+ String newPrefix = (String)walk(t.child(1));
+ if (newPrefix.length() > 0) newPrefix += ".";
+ FileInputStream fis = new FileInputStream(file);
+ Tree tr = new CharParser(MetaGrammar.newInstance()).parse(fis).expand1();
+ return (GrammarNode)new GrammarBuilder(includes, newPrefix).walk(tr);
+ } catch (Exception e) {
+ throw new RuntimeException("while parsing " + file, e);
+ }