digitalmars.D.learn - __stdin.d(2): Error: found End of File when expecting }
- Andre Pany (31/31) Jul 17 2019 Hi,
- H. S. Teoh (6/45) Jul 17 2019 My first suspicion is that the shell is interpreting metacharacters in
- ag0aep6g (15/43) Jul 17 2019 Check out what `echo $text` prints:
- Andre Pany (4/21) Jul 17 2019 Thanks a lot, that solved the issue.
Hi, this scripts throws 2 times this error: __stdin.d(2): Error: found End of File when expecting } following compound statement __stdin.d(2): Error: found End of File when expecting } following compound statement ``` text=" import std; void main() { while(true) { string enemy1 = readln().strip; int dist1 = to!int(readln().strip); string enemy2 = readln().strip; int dist2 = to!int(readln().strip); // Write an action using writeln() writeln(dist1 > dist2 ? enemy2 : enemy1); // Enter the code here } }" curl -fsS https://dlang.org/install.sh | bash -s dmd-2.087.0 source ~/dlang/dmd-2.087.0/activate echo $text | dmd - ``` what is here wrong? ( I execute it using on Ubuntu 18.04 LTS using WSL) Kind regards André
Jul 17 2019
On Wed, Jul 17, 2019 at 07:05:20PM +0000, Andre Pany via Digitalmars-d-learn wrote:Hi, this scripts throws 2 times this error: __stdin.d(2): Error: found End of File when expecting } following compound statement __stdin.d(2): Error: found End of File when expecting } following compound statementMy first suspicion is that the shell is interpreting metacharacters in your string and thereby mangling it. [...]``` text=" import std; void main() { while(true) { string enemy1 = readln().strip; int dist1 = to!int(readln().strip); string enemy2 = readln().strip; int dist2 = to!int(readln().strip); // Write an action using writeln() writeln(dist1 > dist2 ? enemy2 : enemy1); // Enter the code here } }" curl -fsS https://dlang.org/install.sh | bash -s dmd-2.087.0 source ~/dlang/dmd-2.087.0/activate echo $text | dmd - ``` what is here wrong? ( I execute it using on Ubuntu 18.04 LTS using WSL) Kind regards André-- IBM = I'll Buy Microsoft!
Jul 17 2019
On 17.07.19 21:05, Andre Pany wrote:``` text=" import std; void main() {    while(true)    {        string enemy1 = readln().strip;        int dist1 = to!int(readln().strip);        string enemy2 = readln().strip;        int dist2 = to!int(readln().strip);        // Write an action using writeln()        writeln(dist1 > dist2 ? enemy2 : enemy1);        // Enter the code here    } }" curl -fsS https://dlang.org/install.sh | bash -s dmd-2.087.0 source ~/dlang/dmd-2.087.0/activate echo $text | dmd - ``` what is here wrong?Check out what `echo $text` prints: ---- import std; void main() { while(true) { string enemy1 = readln().strip; int dist1 = to!int(readln().strip); string enemy2 = readln().strip; int dist2 = to!int(readln().strip); // Write an action using writeln() writeln(dist1 > dist2 ? enemy2 : enemy1); // Enter the code here } } ---- Note that it's all on one line. And remember that a "//"-style comment spans the rest of the line. That's right. Everything after the first "//" is now part of the comment, all the way to the last closing brace. Obviously, that's not valid code anymore. Try using double quotes around $text: echo "$text" | dmd -
Jul 17 2019
On Wednesday, 17 July 2019 at 20:02:51 UTC, ag0aep6g wrote:On 17.07.19 21:05, Andre Pany wrote:Thanks a lot, that solved the issue. Kind regards Andre[...]Check out what `echo $text` prints: ---- import std; void main() { while(true) { string enemy1 = readln().strip; int dist1 = to!int(readln().strip); string enemy2 = readln().strip; int dist2 = to!int(readln().strip); // Write an action using writeln() writeln(dist1 > dist2 ? enemy2 : enemy1); // Enter the code here } } ---- Note that it's all on one line. And remember that a "//"-style comment spans the rest of the line. That's right. Everything after the first "//" is now part of the comment, all the way to the last closing brace. Obviously, that's not valid code anymore. Try using double quotes around $text: echo "$text" | dmd -
Jul 17 2019