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

Retargeted to rust #10

Open
wants to merge 93 commits into
base: retargeting
Choose a base branch
from

Conversation

db48x
Copy link

@db48x db48x commented Dec 9, 2020

All the tests pass this time around

db48x added 30 commits October 14, 2020 09:28
This adds the Rust backend, along with a command-line switch to choose
it over the cpp backend. The rust directory contains a manual port of
a generated lexer to Rust; once it compiles and works I'll be able to
make the corresponding changes to the rust-flex.skl and rust_backend.c.
turns out that two of the gotos cannot simply be replaced by loop labels
This requires an explicit break after the 'find_action loop, so that
most code paths don't actually loop after entering 'yy_match.
and add a FILE type that so that we can implement Eq for it
so there's no need for a special method to do it. Also, this method
presumably breaks things if you accidentally delete a buffer that is
in the buffer stack but isn't the current buffer.

The detail about not deallocating the buffer contents if we don't own
it can be handled at the type level in Rust; currently we just have an
owned Vec<u8> for that, but I can go back and make it generic, with a
bound of AsRef<&[u8]>, so that we can handle both the owned and
unowned cases automatically.
Still need to go in and remove yy_buffer_stack_top, since the Vec we
store the stack in already knows its own length.
We're storing the stack in a Vec, which already has that information.
Also, make the input and output streams be Option<FILE>.
It's actually buffer.init() now.
Using Scan::wrap instead.
and add a Debug impl to everything
Now that I've pretty much finished porting everything, I think that I
have enough information to replace this with ordinary reads from the
rust standard library, which would prevent this type of brain damage.
I put that in scare quotes because this is still pretty stupid,
considering that the standard library is right there…

Also, we need to actually store the number of bytes that we read.
db48x added 30 commits December 9, 2020 02:35
Rust doesn't have them; use += and -= instead.
Just to be consistent between different m4 branches.
so it must therefore be a method
Fixes both the yymorearraybol_rust and yymorearray_rust tests.
and add some m4_dnl to clean up the blank lines
when M4_NO_MODE_YYMORE_USED is defined.
Mostly the changes are in ruleset.sh, which is printing out rules to
build the "Go" tests using gcc, since the Go backend isn't quite
producing Go code yet.
now that they are generated as part of the ruleset.
by tossing in a bunch of m4_dnl to delete newline characters.
the .l.go and .l.rs rules are quite important.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant