Git Product home page Git Product logo

crust's Introduction

Nishanth Shetty

Hi, there.

As Turing said, "Mathematician with the different ability".

Software engineer with 6+ years of experience learning, building and deploying systems.

  • I spend my time working on Golang as mainstream language.
  • I also spend time tinkering around other languages and tools.
  • Building distributed message queue.
  • neovimer ๐Ÿคทโ€โ™‚๏ธ

NishanthSpShetty's Stats

NishanthSpShetty's Streak

NishanthSpShetty's Top Languages

Follow me on nsphub.in

Nishanth Shetty | LinkedIn Nishanth Shetty | Medium

crust's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crust's Issues

Error on every file: index out of bounds

Hello,

I had read about crust a while ago and was looking forward to a reason to try it out!

Unfortunately, I'm not having any luck using it on a fairly small C++ project: https://github.com/wez/atomicparsley

On nearly every file in the codebase, I get an index out of bounds error:

$ crust src/uuid.cpp 
Input file size : 16474bytes 
TokenizingInvoking Parser....
thread 'main' panicked at 'index out of bounds: the len is 1539 but the index is 1539', src/library/parser/parser.rs:655:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It does succeed on e.g. array.rs, as well as a hello_world.cpp that I tried it on.

Is there a general workflow for me to figure out what the issue may be with these files?

Infinite loop on scope resolution

I found an issue where your code seems to go into an infinite loop trying to resolve a token.

After debugging it I believe it's getting stuck on "Entity::" in the operator== overload line in the cpp file provided below

I'm invoking the command as follows

$ crust
Enter the C/C++ file to be converted to Rust : Entity.cpp
Enter the translation mode [(S/s)trict/(L/l)oose] : S
Do you want to create a cargo project :[Y/N]N
Input file size : 126bytes

At which point it seemingly gets stuck utilizing 100% of one cpu core on my computer.
Running it with loose mode behaves the same.

Here is a minimal piece of code that shows the same issue
entity.hpp:

#include <cstdint>
namespace test
{
	class Entity
	{
	public:
		bool operator==(const Entity& other) const;
	private:
		std::size_t mId;
	};
}

entity.cpp:

#include <entity.hpp>
using namespace test;
bool Entity::operator==(const Entity& other) const
{
	return mId == other.mId;
}

License?

Hallo,
which license has this project?
Thanks
Wolfgang

Wrong output when doing addition on short

#include <iostream>
using namespace std;

int main() {
    
    short a = 32767;
    short b = 32767;
    int c = a + b;
    cout<<c;
}

Current crust will produce something like this

...
 fn main ( ) {
   ...
   let mut a : i16 = 32767 ; let mut b : i16 = 32767 ; 
   let mut c : i32 = a+b ;  // ~~> wrong
   ...
 }

Its seems crust don't handle c integer promotion from short to int.

Crust not recognized auto keyword

int main() {
    auto foo = 255;
}

its seem crust not handling auto keyword because the rust output don't make sense.

let foo = auto {};

Panic when file not exist

Running crust and give it some not existing filename will trigger a panic

D:\repo\crust>cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target\debug\crust.exe`
Enter the C/C++ file to be converted to Rust : dsfdf
Enter the translation mode [(S/s)trict/(L/l)oose] :
Do you want to create a cargo project :[Y/N]
thread 'main' panicked at 'Unable to open input source file.', src\main.rs:56
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: process didn't exit successfully: `target\debug\crust.exe` (exit code: 101)

index out of bounds: the len is 10 but the index is 10

C++ code

// /tmp/test1.cc
struct simple {
	const char* hi;
};

int main(void) {
}

C++ compiler output

g++

$ rm ./a.out; g++ --version; g++ /tmp/test1.cc && ./a.out; echo $?
g++ (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

0

clang++

$ rm ./a.out; clang++ --version; clang++ /tmp/test1.cc && ./a.out; echo $?
Debian clang version 11.0.1-2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
0

Error

$ crust --strict /tmp/test1.cc
Input file size : 138bytes 
TokenizingInvoking Parser....
thread 'main' panicked at 'index out of bounds: the len is 10 but the index is 10', src/library/parser/parser.rs:1700:19
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Can I convert an entire folder of C/C++ files to Rust?

I've been looking at C2Rust a lot, I love that this one can handle C++ as well!! And that's it's written in Rust itself, meaning I don't have to download 3 or 4 external softwares so that C2Rust can use LLVM to do the actual conversion, and it doesn't even work on Windows. Seems like this one might also preserve comments. Awesome!! Don't have to mention,therefore advertising, C2Rust but please stress some of these things in your ReadMe.md

Anyway, one big issue I see those is that conversion has to be done on a file by file basis. Would be really nice and seems relatively easy to modify it to allow calling converting all c or cpp (and h) files in one folder to another folder recursively going through multiple levels and recreating those subfolders in the new folder.

One other thing to point out, C2Rust will transpile header declarations from any headers that are included so that the user can link the resulting Rust code against the same set of shared libraries as the C code did. Would be a nice feature to include.

Thanks for all the hard work!! Love this project and can't wait to play with it!!

Crusty crashed

I attempted to convert a small main.cpp file and crusty dumped core:

[developer@devvm crust-master]$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running target/debug/crust
Enter the C/C++ file to be converted to Rust : /home/developer/develop/XXX/src/main.cpp
Enter the translation mode [(S/s)trict/(L/l)oose] : S
Do you want to create a cargo project :[Y/N]Y
Enter cargo project name : XXX
Input file size : 1671bytes
memory allocation of 34359738368 bytes failed
Aborted (core dumped)

The main.cpp contains a call a boost sleep function. Is that the issue?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.