- public static Tree help0(String grammarFile, String targetFile) throws Throwable {
- try {
- Tree<String> res = new CharParser(MetaGrammar.newInstance()).parse(new FileInputStream(grammarFile)).expand1();
- Union meta = Grammar.create(res, "s" /*,
- new Grammar.Bindings() {
- public Sequence createSequence(Production p) {
- Element[] els = p.elements;
- if (p.tag != null)
- return Sequence.create(p.tag, p.elements, p.drops, false);
- int idx = -1;
- for(int i=0; i<els.length; i++)
- if (!p.drops[i])
- if (idx==-1) idx = i;
- else return Sequence.create(p.nonTerminal, p.elements, p.drops, false);
- if (idx != -1) return Sequence.create(els, idx);
- else return Sequence.create(els, "");
- }
-
- }*/);
- System.out.println();
- System.out.println();
- CharInput input = new CharInput(new FileInputStream(targetFile), "", true);
- //Input input = new Tib(new FileInputStream(targetFile));
- Tree ret = new CharParser(meta).parse(input).expand1();
- if (ret==null) throw new NullPointerException("CharParser returned null");
- return ret;
- } catch (Throwable e) {
- e.printStackTrace();
- throw e;
- }
- }