Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMT (Generative Modeling Technologies) » [xtext] Error in the generated PartitionScanner
[xtext] Error in the generated PartitionScanner [message #618879] Wed, 06 August 2008 11:24
Lorenzo Bettini is currently offline Lorenzo Bettini
Messages: 1308
Registered: July 2009
Senior Member
by taking a look at the generated antlr grammar, the STRING token takes
care of escaping character \ (which is a really good thing :-)

RULE_STRING :

'"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | ~('\\'|'"') )* '"' |
'\'' ( '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') | ~('\\'|'\'') )* '\''

;

However, the generated GeneratedPartitionScanner.java in the .editor
plugin, does not consider the escape character:

public class GeneratedPartitionScanner extends AbstractPartitionScanner {

@Override
public List<IPredicateRule> getRules() {
List<IPredicateRule> rules = new ArrayList<IPredicateRule>();

...
rules.add(new MultiLineRule("\"","\"", string));
rules.add(new MultiLineRule("'","'", string));
return rules;
}

in fact, in the generated editor the highlighting of a string of the shape

"this is \"a test\""

does not generate an error (right!) but it is not highlighted correctly.

The generated partition scanner should consider the escape character:

public class GeneratedPartitionScanner extends AbstractPartitionScanner {

@Override
public List<IPredicateRule> getRules() {
List<IPredicateRule> rules = new ArrayList<IPredicateRule>();

...
rules.add(new MultiLineRule("\"","\"", string, '\\'));
rules.add(new MultiLineRule("'","'", string, '\\'));
return rules;
}

where should I fix this?
if I modify the generated partition scanner directly I assume it will be
overwritten...

thanks
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
Previous Topic:Wizard inheritance and call
Next Topic:[Epsilon] Configuring HUTN file
Goto Forum:
  


Current Time: Sat Aug 02 02:33:42 EDT 2014

Powered by FUDForum. Page generated in 0.01477 seconds