Open kaby76 opened 1 year ago
I think that shouldn't be trace but ParserATNSimulator.trace_atn_sim = true;
trace is definitely for parser tracing.
I don't know enough about PHP to know what IO function outputs an OS-dependent newline ("\n" Linux vs "\r\n" Windows vs "\r" Mac).
print \PHP_EOL;
will do that
I mistakenly was trying to test "tracing" in a parser cross targets, and misunderstood what the "trace" levers in the API actually were, and ran into this bug.
See this.
I wrote a parser driver for the PHP target that performs a
$parser.setTrace(true);
, then ran it. The output is unusable because the trace output is all on one line.CSharp:
PHP:
The problem is this code in the PHP runtime: https://github.com/antlr/antlr-php-runtime/blob/dev/src/ParserTraceListener.php#L25
Compare that to CSharp: https://github.com/antlr/antlr4/blob/76fa05c21b12b96a6c12a0a82e611ed9d87d5af4/runtime/CSharp/src/Parser.cs#L32
WriteLine()
in C# outputs a newline character, whereasecho
in PHP does not.The easy fix is to just add
print("\n");
. I don't know enough about PHP to know what IO function outputs an OS-dependent newline ("\n" Linux vs "\r\n" Windows vs "\r" Mac).