diff options
Diffstat (limited to 'language-mwe2/src/main/java/tools')
-rw-r--r-- | language-mwe2/src/main/java/tools/refinery/language/mwe2/ProblemWebIntegrationFragment.java | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/language-mwe2/src/main/java/tools/refinery/language/mwe2/ProblemWebIntegrationFragment.java b/language-mwe2/src/main/java/tools/refinery/language/mwe2/ProblemWebIntegrationFragment.java deleted file mode 100644 index cdebe452..00000000 --- a/language-mwe2/src/main/java/tools/refinery/language/mwe2/ProblemWebIntegrationFragment.java +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
1 | package tools.refinery.language.mwe2; | ||
2 | |||
3 | import java.util.Set; | ||
4 | |||
5 | import org.eclipse.xtext.xtext.generator.web.WebIntegrationFragment; | ||
6 | |||
7 | import com.google.common.collect.Multimap; | ||
8 | |||
9 | public class ProblemWebIntegrationFragment extends WebIntegrationFragment { | ||
10 | private static final String START_STATE = "start"; | ||
11 | private static final String PREDICATE_BODY_STATE = "predicateBody"; | ||
12 | private static final String CM_MODE_META = "meta"; | ||
13 | |||
14 | public ProblemWebIntegrationFragment() { | ||
15 | setFramework(Framework.CODEMIRROR.name()); | ||
16 | // Use the CodeMirror default .cm-number instead of .cm-constant.cm-numeric | ||
17 | addSuppressPattern("number_decimal"); | ||
18 | // We use our own custom single-line comments | ||
19 | addSuppressPattern("comment_singleLine"); | ||
20 | // Override bracket indentation behavior | ||
21 | addSuppressPattern("bracket_open"); | ||
22 | addSuppressPattern("parenthesis_open"); | ||
23 | addSuppressPattern("brace_open"); | ||
24 | addSuppressPattern("bracket_close"); | ||
25 | addSuppressPattern("parenthesis_close"); | ||
26 | addSuppressPattern("brace_close"); | ||
27 | } | ||
28 | |||
29 | @Override | ||
30 | public void setFramework(String frameworkName) { | ||
31 | if (!frameworkName.toUpperCase().equals(Framework.CODEMIRROR.name())) { | ||
32 | throw new IllegalStateException("Framework cannot be changed from CodeMirror"); | ||
33 | } | ||
34 | super.setFramework(frameworkName); | ||
35 | } | ||
36 | |||
37 | @Override | ||
38 | protected Multimap<String, String> createCodeMirrorPatterns(String langId, Set<String> keywords) { | ||
39 | Multimap<String, String> patterns = super.createCodeMirrorPatterns(langId, keywords); | ||
40 | // Use the CodeMirror default .cm-number instead of .cm-constant.cm-numeric | ||
41 | patterns.put(START_STATE, | ||
42 | "{token: \"number\", regex: \"[+-]?\\\\d+(?:(?:\\\\.\\\\d*)?(?:[eE][+-]?\\\\d+)?)?\\\\b\"}"); | ||
43 | // We use our own custom single-line comments | ||
44 | patterns.put(START_STATE, "{token: \"comment\", regex: \"%.*$\"}"); | ||
45 | patterns.put(START_STATE, "{token: \"comment\", regex: \"\\\\/\\\\/.*$\"}"); | ||
46 | patterns.put(CM_MODE_META, "lineComment: \"%\""); | ||
47 | // Override indentation behavior | ||
48 | patterns.put(START_STATE, "{token: \"lparen\", indent: true, regex: \"[[({]\"}"); | ||
49 | patterns.put(START_STATE, "{token: \"rparen\", dedent: true, regex: \"[\\\\])}]\"}"); | ||
50 | patterns.putAll(PREDICATE_BODY_STATE, patterns.get(START_STATE)); | ||
51 | patterns.put(START_STATE, "{indent: true, push: \"" + PREDICATE_BODY_STATE + "\", regex: \"<->\"}"); | ||
52 | patterns.put(PREDICATE_BODY_STATE, | ||
53 | "{dedent: true, dedentIfLineStart: false, pop: true, regex: \"\\\\.\\\\s*$\"}"); | ||
54 | patterns.put(PREDICATE_BODY_STATE, "{indent: true, dedent: true, regex: \"[;]\"}"); | ||
55 | // We must repeat the keyword rule here, because Xtext only adds it to "main" | ||
56 | // later | ||
57 | patterns.put(PREDICATE_BODY_STATE, "{token: \"keyword\", regex: \"\\\\b(?:\" + keywords + \")\\\\b\"}"); | ||
58 | patterns.put(CM_MODE_META, "electricChars: \"])];\""); | ||
59 | return patterns; | ||
60 | } | ||
61 | } | ||