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

piqic-ocaml generates faulty output on some piqi files #2

Closed
vbmithr opened this issue Apr 13, 2014 · 3 comments
Closed

piqic-ocaml generates faulty output on some piqi files #2

vbmithr opened this issue Apr 13, 2014 · 3 comments

Comments

@vbmithr
Copy link

vbmithr commented Apr 13, 2014

When tring to generate ocaml code for this1 proto file (via piqi), the output ml files does not compile:

[vb@nerenyi ~/code/ocaml-ripple/thin]% piqic-ocaml ripple.proto.piqi                                       
[vb@nerenyi ~/code/ocaml-ripple/thin]% ocamlc ripple_piqi.ml                                               
File "ripple_piqi.ml", line 1, characters 7638-7642:
Error: Syntax error: 'end' expected
File "ripple_piqi.ml", line 1, characters 7616-7619:
Error: This 'sig' might be unmatched
zsh: exit 2     ocamlc ripple_piqi.ml
@alavrik
Copy link
Owner

alavrik commented Apr 14, 2014

This is because the original ripple.proto defines a field named type which is a keyword in OCaml.

There is a standard solution for that. All you have to do is define explicit OCaml names for these fields that override the default names from the original spec. If you created ripple.ocaml.piqi with the following contents and put it next to ripple.proto.piqi everything should work.

By the way, you may want to pull the latest changes from master. One of the changes (pretty-printing generated code) should make it easy to see why the code is failing to compile.

ripple.ocaml.piqi:

.include [ .module ripple ]

.extend [
    (.field TMGetObjectByHash.type TMLedgerData.type TMPing.type)

    .with.ocaml-name "piqi_type"
]

.custom-field ocaml-name

Related issues:

alavrik/piqi#24
#1

@vbmithr
Copy link
Author

vbmithr commented Apr 15, 2014

Thanks for the detailled information. Very helpful!

@alavrik
Copy link
Owner

alavrik commented May 17, 2014

Solved by #3. Closing.

@alavrik alavrik closed this as completed May 17, 2014
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

No branches or pull requests

2 participants