hangs on Windows

26 views
Skip to first unread message

Alex Shkotin

unread,
Dec 31, 2024, 5:48:36 AM12/31/24
to antlr-discussion
Hi all! HNY and question.

I have Python on my W10 notebook and follow https://github.com/antlr/antlr4/blob/master/doc/getting-started.md
to install antlr4:
$ pip install antlr4-tools       is OK
$ antlr4    is OK
but
$ antlr4-parse Expr.g4 prog -tree      hangs 
and after ^C I got this [1]

What to be done?

Alex

[1]

Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main

  File "<frozen runpy>", line 88, in _run_code

  File "C:\Users\Alex\AppData\Local\Programs\Python\Python311\Scripts\antlr4-parse.exe\__main__.py", line 7, in <module>

  File "C:\Users\Alex\AppData\Local\Programs\Python\Python311\Lib\site-packages\antlr4_tool_runner.py", line 146, in interp

    run_cli('org.antlr.v4.gui.Interpreter')

  File "C:\Users\Alex\AppData\Local\Programs\Python\Python311\Lib\site-packages\antlr4_tool_runner.py", line 135, in run_cli

    cp = subprocess.run([java, '-cp', jar, entrypoint]+args)

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\Alex\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 550, in run

    stdout, stderr = process.communicate(input, timeout=timeout)

                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\Alex\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1201, in communicate

    self.wait()

  File "C:\Users\Alex\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1264, in wait

    return self._wait(timeout=timeout)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\Alex\AppData\Local\Programs\Python\Python311\Lib\subprocess.py", line 1588, in _wait

    result = _winapi.WaitForSingleObject(self._handle,

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

KeyboardInterrupt


Ken Domino

unread,
Jan 1, 2025, 2:44:11 PMJan 1
to antlr-discussion
I think you can avoid the problem by using the option `-v 4.13.2`. It then avoids the issue of looking for the latest version string. See https://github.com/antlr/antlr4-tools/issues/18 https://github.com/antlr/antlr4-tools/pull/20

Alex Shkotin

unread,
Jan 2, 2025, 3:39:46 AMJan 2
to antlr-di...@googlegroups.com
Hi Ken. Thanks. 
You made me take a closer look at the situation and here's what happened.
The hang itself is actually the program waiting for input from the keyboard.
The end of the file from the keyboard is not just ^Z, but ^Z<Enter>

The better way for me is to put input into the file  and start like this
antlr4-parse Expr.g4 prog -tree IN.txt
where IN.txt=10+20*30

ср, 1 янв. 2025 г. в 22:44, Ken Domino <ken.d...@gmail.com>:
--
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.
To view this discussion visit https://groups.google.com/d/msgid/antlr-discussion/18673a64-a671-45a3-b11e-c5b718c64ba3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages