Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue 17392 - Add Dub file for the lexer and parser
The Dub file is intended to make the the compiler available as a library through Dub.
- Loading branch information
1 parent
832186a
commit b5e6ed4
Showing
5 changed files
with
113 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name "dmd" | ||
description "The DMD compiler" | ||
authors "Walter Bright" | ||
copyright "Copyright © 1999-2017, Digital Mars" | ||
license "BSL-1.0" | ||
|
||
targetType "none" | ||
dependency ":parser" version="*" | ||
|
||
subPackage { | ||
name "root" | ||
targetType "library" | ||
sourcePaths "src/ddmd/root" | ||
} | ||
|
||
subPackage { | ||
name "lexer" | ||
targetType "library" | ||
sourcePaths | ||
|
||
sourceFiles \ | ||
"src/ddmd/console.d" \ | ||
"src/ddmd/entity.d" \ | ||
"src/ddmd/errors.d" \ | ||
"src/ddmd/globals.d" \ | ||
"src/ddmd/id.d" \ | ||
"src/ddmd/identifier.d" \ | ||
"src/ddmd/lexer.d" \ | ||
"src/ddmd/tokens.d" \ | ||
"src/ddmd/utf.d" | ||
|
||
// stringImportPaths cannot be used because it will make Dub extremely slow | ||
// https://github.com/dlang/dub/issues/1199 | ||
dflags "-J$PACKAGE_DIR" | ||
|
||
dependency "dmd:root" version="*" | ||
} | ||
|
||
subPackage { | ||
name "parser" | ||
targetType "library" | ||
sourcePaths | ||
|
||
sourceFiles \ | ||
"src/ddmd/astbase.d" \ | ||
"src/ddmd/astbasevisitor.d" \ | ||
"src/ddmd/parse.d" | ||
|
||
dependency "dmd:lexer" version="*" | ||
} |
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,5 @@ | ||
name "dmd-dub-test" | ||
description "Test of the DMD Dub package" | ||
license "BSL 1.0" | ||
|
||
dependency "dmd" path="../../" |
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,45 @@ | ||
// The tests in this module are highlevel and mostly indented to make sure all | ||
// necessary modules are included in the Dub package. | ||
|
||
void main() | ||
{ | ||
} | ||
|
||
// lexer | ||
unittest | ||
{ | ||
import ddmd.lexer; | ||
import ddmd.tokens; | ||
|
||
immutable expected = [ | ||
TOKvoid, | ||
TOKidentifier, | ||
TOKlparen, | ||
TOKrparen, | ||
TOKlcurly, | ||
TOKrcurly | ||
]; | ||
|
||
immutable sourceCode = "void test() {} // foobar"; | ||
scope lexer = new Lexer("test", sourceCode.ptr, 0, sourceCode.length, 0, 0); | ||
lexer.nextToken; | ||
|
||
TOK[] result; | ||
|
||
do | ||
{ | ||
result ~= lexer.token.value; | ||
} while (lexer.nextToken != TOKeof); | ||
|
||
assert(result == expected); | ||
} | ||
|
||
// parser | ||
unittest | ||
{ | ||
import ddmd.astbase; | ||
import ddmd.parse; | ||
|
||
scope parser = new Parser!ASTBase(null, null, false); | ||
assert(parser !is null); | ||
} |
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