1 31 32 package org.antlr.works.grammar; 33 34 import org.antlr.works.components.grammar.CEditorGrammar; 35 import org.antlr.works.utils.Console; 36 import org.antlr.works.utils.ErrorListener; 37 38 public class CheckGrammar implements Runnable { 39 40 protected CheckGrammarDelegate delegate; 41 protected CEditorGrammar editor; 42 43 public CheckGrammar(CEditorGrammar editor, CheckGrammarDelegate delegate) { 44 this.editor = editor; 45 this.delegate = delegate; 46 } 47 48 public void check() { 49 new Thread (this).start(); 50 } 51 52 public void cancel() { 53 editor.getEngineGrammar().cancel(); 54 } 55 56 public void run() { 57 editor.getConsole().setMode(Console.MODE_VERBOSE); 58 ErrorListener.shared().clear(); 59 ErrorListener.shared().setPrintToConsole(true); 60 61 delegate.checkGrammarDidBegin(); 62 try { 63 editor.getEngineGrammar().analyze(); 64 } catch (Exception e) { 65 editor.getConsole().print(e); 66 } 67 delegate.checkGrammarDidEnd(ErrorListener.shared().getFirstErrorMessage()); 68 } 69 70 } 71 | Popular Tags |