Skip to content

Commit 96323b7

Browse files
committed
Doing some renaming like @dwightguth suggested.
Former-commit-id: ea6e55768fa472351ea5a6eac06daecf71d8c9c2 [formerly 655519577dac4616f7e36a870a824928000b90c3] Former-commit-id: e5524b5f2ba06ca13260b28330abfefb414ea58a
1 parent d2d52ae commit 96323b7

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

kernel/src/main/java/org/kframework/kil/loader/Constants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class Constants {
1616
public static final String BODY = "body";
1717
public static final String REWRITE = "rewrite";
1818
public static final String LEFT = "left";
19+
public static final String AUTOREJECT = "autoReject";
20+
public static final String REJECT2 = "reject2";
1921
public static final String TERM = "term";
2022
public static final String SYN = "Syn";
2123
public static final String BRACKET = "bracket";

kernel/src/main/java/org/kframework/parser/concrete2kore/kernel/KSyntax2GrammarStatesFilter.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package org.kframework.parser.concrete2kore.kernel;
33

44
import org.kframework.Collection;
5+
import org.kframework.kil.loader.Constants;
56
import org.kframework.kore.Sort;
67
import org.kframework.definition.Module;
78
import org.kframework.definition.Production;
@@ -137,12 +138,12 @@ public static void processProduction(Production prd, Grammar grammar, String rej
137138
Pattern pattern = null;
138139
if (prd.att().contains("token")) {
139140
// TODO: calculate reject list
140-
if (prd.att().contains("autoReject") && prd.att().contains("rejectt"))
141-
pattern = Pattern.compile("(" + prd.att().get("rejectt").get().toString() + ")|(" + rejectPattern + ")");
142-
else if (prd.att().contains("autoReject"))
141+
if (prd.att().contains(Constants.AUTOREJECT) && prd.att().contains(Constants.REJECT2))
142+
pattern = Pattern.compile("(" + prd.att().get(Constants.REJECT2).get().toString() + ")|(" + rejectPattern + ")");
143+
else if (prd.att().contains(Constants.AUTOREJECT))
143144
pattern = Pattern.compile(rejectPattern);
144-
else if (prd.att().contains("rejectt"))
145-
pattern = Pattern.compile(prd.att().get("rejectt").get().toString());
145+
else if (prd.att().contains(Constants.REJECT2))
146+
pattern = Pattern.compile(prd.att().get(Constants.REJECT2).get().toString());
146147
}
147148
RuleState labelRule = new RuleState("AddLabelRS", nt, new WrapLabelRule(prd, pattern));
148149
previous.next.add(labelRule);

kernel/src/main/java/org/kframework/parser/concrete2kore/kernel/Rule.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,22 @@ public Set<KList> apply(Set<KList> set, MetaData metaData) {
7373
*/
7474
public static class WrapLabelRule extends KListRule {
7575
private final Production label;
76-
public final Pattern pattern;
77-
public WrapLabelRule(Production label, Pattern pattern) {
76+
public final Pattern rejectPattern;
77+
public WrapLabelRule(Production label, Pattern rejectPattern) {
7878
assert label != null;
7979
this.label = label;
80-
this.pattern = pattern;
80+
this.rejectPattern = rejectPattern;
8181
}
8282
public WrapLabelRule(Production label) {
8383
assert label != null;
8484
this.label = label;
85-
pattern = null;
85+
rejectPattern = null;
8686
}
8787
protected KList apply(KList klist, MetaData metaData) {
88-
//Term term = new KApp(label, klist);
8988
Term term;
9089
if (label.att().contains("token")) {
91-
// TODO: radum, figure out how to reject constants from here.
9290
String value = metaData.input.subSequence(metaData.start.position, metaData.end.position).toString();
93-
if (pattern != null && pattern.matcher(value).matches()) {
91+
if (rejectPattern != null && rejectPattern.matcher(value).matches()) {
9492
return null;
9593
}
9694
term = Constant.apply(value, label, Optional.empty());

kernel/src/main/resources/e-kore.k

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ module BUBBLE
6767
6868
syntax Bubble ::= Bubble BubbleItem [token]
6969
| BubbleItem [token]
70-
syntax BubbleItem ::= r"((?!rule|syntax|endmodule|configuration|context)\\S+)" [token]
71-
// the proper way to reject would be: reject("rule|syntax|endmodule|configuration|context")
70+
syntax BubbleItem ::= r"\\S+" [token, reject2("rule|syntax|endmodule|configuration|context")]
7271
7372
endmodule
7473

0 commit comments

Comments
 (0)