[xtext] Error in the generated PartitionScanner [message #618629] |
Sun, 03 August 2008 10:03 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02437 seconds