diff options
Diffstat (limited to 'language-mwe2')
-rw-r--r-- | language-mwe2/build.gradle | 2 | ||||
-rw-r--r-- | language-mwe2/src/main/java/org/eclipse/viatra/solver/language/mwe2/ProblemWebIntegrationFragment.java | 36 |
2 files changed, 23 insertions, 15 deletions
diff --git a/language-mwe2/build.gradle b/language-mwe2/build.gradle index 8596b4c1..ae456c39 100644 --- a/language-mwe2/build.gradle +++ b/language-mwe2/build.gradle | |||
@@ -1,3 +1,5 @@ | |||
1 | apply from: "${rootDir}/gradle/java-common.gradle" | ||
2 | |||
1 | dependencies { | 3 | dependencies { |
2 | compile "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:${xtextVersion}" | 4 | compile "org.eclipse.xtext:org.eclipse.xtext.xtext.generator:${xtextVersion}" |
3 | } | 5 | } |
diff --git a/language-mwe2/src/main/java/org/eclipse/viatra/solver/language/mwe2/ProblemWebIntegrationFragment.java b/language-mwe2/src/main/java/org/eclipse/viatra/solver/language/mwe2/ProblemWebIntegrationFragment.java index 83b56bc6..78311e0d 100644 --- a/language-mwe2/src/main/java/org/eclipse/viatra/solver/language/mwe2/ProblemWebIntegrationFragment.java +++ b/language-mwe2/src/main/java/org/eclipse/viatra/solver/language/mwe2/ProblemWebIntegrationFragment.java | |||
@@ -7,6 +7,10 @@ import org.eclipse.xtext.xtext.generator.web.WebIntegrationFragment; | |||
7 | import com.google.common.collect.Multimap; | 7 | import com.google.common.collect.Multimap; |
8 | 8 | ||
9 | public class ProblemWebIntegrationFragment extends WebIntegrationFragment { | 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 | |||
10 | public ProblemWebIntegrationFragment() { | 14 | public ProblemWebIntegrationFragment() { |
11 | setFramework(Framework.CODEMIRROR.name()); | 15 | setFramework(Framework.CODEMIRROR.name()); |
12 | // We use our custom token style for single-quoted names | 16 | // We use our custom token style for single-quoted names |
@@ -36,25 +40,27 @@ public class ProblemWebIntegrationFragment extends WebIntegrationFragment { | |||
36 | protected Multimap<String, String> createCodeMirrorPatterns(String langId, Set<String> keywords) { | 40 | protected Multimap<String, String> createCodeMirrorPatterns(String langId, Set<String> keywords) { |
37 | Multimap<String, String> patterns = super.createCodeMirrorPatterns(langId, keywords); | 41 | Multimap<String, String> patterns = super.createCodeMirrorPatterns(langId, keywords); |
38 | // We use our custom token style for single-quoted names | 42 | // We use our custom token style for single-quoted names |
39 | patterns.put("start", "{token: \"quoted-name\", regex: \"['](?:(?:\\\\\\\\.)|(?:[^'\\\\\\\\]))*?[']\"}"); | 43 | patterns.put(START_STATE, "{token: \"quoted-name\", regex: \"['](?:(?:\\\\\\\\.)|(?:[^'\\\\\\\\]))*?[']\"}"); |
40 | // Use the CodeMirror default .cm-number instead of .cm-constant.cm-numeric | 44 | // Use the CodeMirror default .cm-number instead of .cm-constant.cm-numeric |
41 | patterns.put("start", | 45 | patterns.put(START_STATE, |
42 | "{token: \"number\", regex: \"[+-]?\\\\d+(?:(?:\\\\.\\\\d*)?(?:[eE][+-]?\\\\d+)?)?\\\\b\"}"); | 46 | "{token: \"number\", regex: \"[+-]?\\\\d+(?:(?:\\\\.\\\\d*)?(?:[eE][+-]?\\\\d+)?)?\\\\b\"}"); |
43 | patterns.put("start", "{token: \"number\", regex: \"[*]\"}"); | 47 | patterns.put(START_STATE, "{token: \"number\", regex: \"[*]\"}"); |
44 | // We use our own custom single-line comments | 48 | // We use our own custom single-line comments |
45 | patterns.put("start", "{token: \"comment\", regex: \"%.*$\"}"); | 49 | patterns.put(START_STATE, "{token: \"comment\", regex: \"%.*$\"}"); |
46 | patterns.put("start", "{token: \"comment\", regex: \"\\\\/\\\\/.*$\"}"); | 50 | patterns.put(START_STATE, "{token: \"comment\", regex: \"\\\\/\\\\/.*$\"}"); |
47 | patterns.put("meta", "lineComment: \"%\""); | 51 | patterns.put(CM_MODE_META, "lineComment: \"%\""); |
48 | // Override indentation behavior | 52 | // Override indentation behavior |
49 | patterns.put("start", "{token: \"lparen\", indent: true, regex: \"[[({]\"}"); | 53 | patterns.put(START_STATE, "{token: \"lparen\", indent: true, regex: \"[[({]\"}"); |
50 | patterns.put("start", "{token: \"rparen\", dedent: true, regex: \"[\\\\])}]\"}"); | 54 | patterns.put(START_STATE, "{token: \"rparen\", dedent: true, regex: \"[\\\\])}]\"}"); |
51 | patterns.putAll("predicateBody", patterns.get("start")); | 55 | patterns.putAll(PREDICATE_BODY_STATE, patterns.get(START_STATE)); |
52 | patterns.put("start", "{indent: true, push: \"predicateBody\", regex: \"<=>\"}"); | 56 | patterns.put(START_STATE, "{indent: true, push: \"" + PREDICATE_BODY_STATE + "\", regex: \"<=>\"}"); |
53 | patterns.put("predicateBody", "{dedent: true, dedentIfLineStart: false, pop: true, regex: \"\\\\.\\\\s*$\"}"); | 57 | patterns.put(PREDICATE_BODY_STATE, |
54 | patterns.put("predicateBody", "{indent: true, dedent: true, regex: \"[;]\"}"); | 58 | "{dedent: true, dedentIfLineStart: false, pop: true, regex: \"\\\\.\\\\s*$\"}"); |
55 | // We must repeat the keyword rule here, because Xtext only adds it to "main" later. | 59 | patterns.put(PREDICATE_BODY_STATE, "{indent: true, dedent: true, regex: \"[;]\"}"); |
56 | patterns.put("predicateBody", "{token: \"keyword\", regex: \"\\\\b(?:\" + keywords + \")\\\\b\"}"); | 60 | // We must repeat the keyword rule here, because Xtext only adds it to "main" |
57 | patterns.put("meta", "electricChars: \"])];\""); | 61 | // later |
62 | patterns.put(PREDICATE_BODY_STATE, "{token: \"keyword\", regex: \"\\\\b(?:\" + keywords + \")\\\\b\"}"); | ||
63 | patterns.put(CM_MODE_META, "electricChars: \"])];\""); | ||
58 | return patterns; | 64 | return patterns; |
59 | } | 65 | } |
60 | } | 66 | } |