[antlr-interest] Newbie trying to be more precise about antlr debug problem

Mikael Petterson mikael.petterson at ericsson.com
Sat Aug 2 05:41:29 PDT 2008


I missed the heading:-)

Hi,

Thanks for replying. Well AFAIK ( I am annoyed that I accepted the code
, not given by me, generated by antlr without knowing it complex
implications) the grammar file defined is for recognizing clearcase
output. Depending on what clearcase returns the generated code will an
array of information that the rest of the plugin can interpret. The
problem I have is that I want to see why the parser rule 'error' does
not return anything.

Eg when clearcase returns the following:

cleartool: Error: By default won't create a version identical to
predecessor.

I supposed that the grammar file ( attatached) defined ( I don't know if
it is 2.x or 3.x grammar ? Anyone?) to return an ClearcaseElementState
object containing values:

	$elem.text, ClearCase.IS_ELEMENT |
ClearCase.ERROR_IDENTICAL_TO_PREDECESSOR

I have used the regular debugger in eclipse and foud that elements ( see
code below ) does not contain these.

So that is why I wanted to debug antlr generated code.

How can I do that?

cheers,

//mikael




protected ClearCaseElementState[] parserOutput(final String[] result) {
		final StringBuffer display = new StringBuffer();
		for (int i = 0; i < result.length; i++) {
			if (i != 0) {
				display.append("\n");
			}
			display.append(result[i]);
		}
		LOG.finest("parsing:" + display.toString());
		ClearCaseElementState[] res = null;
		try {
			final Reader reader = new
StringReader(display.toString());
			final CleartoolOutputLexer lexer = new
CleartoolOutputLexer(
					new ANTLRReaderStream(reader));
			final CommonTokenStream cts = new
CommonTokenStream(lexer);
			final CleartoolOutputParser parser = new
CleartoolOutputParser(cts);
			final List elements = parser.main();
			res = (ClearCaseElementState[]) elements
					.toArray(new
ClearCaseElementState[elements.size()]);
		} catch (final IOException e) {
			// TODO handle catch block
			e.printStackTrace();
		} catch (final RecognitionException e) {
			// TODO handle catch block
			e.printStackTrace();
		} catch (final Exception e) {
			// TODO handle catch block
			e.printStackTrace();
		}
		
		return res;
	}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080802/c0623f38/attachment.html 


More information about the antlr-interest mailing list