diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java index 23bdc2bd11a..9db25695eb1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner/LexerTests.java @@ -201,7 +201,29 @@ public class LexerTests extends BaseTestCase { id("ab"); eof(); } - + + public void testLessColonColon() throws Exception { + // 2.5-3 + // <: is treated as digraph [ + init("<::>"); + token(IToken.tLBRACKET); + token(IToken.tRBRACKET); + eof(); + + // <: is treated as digraph [ + init("<:::"); + token(IToken.tLBRACKET); + token(IToken.tCOLONCOLON); + eof(); + + // <:: is treated as < and :: + init("<::A"); + token(IToken.tLT); + token(IToken.tCOLONCOLON); + token(IToken.tIDENTIFIER); + eof(); + } + public void testWindowsLineEnding() throws Exception { init("\n\n"); nl(); nl(); eof(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java index 439e2a910fb..40e1341fee3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java @@ -582,8 +582,19 @@ final public class Lexer implements ITokenSequence { } break; case ':': - nextCharPhase3(); - return newDigraphToken(IToken.tLBRACKET, start); + // 2.5-3 + markPhase3(); + if (nextCharPhase3() != ':') { + return newDigraphToken(IToken.tLBRACKET, start); + } + switch (nextCharPhase3()) { + case ':': case '>': + restorePhase3(); + nextCharPhase3(); + return newDigraphToken(IToken.tLBRACKET, start); + } + restorePhase3(); + break; case '%': nextCharPhase3(); return newDigraphToken(IToken.tLBRACE, start);