Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Trouble parsing structs with cdt.core.IParser
Trouble parsing structs with cdt.core.IParser [message #87176] Mon, 24 November 2003 09:09
Eclipse UserFriend
Originally posted by: volanaki.informatik.uni-tuebingen.de

This is a multi-part message in MIME format.
--------------050009030704060803030700
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I'm experimenting with the cdt.core.Parser component and have trouble
parsing following (legal) code:

struct s { /* ... */ };
void f(int s) { struct s a; s++; }

I've attached a small java program demonstrating this problem.

Since I wasn't able to find an parser-bug in bugzilla for this case,
I would like to know if I'm doing something wrong?

Thanks for your time,
Elias.

--------------050009030704060803030700
Content-Type: text/plain;
name="CppStructParser.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="CppStructParser.java"

import java.io.StringReader;
import org.eclipse.cdt.core.parser.*;

public class CppStructParser {

public static void main(String[] args) throws Exception {
// code from page 27
// Ellis, Stroustrup, "Annotated C++ Reference Manual", Addisson-Wesley, 1990
// compiles with g++ 3.2
String code = "struct s { /* ... */ }; void f(int s) { struct s a; s++; }\n";

ParserMode mode = ParserMode.COMPLETE_PARSE;
ParserLanguage lang = ParserLanguage.CPP;
IScanner scanner =
ParserFactory.createScanner(new StringReader(code), "", new ScannerInfo(), mode, lang, null, null);
IParser parser = ParserFactory.createParser(scanner, new NullSourceElementRequestor(), mode, lang, null);
if (!parser.parse()) { // failure
System.err.println("failure at: "+parser.getLastErrorOffset()+": "
+ code.substring(parser.getLastErrorOffset()));
}
}
}

--------------050009030704060803030700--
Previous Topic:GDB 5.0
Next Topic:Eclipse & Cygwin
Goto Forum:
  


Current Time: Fri Jul 04 21:37:50 EDT 2025

Powered by FUDForum. Page generated in 0.03984 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top