blob: 90df6c78da3ce644fb909ad89d637fd5a8ad6bb6 (
plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package bjc.utils.ioutils.format.directives;
import java.io.IOException;
/**
* A CL format directive.
*
* @author Ben Culkin
*/
public interface Directive {
/**
* Execute this format directive.
*
* @param dirParams
* The parameters for the directive.
* @throws IOException
* If something goes wrong.
*/
public default void format(FormatParameters dirParams) throws IOException {
Edict edt = compile(dirParams.toCompileCTX());
edt.format(dirParams.toFormatCTX());
}
/**
* Compile this directive.
*
* @param compCTX
* The state necessary to compile this directive.
*
* @return A compiled form of this directive.
*/
public default Edict compile(CompileContext compCTX) {
throw new IllegalArgumentException(
"This directive does not support compilation yet");
}
/**
* Check if a particular directive is an opening directive.
*
* @param str
* The directive to check.
*
* @return Whether or not the directive is opening.
*/
public static boolean isOpening(String str) {
switch (str) {
case "(":
case "<":
case "[":
case "{":
case "`(":
return true;
default:
return false;
}
}
/**
* Check if a particular directive is an opening directive.
*
* @param str
* The directive to check.
*
* @return Whether or not the directive is opening.
*/
public static boolean isClosing(String str) {
switch (str) {
case ")":
case ">":
case "]":
case "}":
case "`)":
return true;
default:
return false;
}
}
// @TODO 9/19/18 Ben Culkin :ParseContained
//
// Implement something for parsing contained bodies, abstracting the
// stuff that Iteration/Conditional/CaseDirective do.
//
// The main issue is thinking of a good interface to it.
}
|