Last change
on this file was
5,
checked in by zeiss, 14 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.1 KB
|
Line | |
---|
1 | package de.ugoe.cs.swe.bnftools.valueconverter;
|
---|
2 |
|
---|
3 | import org.eclipse.xtext.common.services.DefaultTerminalConverters;
|
---|
4 | import org.eclipse.xtext.conversion.IValueConverter;
|
---|
5 | import org.eclipse.xtext.conversion.ValueConverter;
|
---|
6 | import org.eclipse.xtext.conversion.ValueConverterException;
|
---|
7 | import org.eclipse.xtext.conversion.impl.AbstractNullSafeConverter;
|
---|
8 | import org.eclipse.xtext.parsetree.AbstractNode;
|
---|
9 | import org.eclipse.xtext.util.Strings;
|
---|
10 |
|
---|
11 | public class EbnfTerminalConverters extends DefaultTerminalConverters {
|
---|
12 |
|
---|
13 | @ValueConverter(rule = "STRING")
|
---|
14 | public IValueConverter<String> STRING() {
|
---|
15 | return new AbstractNullSafeConverter<String>() {
|
---|
16 | @Override
|
---|
17 | protected String internalToValue(String string, AbstractNode node) {
|
---|
18 | try {
|
---|
19 | return string.substring(1,
|
---|
20 | string.length() - 1);
|
---|
21 | } catch (IllegalArgumentException e) {
|
---|
22 | throw new ValueConverterException(e.getMessage(), node, e);
|
---|
23 | }
|
---|
24 | }
|
---|
25 |
|
---|
26 | @Override
|
---|
27 | protected String internalToString(String value) {
|
---|
28 | return '"' + Strings.convertToJavaString(value, false) + '"';
|
---|
29 | }
|
---|
30 | };
|
---|
31 | }
|
---|
32 |
|
---|
33 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.