Python2 runtime, invalid syntax (?)

238 views
Skip to first unread message

Athanasios Anastasiou

unread,
Jul 16, 2015, 7:44:01 PM7/16/15
to antlr-di...@googlegroups.com
Hello everyone

Really excited to see this recently: https://theantlrguy.atlassian.net/wiki/display/ANTLR4/Python+Target

Simple grammar in hand, antlr4 -Dlanguage=Python2 simple.g4, no errors during generation.

BUT, straight into iPython to build the parsing tree (which would be fantastic on its own right now) and when:

from antlr4 import *

This happens:

  File "/usr/local/lib/python2.7/dist-packages/antlr4/Token.py", line 84
    def text(self, text:str):
                       ^
SyntaxError: invalid syntax


Is that some sort of Java remnant?

The antlr4 python2 runtime was installed via pip without any complaints.

Looking forward to hearing from you
AA

Terence Parr

unread,
Jul 16, 2015, 8:37:49 PM7/16/15
to antlr-di...@googlegroups.com
weird. i just tried on my mac:

$ pip install antlr4-python2-runtime
Collecting antlr4-python2-runtime
  Downloading antlr4-python2-runtime-4.5.2.tar.gz (108kB)
    100% |████████████████████████████████| 110kB 1.4MB/s 
Installing collected packages: antlr4-python2-runtime
  Running setup.py install for antlr4-python2-runtime
Successfully installed antlr4-python2-runtime-4.5.2
$ python
Python 2.7.9 (default, Jul  5 2015, 12:18:15) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from antlr4 import *
>>> 

seems ok.  maybe you are launching python3 and using python 2 lib?
Ter

--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Athanasios Anastasiou

unread,
Jul 17, 2015, 4:22:36 AM7/17/15
to antlr-di...@googlegroups.com
Hello Terence

Thank you for your response.

In fact, iPython starts on Python 2.7.6. Weird indeed, I just tried it on an _identical_ image at a different setup and it worked fine :/

Anyway, I am so excited to find the Python target mostly functional (I say mostly, as I haven't pushed it yet :D ), this is beautiful, a very warm "thank you" to everyone who was involved in this.

All the best
AA




--
You received this message because you are subscribed to a topic in the Google Groups "antlr-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/antlr-discussion/n6SDXXdfT3I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to antlr-discussi...@googlegroups.com.

Athanasios Anastasiou

unread,
Jul 18, 2015, 6:13:40 AM7/18/15
to antlr-di...@googlegroups.com
In case this might help to highlight some sort of small bug somewhere, I managed to resolve the situation of Python2 / Python3 runtime on my machines.

I had both antlr4-python*-runtime installed and iPython was indeed picking up the Python3 package despite it starting on top of a 2.7.6 interperter.

Perhaps there is something going on with the install script (?) because even when I have a perfectly working Python2 antlr4 runtime and subsequently install the Python3 runtime it seems to be sending its files to the 2.7 dist-packages location.

Hope this helps.

All the best
AA
Reply all
Reply to author
Forward
0 new messages