skvadrik / re2c

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

Dlang support #431

Closed ghost closed 1 year ago

ghost commented 1 year ago

Initial support for the D programming language. So far I have a few examples working and building and am working on fixing up the rest. I haven't done anything with the documentation yet, but can fix that up after all the examples are changed over. I am far from an expert in D, so the examples may not be very idiomatic.

So far I can build re2d with cmake and make and can run the examples like:

> re2c-build/re2d -w 01_fill.re -o 01_fill.d
> rdmd -g -w -unittest -betterC 01_fill.d
ghost commented 1 year ago

Currently failing CI with

make: *** No rule to make target 'doc/manual/syntax/api2_d.rst_', needed by 'src/msg/help.cc'.  Stop.

I will fix that next.

skvadrik commented 1 year ago

Thanks a lot for working on this, @abenedic ! Great work!

Can you split the work into smaller commits? This will make it easier for review and describe each change in commit message. E.g. one commit per each example, one (or a few) for source code, one (or a few) for documentation. Ideally each commit should build and pass the tests. You can either do this in the current PR (then I will wait until all commits in the PR look good, and then merge) or you can push into a separate branch that will be later merged into master, creating multiple PRs (not necessarily one for PR, but not all in one --- then I can merge commits as you make progress in that branch). Whatever is more convenient for you.

ghost commented 1 year ago

Can you split the work into smaller commits?

Absolutely! After I finish getting everything working properly I will go back and fix up things to look nicer.

Currently CI is failing with

/home/runner/work/re2c/re2c/build/split_man.py : unknown lang: b'd'

I should have some time later today to fix that and move over more examples.

ghost commented 1 year ago

Currently CI is failing with

/home/runner/work/re2c/re2c/.build/linux-gcc-ubsan-ootree-full/doc/manpage.rst.d:187: (SEVERE/4) Problems with "include" directive path:
InputError: [Errno 2] No such file or directory: '../../examples/d/includes/definitions.d'.

I will look over the documentation generation more thoroughly later.

ghost commented 1 year ago

I noticed that one of the tests failed due to the extension being '??' which is set by run_tests.py.in if the first line of the file isn't one of the language dependent options, "// re2d" like for D. Still in the process of converting over the examples.

skvadrik commented 1 year ago

Still in the process of converting over the examples.

You don't need to convert them all in one go --- maybe it will be easier to split patches and start review process before converting all examples (if there's something that needs to be reworked, you'll have less work to do). Also, please note that C has more examples than Go and Rust, and you can convert only those present in Go and Rust (others are optional).

ghost commented 1 year ago

I am going to keep this branch open, and pull bits from this into other pull requests. I just updated it to use the new master.