-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathREADME
131 lines (86 loc) · 2.48 KB
/
README
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
ecomcon: Enable Comments Conditionally
Douglas Crockford
Public Domain
Ecomcon is a filter that enables selected comments, making them
executable. This makes it possible to put development, performance, and
testing scaffolding into a source file. The scaffolding is removed by
minification, but is activated by ecomcon. There are currently two
implementations of ecomcon in C and JavaScript.
Ecomcon is a filter that takes a source file and looks for tagged
comments in this form:
//tag stuff
The line comment starts at the beginning of the line. There can be no
space between the '//' and the tag.
Ecomcon is given a list of the names of the tags that should be enabled.
The implementation in C obtains the input from 'stdin', and provides the
result to 'stdout'. The tag list is taken from the command line. The
command line can also include a '-comment' specification. Ecomcon will
exit(1) if there is an error.
In JavaScript, it is available as the ecomcon function that takes a
source string, an array of tags, and an optional array of comments. It
will throw an exception if there is an error. If there is no error, it
returns a string.
C command line example:
----
ecomcon -comment "Devel Edition." <input >output es6 test enter exit
----
JavaScript example:
----
import ecomcon from "./ecomcon.js";
let output = ecomcon(
input,
["es6", "test", "enter", "exit"],
["Devel Edition."]
);
----
input:
----
// This is a sample file.
function Constructor(number) {
//enter log_enter("Constructor");
function private_method() {
//enter log_enter("private_method");
//nochange alert();
//exit log_exit("private_method");
}
//test this.private_method = private_method;
//test this.priv = function () {
//enter log_enter("priv");
private_method();
//exit log_exit("priv");
}
//exit log_exit("Constructor");
}
//es6 export default Constructor;
//legacy module.exports = Constructor;
----
output:
----
// Devel Edition.
// This is a sample file.
function Constructor(number) {
log_enter("Constructor");
function private_method() {
log_enter("private_method");
log_exit("private_method");
}
this.private_method = private_method;
this.priv = function () {
log_enter("priv");
private_method();
log_exit("priv");
}
log_exit("Constructor");
}
export default Constructor;
----
input, lightly minified:
----
function Constructor(number) {
function private_method() {
}
this.priv = function () {
private_method();
}
}
----