Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Applied [HEAD & Parser_SymbolTable] Re: [cdt-patch] Fix for PR 38065


Thanks for the patch.

For future reference:
  - ChangeLogs should be updated on every patch (a short description is fine with me)
  - adding a Junit test to the org.eclipse.cdt.ui.tests plugin to be joined into our AutomatedIntegrationSuite.java is highly encouraged so that we can see that a new bug has been fixed without the committer reproducing the testcase.  

Thanks again,
JohnC



victor.mozgin@xxxxxxxxxxxxx
Sent by: cdt-patch-admin@xxxxxxxxxxx

06/04/2003 03:47 PM

Please respond to
cdt-patch@xxxxxxxxxxx

To
cdt-patch@xxxxxxxxxxx
cc
Subject
[cdt-patch] Fix for PR 38065





        Here is another small patch. The problem is caused by the scanner: it mistreated '\' characters. getChar() handles "'\' as the last character on the line" scenario, where '\' and the end-of-line are correctly skipped (imitating preprocessor activity). But it didn't backtrack properly in other cases, effectively skipping '\' characters anywhere else in the code (outside strings). You could write
 cl\ass C\Foo\Bar {
and it was automagically transformed to
 class CFooBar {
for the parser.
 Now getChar() does additional ungetChar() in case '\' is not the last character on the line (and it throws ScannerException, from ungetChar()).

 
                                /Vic
 
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.26
diff -u -r1.26 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003 20:04:51 -0000 1.26
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003 19:02:28 -0000
@@ -198,7 +198,7 @@
  return buffer.toString();
 }

- protected void skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline() throws ScannerException {
  for (;;) {
   switch (getChar()) {
    case NOCHAR :
@@ -366,12 +366,12 @@
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.26
diff -u -r1.26 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003 20:04:51 -0000 1.26
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003 19:04:07 -0000
@@ -198,7 +198,7 @@
  return buffer.toString();
 }

- protected void skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline() throws ScannerException {
  for (;;) {
   switch (getChar()) {
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.26
diff -u -r1.26 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003 20:04:51 -0000 1.26
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003 19:05:14 -0000
@@ -198,7 +198,7 @@
  return buffer.toString();
 }

- protected void skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline() throws ScannerException {
  for (;;) {
   switch (getChar()) {
    case NOCHAR :
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.26
diff -u -r1.26 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003 20:04:51 -0000 1.26
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003 19:06:40 -0000
@@ -198,7 +198,7 @@
  return buffer.toString();
 }

- protected void skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline() throws ScannerException {
  for (;;) {
   switch (getChar()) {
    case NOCHAR :
@@ -366,12 +366,12 @@
  callback = c;
 }

- private int getChar()
+ private int getChar() throws ScannerException
 {
  return getChar( false );
 }

- private int getChar( boolean insideString ) {
+ private int getChar( boolean insideString ) throws ScannerException {
  int c = NOCHAR;
 
  lastContext = contextStack.getCurrentContext();
@@ -423,6 +423,10 @@
     c = getChar(false);
     if( c == '\n')
      contextStack.newLine();
+    } else // '\' is not the last character on the line
+    {
+     ungetChar(c);
+     c = '\\';
    }
   }
   else if( c == '\n' )


Back to the top