-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathPragma.java
More file actions
46 lines (34 loc) · 1.13 KB
/
Pragma.java
File metadata and controls
46 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.python.core;
import org.python.antlr.ParseException;
public interface Pragma {
void addTo(PragmaReceiver receiver);
public abstract class PragmaModule {
public final String name;
protected PragmaModule(String name) {
this.name = name;
}
public abstract Pragma getPragma(String name);
public abstract Pragma getStarPragma();
}
public final class ForbiddenPragmaModule extends PragmaModule {
private final String message;
public ForbiddenPragmaModule(String name) {
this(name, "pragma " + name + " is not allowed in this context.");
}
public ForbiddenPragmaModule(String name, String message) {
super(name);
this.message = message;
}
@Override
public Pragma getPragma(String name) {
throw new ParseException(message);
}
@Override
public Pragma getStarPragma() {
throw new ParseException(message);
}
public void addTo(PragmaReceiver receiver) {
throw new ParseException(message);
}
}
}