skvadrik / re2c

Lexer generator for C, C++, Go and Rust.
https://re2c.org
Other
1.07k stars 169 forks source link

Introduce Dlang codegen. #432

Closed ghost closed 1 year ago

ghost commented 1 year ago

Currently builds and passes every test with run_tests.py except: golang/010_error_case_ranges.re. One of the main differences from Go/Rust is that D supports case ranges like C. It also supports generic enums which are just compile time constants which can be used basically like a C define macro. So far from converting the example programs the codegen seems to be working well. I mostly just grepped for any use of Lang:: and copied the existing code and made the smallest modifications I could to have it generate valid D code.

ghost commented 1 year ago

Windows build failing CI with ERROR: The remote file either doesn't exist, is unauthorized, or is forbidden for url 'https://sourceforge.net/projects/gnuwin32/files/coreutils/5.3.0/coreutils-5.3.0.exe'. Exception calling "GetResponse" with "0" argument(s): "The request was aborted: Could not create SSL/TLS secure channel." The linux builds are failing with that Go issue mentioned earlier.

skvadrik commented 1 year ago

Thanks for the PR! I left some comments. I think you can ignore Windows infra errors (they happen from time to time and are usually fixed on rerun) and focus on the test failure.

ghost commented 1 year ago

Sure I will make those changes. I will need to look more into the line count thing you mentioned for the fallthrough, and supporting the pointer API. I should have some time tomorrow to work on that.

skvadrik commented 1 year ago

Sure I will make those changes. I will need to look more into the line count thing you mentioned for the fallthrough, and supporting the pointer API. I should have some time tomorrow to work on that.

Of course, no rush at all. Thanks for working on this.

ghost commented 1 year ago

Actually looking at every place the default API is used by grepping for Api::DEFAULT. All of code emitted is valid D code. So I made the change you suggested to enable that.

ghost commented 1 year ago

Currently failing more tests for Go now :

FAIL       golang/006_error_default_api.re
FAIL       golang/010_error_case_ranges.re
FAIL       golang/007_error_default_api.re

from run_tests.py. I will fix that.

ghost commented 1 year ago

Looks like it is just failing those tests since I changed the error string to be non-C/D backends instead of just non-C.

skvadrik commented 1 year ago

BTW you can squash all your fixes and force-push, unless you want to keep them separate for some reason.

ghost commented 1 year ago

BTW you can squash all your fixes and force-push, unless you want to keep them separate for some reason.

Sure, whatever works for me, at work there is a no squashing rule, but I don't have any strong feelings.

skvadrik commented 1 year ago

BTW you can squash all your fixes and force-push, unless you want to keep them separate for some reason.

Sure, whatever works for me, at work there is a no squashing rule, but I don't have any strong feelings.

Squash is fine for pull requests, when you are the only one with this history and there's no risk breaking history for others. It is not the same as squashing changes that have been merged already.

ghost commented 1 year ago

Sounds good, I will fix those issues!

skvadrik commented 1 year ago

I'm sorry for all the nit-picking, but since you have more changes to merge, I thought I'd better be picky this time to make it easier for other commits.

ghost commented 1 year ago

Sure thing, I will fix that. I kind of figured that was the case.

ghost commented 1 year ago

Looks like CI is failing with:

FAIL       golang/003_fill_bf.re
FAIL       golang/001_basic_b.re

I will look into that.

ghost commented 1 year ago

Looks like it is due to a new space being added.

87c87
<   yybm := []byte{
---
>   yybm := []byte {
ghost commented 1 year ago

Hopefully that last change resolved the issue. It at least is building and running without errors locally.