-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
167 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.dub | ||
docs.json | ||
__dummy.html | ||
*.o | ||
*.obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "application", | ||
"description": "A minimal D application.", | ||
"copyright": "Copyright © 2015, ilya", | ||
"authors": ["ilya"], | ||
"dependencies": { | ||
"comp": "~master" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import component; | ||
|
||
import std.stdio; | ||
|
||
void main() | ||
{ | ||
writeln("Edit source/app.d to start your project."); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.dub | ||
docs.json | ||
__dummy.html | ||
*.o | ||
*.obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "component", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/++ | ||
Module a; | ||
+/ | ||
module component.mod; | ||
|
||
import std.algorithm, std.ascii, std.range, std.string, std.functional; | ||
|
||
/++ | ||
Params: | ||
or = output range | ||
ir = input range | ||
cmt = comment prefix (like // in or # in Python) | ||
Returns | ||
Text without single line comments. | ||
+/ | ||
void removeSingleLineComments | ||
(OutputRange, Range1, Range2) // template parameters | ||
(OutputRange or, Range1 ir, Range2 cmt) // function parameters | ||
{ | ||
foreach(line; lineSplitter(ir)) | ||
{ | ||
auto s = line.save.find!(not!isWhite); | ||
if(!s.startsWith(cmt)) | ||
{ | ||
put(or, line.until(cmt)); | ||
put(or, "\n"); | ||
} | ||
} | ||
} | ||
|
||
/// Unittests with comment appears in documentation. | ||
unittest | ||
{ | ||
auto app = appender!string; | ||
|
||
immutable text0 = | ||
` | ||
// main function | ||
int main() | ||
{ | ||
// return statement | ||
return 0; //returns 0 | ||
} | ||
`; | ||
|
||
immutable text1 = | ||
` | ||
int main() | ||
{ | ||
return 0; | ||
} | ||
`; // Note: "return 0; " ends with a space character | ||
|
||
removeSingleLineComments(app, text0, "//"); | ||
|
||
debug | ||
{ | ||
import std.stdio; | ||
writeln("text:", app.data); | ||
} | ||
|
||
assert(app.data == text1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/++ | ||
Pacakge component | ||
+/ | ||
module component; | ||
|
||
public import component.mod : removeSingleLineComments; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters