[antlr-interest] ANTLR Eclipse plugin newsgroup

Brannon King brannonking at yahoo.com
Fri Dec 23 10:05:18 PST 2005


Schweet. Now that my email system is working right, I can continue a
conversation from yesterday though I am going to have to start a new thread
because of my new address.

First, I'm not sure this is the right place to discuss ANTLR-Eclipse
projects or integration. If not here, where? It appears that the
ANTLREclipse plugin forum on Sourceforge only gets used on rare occasions.

Second, contrary to Scott's posting yesterday that states that ANTLREclipse
uses the ANTLR lexer/parser for syntax highlighting, it does not. I have the
AntlrCodeScanner.java in front of me, and I assure you that it does syntax
highlighting using the same methods as the other Eclipse plugins I've seen:
it uses a list of keywords. I pulled the file from the SourceForge
yesterday. It is possible that I did not get the right file, though the same
(or similar) file is in org.antlr.eclipse.ui_4.0.0.b2 in my Eclipse plugins
folder.

I cannot see that it does on-the-fly syntax markers either (and I don't
think I've seen any show up during my editing), though it can quite easily
be done with code like the following:

 this(lexer, 2);
 this.file = ((IFileEditorInput)editor.getEditorInput()).getFile();
 this.editor = editor;
 this.doc = doc;
public void reportError(RecognitionException ex) 
{
  try 
  {
    file.deleteMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
  } 
  catch (CoreException e1) 
  {
    e1.printStackTrace();
  }
  Map attributes = new HashMap();
  int line = ex.getLine()-1;
  MarkerUtilities.setMessage(attributes, ex.getMessage());
  MarkerUtilities.setLineNumber(attributes, line);
  try 
  {
    int offset = doc.getLineOffset(line);
    MarkerUtilities.setCharStart(attributes, offset);
    MarkerUtilities.setCharEnd(attributes, offset + ex.getColumn()+6);
    attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
    MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);
  } 
  catch (BadLocationException e) 
  {
    e.printStackTrace();
  }
  catch (CoreException x) 
  {
    x.printStackTrace();
  }
}





More information about the antlr-interest mailing list