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

lcm-gen generates invalid Python for messages with language keywords #280

Open
keilWolf opened this issue Aug 5, 2019 · 0 comments
Open

Comments

@keilWolf
Copy link

keilWolf commented Aug 5, 2019

We have a c++ project where we use a lcm message with a variable named 'pass'. There is no problem, but now we wanne use this messages with python too, but cant use them because of reserved language keywords.

eg.: example_t.lcm

package exlcm;

struct example_t
{
    string   name;
    boolean pass;
}

lcm-gen generates a python class without failure

"""LCM type definitions
This file automatically generated by lcm.
DO NOT MODIFY BY HAND!!!!
"""

try:
    import cStringIO.StringIO as BytesIO
except ImportError:
    from io import BytesIO
import struct

class example_t(object):
    __slots__ = ["name", "pass"]

    __typenames__ = ["string", "boolean"]

    __dimensions__ = [None, None]

    def __init__(self):
        self.name = ""
        self.pass = False

...

But because of the reserved keyword, its not a valid python file:

Python 2.7.12 (default, Dec  4 2017, 14:50:18)
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from example_t import example_t
  File "example_t.py", line 21
    self.pass = False
            ^
SyntaxError: invalid syntax


In [2]:

Maybe lcm-gen could check for keywords of supported languages before it translates it.

Kind regards

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

1 participant