dlang-community / Pegged

A Parsing Expression Grammar (PEG) module, using the D programming language.
534 stars 66 forks source link

Unit tests fail on 64 bit Linux. #123

Closed Nekroze closed 11 years ago

Nekroze commented 11 years ago

Using both my Ubunu and Arch Linux 64 bit machines the unit tests fail when run via dub:

$ dub run --build=unittest

which causes a set of warnings and then the unit test errors. The warnings appear on every build of type of pegged using dub and afaik they have no effect on the unit tests failing but just in case:

## Warning for package pegged ##

The following compiler flags have been specified in the package description
file. They are handled by DUB and direct use in packages is discouraged.
Alternatively, you can set the DFLAGS environment variable to pass custom flags
to the compiler, or use one of the suggestions below:

-wi: Use the "buildRequirements" field to control warning behavior
-property: Using this flag may break building of dependencies and it will probably be removed from DMD in the future

The following however is where the tests seam to fail hard on 64 bit only:

pegged/tester/grammartester.d(382): Error: cannot implicitly convert expression (max(this.max1stColumnWidth, ltext.length)) of type ulong to int
pegged/tester/grammartester.d(290): Error: cannot implicitly convert expression (j) of type ulong to int
pegged/tester/grammartester.d(116): Error: template instance pegged.tester.grammartester.Differencer!(ParseTree, ParseTree) error instantiating
pegged/tester/grammartester.d(86):        instantiated from here: getDifferencer!(ParseTree, ParseTree)
pegged/tester/grammartester.d(396):        instantiated from here: GrammarTester!(TesterGrammar, "Root")
pegged/tester/grammartester.d(86): Error: template instance pegged.tester.grammartester.GrammarTester!(TesterGrammar, "Root").GrammarTester.getDifferencer!(ParseTree, ParseTree) error instantiating
pegged/tester/grammartester.d(396):        instantiated from here: GrammarTester!(TesterGrammar, "Root")
pegged/tester/grammartester.d(396): Error: template instance pegged.tester.grammartester.GrammarTester!(TesterGrammar, "Root") error instantiating
Error: DMD compile run failed with exit code 1

I have confirmed that this works fine on my 32 bit Arch laptop which can run both of the following commands to compile and run the unit tests perfectly fine:

$ dub build --build=unittest
$ dub run --build=unittest

However it cannot even build the unittests on 64 bit. The reason I am having a major problem with this is that by using pegged as a dependency through dub, whenever i build my project with the intention of running the unit tests, all of pegged's unit tests get compiled in as well because dub seems to only work for source libraries at present. This obviously causes all of my unit testing to fail before it even gets to my project.

Thanks for the great work on this library and have a good day.

PhilippeSigaud commented 11 years ago

I'll have a look. I didn't write grammartester, though, so it may take me a while.

PhilippeSigaud commented 11 years ago

I changed a bunch of ints to size_ts. I haven't used GitHub in months, I hope the pull worked. That was tested with waf: all green. But I only have a 32bit machine, can you tell me if it works for you?

Nekroze commented 11 years ago

I can indeed confirm that this issue is now solved and the tests pass both directly from within pegged and when using pegged as a dependency in dub.

Any idea on those dub warnings then or can they be safely ignored? Lastly, and sorry to ask but I need to know before I base my new project around pegged, are you slowing development on pegged currently? if so is it permanent?

Thanks for the swift assistance.

PhilippeSigaud commented 11 years ago

I'm afraid I do not know dub, so I cannot help you with that. I find it a bit cumbersome that it also compiles and runs unit tests in dependencies, but I guess it's logical if it creates anything from source. Maybe you could also compile Pegged as a library and use it as such?

As for Pegged development, I reached a stage where I cannot go farther without improvements in the DMD CTFE engine. Hopefully, the D devs are working on it. I also had some problems with some D bugs, so I'm waiting for the next DMD to arrive.

I planned to get an LR parser into Pegged but got side-tracked into writing a D raytracer. Such is the joy of coding during my free time ;-)

I'm still committed to squash any bug that should appear in Pegged. Do not hesitate to report any issue you encounter.

May I ask what is your own project?

Nekroze commented 11 years ago

I have long wanted to use llvm to write my own little toy programming language. However I have used python for so long now that I cannot stand all of the pains of c++.

So I am planning on using pegged and llvm-d and playing around with making my own programming language designed specifically for making game development easier. I don't think I want to hand write my own parser and pegged always seemed like a cool way to do things so it's the perfect choice.

It will probably never amount to much other then a fun learning proccess but you seem to understand that kind of thing. Its just about fun and learning really nothing serious at this point. I have been (very loosely as I am new to this kind of thing) keeping a blog(http://ninja.eturnilnetwork.com) about my thoughts while researching and experimenting with ways to do this. The blog really just shows how non-commital I have been thus far in finding a framework to do this as its more a long term in spare time project.

Thanks for the honest response mate.

PhilippeSigaud commented 11 years ago

I see. This sounds fun! Don't hesitate to tell me of any bug you find.

Nekroze commented 11 years ago

Will do thanks.