-
Notifications
You must be signed in to change notification settings - Fork 125
Implement a Gherkin parser in C #73
Comments
The acceptance tests use jq to normalise the JSON so that formatting differences are taken care of. e.g. https://github.com/cucumber/gherkin3/blob/master/ruby/Makefile#L32 |
Thanks @tooky that works fine and reveal some errors with table handling. I will make sure all the dataset passes and propose a MR. |
Also I have this kind of issiues: - "keyword": "And ",
+ "keyword": "And", Why would it requiere a space after the 'And' keyword? |
The space is part of the keyword because some languages (like Chinese) don't use spaces between words. |
I've taken a look at your code. It's a good start, but some substantial changes are needed before we can accept it into this project. In order to make it easy for us to maintain the various implementations, it's important that they all follow the same design. Your code doesn't bear any resemblance to the existing implementations. Please follow the guidelines for implementing a parser for a new language. For a language like C I think it is important to have 0 dependencies, since this would make it easier to use in embedded systems. The library itself shouldn't have any runtime dependencies on JSON. The AST should just be a tree of C structs, and the As for reading in the translations to configure the lexer, it would probably make sense to have a target in the One last comment - would you be able to / willing to use the existing license for the contribution? |
I'm sure Meson is very nice, but I think the build system should use only |
I read that but was not sure what that means in practice. What
I am not sure I agree with that, I think that using the GLib GScanner module is the right thing to do, and on what embeded device does the GLib not run? Also a big advantage of using the GLib is that we can then introspect the library and have bindings for many languages very easily. I could use GNode to represent the AST and json-glib in bin/gherkin-generate-ast.
You mean I should give the copyright to
I had the impression in java you had a makefile and another build system, would that be OK for you? Thanks a lot for having a look at my WIP code. |
In short, translate the existing code, using the same file names, function names, variable names etc. Of course there are idioms that are particular to each language, but the control flow should be the same. This control flow is documented at a high level in
I'm fine with that if you say so - I'm not very experienced with C.
You mean this could become a
That sounds like a good idea to me.
Sorry - I didn't mean to exclude you from the license. Could you give the copyright to
The reason Java also has Maven is that it's the most common build system for Java, and not having it would make it difficult for many Java developers to contribute. We aim to use the "standard" build tool for each language, but front everything with make to make it easier to build them all in CI. What's your motivation for adding Meson? |
That all makes a lot of sense indeed, currently the code is not properly modularized so I will follow what you describe in there.
More than that, we will have auto generated bindings for all the languages supported by Gobject Introspection (currently python, javascript, lua, experimental bindings for rust, c# (though it is not dynamic), vala...) and you can always write for other languages as well.
Sure.
I am (starting to be) involved in the Meson project and it makes my life very easy to get the build system in place with multiplatform support. Using plain Makefile in C quickly becomes a mess. |
The advice of @aslakhellesoy to limit the number of dependencies is good. From time to time there are posts on the cukes mailing list from people having problem building Cucumber-cpp, which could turn out is because they are using an old version of Visual Studio, or a miss match between the used version of gcc and the used version of the boost library, or something. So adding a dependency should not be taken lightly. I am not familiar with GLib or Meson, so I can't comment specifically on their suitability in this case. I do not understand the reference to the license for the Python implementation. That license file (and all other license files for the current language implementations) are a copy of the license file of the cucumber/gherkin3 project (copied by a rule in the Makefile). |
I pushed a few new commit no my branch where I basically factored ou the parser from the scanner and I know have a AstBuilder. |
I just realised Meson requires Python 3.4. If it ran on Python 2.7 (what's shipped on OS X) I might be ok with it, but having to install Python just to build this is too much of a burden I think. A lot of pain for little gain. Given the simplicity of this Gherkin3 I don't see why a non-standard build tool is needed. |
@brasmusson I thought the Python license had your name in it, but now I realise every sub-project gets the license from the root folder. Ideally I'd like the license to mention just the original creators of the project, and have a separate file listing contributors. Any objections to that? |
Because I would like to have for example, the API self documented and have the library introspected, I could do that with autotools too, but tbh this would be the burden :) Are you against having the thing just compiled with Makefile (if GLib is on the system and uglyly fail if it not the case) and have a proper modern build system for people who want to use the introspection and generate the doc? |
I usually do not like to give away my copyright on the code I write (from scratch, in case of patches etc... it is normal). |
I don't think we'll accept a parser that isn't generated with Berp unless there are good reasons not to do it. Gherkin3 is currently implemented in 7 languages (if we count c), and I wouldn't be surprised if that number increases to a dozen within a year or two. Very few programmers are intimate with all those languages. Therefore, in order to make it as easy as possible to refactor, fix bugs, add features and release packages it is essential that all implementations have a similar structure. For example, I don't know go at all, and very little Python. Still, I have been able to fix bugs and refactor the go and python code simply because I know where to find stuff since they follow the same structure. If one implementation looks completely different, this becomes a huge burden that will slow everything down. Another reason I prefer all parsers to be generated by Berp is that they are more likely to behave the same that way, especially when they are given grammatically incorrect gherkin. I don't know if you've started working on error messages yet, but it's essential that all implementations report parse errors in the same way. |
Fair enough - I'm happy to add you (and @brasmusson) to |
That sounds like a good compromise. I don't mind the presence of an additional, better build system at all as long as it can still be built with a standard/mainstram one (make in this case). |
Stupid question while I'm waiting for a
That just gives me:
I wasn't able to find any meson docs that tell me how to install it with pip. |
I figured out how to install it - looks like meson isn't on PyPI(?!). I just cloned the repo and ran Now I wanted to build the code. I guessed this is the magic commands:
It complained about missing packages, so I guessed I had to do a Is all of this correct? Could you please provide some guidelines in |
Is it true that meson doesn't build anything - it just generates a build file (for ninja)? I tried this:
|
Concerning generating the parser with Berp, it makes sense, I will do it (haven't had time to had a look at how that works yet, I was just wondering what your standpoint was about it).
I will provide an explanation about how to build with meson, sure.
That is correct, and it is what most build system do (autotools, cmake, scans, meson...). Meson has the advantage of handling several backends (currently ninja is the most mature one, but there is also one for xcode and visual studio) Sorry for the build failure, this is all very WIP :) I just fixed the warnings, but it looks like something is introspecting the lib with clang on OS X as it looks like on OS X the linker does not support setting -rpath adding an '='. I will have a look at that. For now you can disable the introspection (with my latest code) doing:
but tbh there is not much to see yet :) |
Thanks for your understanding @thiblahute. I realise it might be a little daunting to have to use .NET/Mono to run the berp parser generator, but it's actually pretty easy to install mono on most OSes, and you won't have to learn any .NET, except for the slightly weird Razor template syntax. |
I started implementing a Gherkin parser using the GLib and json-glib: gherkin C/glib implementation. It is currently able to generate the AST (in json) for simple scenarios without tags (yet), it supports feature/scenario/Step/tables for now. It is just the beginning but I am opening this task basically to know if you would concider that direction good for you?
Also, I started looking at the acceptance tests but it looks like it is just doing diff between expect results and actual results, but the json outputed by json-glib has minor difference in formating (name: value VS name : value for example) so diffing will just fail, am I missing somthing here?
The text was updated successfully, but these errors were encountered: