Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAOC 2023: replace libdparse with dmd #589

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
34174ba
chore(deps): add dmd library
snprajwal Sep 22, 2023
61206bc
refactor: lexer in `tokens.d`
snprajwal Sep 22, 2023
806e758
refactor: lexer in `indentation.d` and `wrapping.d`
snprajwal Sep 27, 2023
6c1c543
feat: make it compile with dmd AST
snprajwal Sep 27, 2023
3ac8e5a
feat: implement visitors and writers
snprajwal Oct 19, 2023
decdc79
fix: add indentation logic
snprajwal Nov 8, 2023
ded6e8d
fix: iron out some bugs
snprajwal Nov 9, 2023
90c9040
feat: add 4 transformations
snprajwal Nov 10, 2023
62e47bb
feat: add `dfmt_space_after_keywords`
snprajwal Nov 22, 2023
b4e36d9
feat: add `dfmt_selective_import_space`
snprajwal Nov 22, 2023
07bfe5c
feat: add brace styles
snprajwal Dec 1, 2023
14024a5
feat: add `dfmt_compact_labeled_statements`
snprajwal Dec 13, 2023
0259887
feat: add `dfmt_space_before_named_arg_colon`
snprajwal Dec 13, 2023
0897c83
feat: non-conditional template constraints styles
snprajwal Dec 13, 2023
3b80011
chore: make it compile with latest DMD
snprajwal Dec 29, 2023
16028a8
fix: store unit tests in AST
snprajwal Dec 29, 2023
6e97ea8
feat: track line length
snprajwal Dec 29, 2023
7f81285
feat: conditional template constraint style
snprajwal Dec 29, 2023
3eb0928
chore: run dfmt on all files
snprajwal Dec 29, 2023
90bb91d
fix: use temporary buffer for conditional newline
snprajwal Jan 2, 2024
6ef9fba
chore: revert changes to README
snprajwal Jan 4, 2024
325f093
feat: add `dfmt_split_operator_at_line_end`
snprajwal Jan 12, 2024
864caad
feat: add `dfmt_single_template_constraint_indent`
snprajwal Jan 12, 2024
b845d96
fix: boolean logic for line split
snprajwal Jan 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "libdparse"]
path = libdparse
url = https://github.com/dlang-community/libdparse.git
[submodule "stdx-allocator"]
path = stdx-allocator
url = https://github.com/dlang-community/stdx-allocator
[submodule "d-test-utils"]
path = d-test-utils
url = https://github.com/dlang-community/d-test-utils.git
[submodule "dmd"]
path = dmd
url = https://github.com/dlang/dmd.git
1 change: 1 addition & 0 deletions dmd
Submodule dmd added at b85910
16 changes: 8 additions & 8 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"targetType": "autodetect",
"license": "BSL-1.0",
"dependencies": {
"libdparse": ">=0.19.2 <1.0.0"
"dmd": "~>2.107.0-beta.1"
},
"targetPath" : "bin/",
"targetName" : "dfmt",
"stringImportPaths" : [
"bin"
"targetPath": "bin/",
"targetName": "dfmt",
"stringImportPaths": [
"bin"
],
"versions" : [
"versions": [
"built_with_dub"
],
"preBuildCommands" : [
"$DC -run \"$PACKAGE_DIR/dubhash.d\""
"preBuildCommands": [
"$DC -run \"$PACKAGE_DIR/dubhash.d\""
]
}
1 change: 0 additions & 1 deletion libdparse
Submodule libdparse deleted from fe6d1e
36 changes: 32 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,36 @@
DMD_ROOT_SRC := \
$(shell find dmd/compiler/src/dmd/common -name "*.d")\
$(shell find dmd/compiler/src/dmd/root -name "*.d")
DMD_LEXER_SRC := \
dmd/compiler/src/dmd/console.d \
dmd/compiler/src/dmd/entity.d \
dmd/compiler/src/dmd/errors.d \
dmd/compiler/src/dmd/errorsink.d \
dmd/compiler/src/dmd/location.d \
dmd/compiler/src/dmd/file_manager.d \
dmd/compiler/src/dmd/globals.d \
dmd/compiler/src/dmd/id.d \
dmd/compiler/src/dmd/identifier.d \
dmd/compiler/src/dmd/lexer.d \
dmd/compiler/src/dmd/tokens.d \
dmd/compiler/src/dmd/utils.d \
$(DMD_ROOT_SRC)

DMD_PARSER_SRC := \
dmd/compiler/src/dmd/astbase.d \
dmd/compiler/src/dmd/parse.d \
dmd/compiler/src/dmd/parsetimevisitor.d \
dmd/compiler/src/dmd/transitivevisitor.d \
dmd/compiler/src/dmd/permissivevisitor.d \
dmd/compiler/src/dmd/strictvisitor.d \
dmd/compiler/src/dmd/astenums.d \
$(DMD_LEXER_SRC)
Comment on lines +1 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might dmd -i be useful here? This makes you quite brittle towards upstream changes.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm not really sure about keeping these changes, because they refused to work once I started using ASTCodegen. I tried a bunch of things to fix it, but didn't manage to make it work. dmdfmt currently works with dub build, but the Makefile itself is pretty broken. Even with every single D file in DMD included, it would die during linking.


SRC := $(shell find src -name "*.d") \
$(shell find libdparse/src -name "*.d") \
$(shell find stdx-allocator/source -name "*.d")
INCLUDE_PATHS := -Ilibdparse/src -Istdx-allocator/source -Isrc -Jbin
DMD_COMMON_FLAGS := -dip25 -w $(INCLUDE_PATHS)
$(shell find stdx-allocator/source -name "*.d") \
$(DMD_PARSER_SRC)
INCLUDE_PATHS := -Ilibdparse/src -Istdx-allocator/source -Isrc -Idmd/compiler/src -Jbin -Jdmd
DMD_COMMON_FLAGS := -w $(INCLUDE_PATHS)
DMD_DEBUG_FLAGS := -debug -g $(DMD_COMMON_FLAGS)
DMD_FLAGS := -O -inline $(DMD_COMMON_FLAGS)
DMD_TEST_FLAGS := -unittest -g $(DMD_COMMON_FLAGS)
Expand Down
Loading