Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327051

Summary: Wrong backtracking in case of keywords with common prefix
Product: [Modeling] TMF Reporter: Dénes Harmath <thsoft>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: henrik.lindberg, thsoft
Version: 1.0.1   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Dénes Harmath CLA 2010-10-05 19:47:50 EDT
Build Identifier: M20100909-0800

The lexer & parser even when backtracking can't handle the following case (keywords which share the same prefix):

Reproducible: Always

Steps to Reproduce:
Grammar:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model: expressions+=Expression+;

Expression: Bar | Baz | Other;

Bar: {Bar} "\\bar";

Baz: {Baz} "\\baz";

Other hidden(): "\\" id=ID;

Generator options:

fragment = parser.antlr.ex.rt.AntlrGeneratorFragment {
options = {
backtrackLexer = true
backtrack = true
}
}

Input:

\b

Error:

no viable alternative at character '\'

Xtext version: 1.0.1.v201008251220
Comment 1 Henrik Lindberg CLA 2010-11-29 09:45:06 EST
I am having problems with this as well - backtracking lexer and keywords "else" and "elsif" will report problems for the combination of "el" as in "hello" when used elsewhere. Removing the "elsif" from my grammar makes it work.
Comment 2 Sven Efftinge CLA 2012-11-16 05:25:16 EST
I fear that we can't do much about it as it appears to be an Antlr problem.