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

Cross-reference enums causing parsing errors #163

Open
alkorolyov opened this issue Feb 27, 2023 · 2 comments
Open

Cross-reference enums causing parsing errors #163

alkorolyov opened this issue Feb 27, 2023 · 2 comments

Comments

@alkorolyov
Copy link

Hi,

I noticed that using this type of enum causes an error, but it seems to work with the Google protobuf library. Although it should be fixable by simply removing the enum from the message declaration, the authors of the original .proto deliberately used this declaration style. I would like to attempt to implement the patch myself if it is a straightforward fix.

@thirtythreeforty and @tburmeister, I've seen that you both have contributed significantly to this repository and likely have a better understanding of the underlying details. If you have some free time, could you please provide some guidance or a starting point for addressing this issue? Thank you in advance.

message EnumMsg {
  enum EnumType {
    ENUM_FIELD = 0;
  }
}

message Test {
  EnumMsg.EnumType field = 1;
}
Exception while parsing proto\test.proto
Traceback (most recent call last):
  File "C:/Users/ergot/PycharmProjects/pyrobuf/pyrobuf/__main__.py", line 10, in <module>
    main()
  File "C:/Users/ergot/PycharmProjects/pyrobuf/pyrobuf/__main__.py", line 6, in main
    compiler.compile()
  File "C:\Users\ergot\PycharmProjects\pyrobuf\pyrobuf\compile.py", line 88, in compile
    self._compile_spec()
  File "C:\Users\ergot\PycharmProjects\pyrobuf\pyrobuf\compile.py", line 121, in _compile_spec
    self._generate(source)
  File "C:\Users\ergot\PycharmProjects\pyrobuf\pyrobuf\compile.py", line 133, in _generate
    msg_def = self.parser.parse_from_filename(filename, self.includes)
  File "C:\Users\ergot\PycharmProjects\pyrobuf\pyrobuf\parse_proto.py", line 264, in parse_from_filename
    raise e
  File "C:\Users\ergot\PycharmProjects\pyrobuf\pyrobuf\parse_proto.py", line 261, in parse_from_filename
    return cls(s).parse(fname=fname, includes=includes, disabled_tokens=disabled_tokens)
  File "C:\Users\ergot\PycharmProjects\pyrobuf\pyrobuf\parse_proto.py", line 225, in parse
    imported['enums']
  File "C:\Users\ergot\PycharmProjects\pyrobuf\pyrobuf\parse_proto.py", line 376, in _parse_message
    token.token_type, token.line + 1, self.lines[token.line])
AssertionError: unexpected ENUM_FIELD token on line 10: '  EnumMsg.EnumType field = 1;'
@tburmeister
Copy link
Collaborator

Hi @alkorolyov,

I have stopped contributing to this project and don't really have the time to continue supporting it. I would consider Pyrobuf essentially dead, though you are free to fork and use it if you like.

-Taylor

@alkorolyov
Copy link
Author

Hi @tburmeister !

Thank you for getting back to me. I was wondering if I could ask for your opinion on Cython in general. I really enjoyed using it when learning about Algorithms and Data Structures because of its native integration with Python (which I heavily use in chemoinformatics), the clean look of the code, and the speed-ups it provides. However, as I dive deeper into real-world problems, it seems that Cython has a smaller set of tools compared to more common languages like C++. Do you think it's worth investing in further learning of Cython, or would it be better to gain some competence in C++ (even though its syntax hurts my eyes :)? It would be great to have an opinion from a more experienced programmer on how often Cython is used in production code for real-life problems and what its general use case is.

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