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

Remove extra crlf from ast_fprint #2555

Merged
merged 1 commit into from
Feb 21, 2018

Conversation

winksaville
Copy link
Contributor

the print routine in ast.c already prints a crlf so the one printed
in ast_fprint is unnecessary, this change removes the extra crlf.

To test I added some consecutive ast_print statements to
suggest_alt_name:

   if(case_ast != NULL)
   {
+    AST_GET_CHILDREN(case_ast, first, second);
+    printf("suggest_alt_name:    ast "); ast_print(ast, 200);
+    printf("suggest_alt_name:  first "); ast_print(first, 200);
+    printf("suggest_alt_name: second "); ast_print(second, 200);
+
+    return NULL;
+

Before this change the output would be:

$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))

suggest_alt_name:  first box

suggest_alt_name: second (id doIt)

suggest_alt_name:    ast (reference (id astr))

suggest_alt_name:  first (id aStr)

suggest_alt_name: second (nominal (id $0) (id String) x val x x)

Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^

After removing the extra crlf in this change the output is nicer:

$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))
suggest_alt_name:  first box
suggest_alt_name: second (id doIt)
suggest_alt_name:    ast (reference (id astr))
suggest_alt_name:  first (id aStr)
suggest_alt_name: second (nominal (id $0) (id String) x val x x)
Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^

the print routine in ast.c already prints a crlf so the one printed
in ast_fprint is unnecessary, this change removes the extra crlf.

To test I added some consecutive ast_print statements to
suggest_alt_name:
```
   if(case_ast != NULL)
   {
+    AST_GET_CHILDREN(case_ast, first, second);
+    printf("suggest_alt_name:    ast "); ast_print(ast, 200);
+    printf("suggest_alt_name:  first "); ast_print(first, 200);
+    printf("suggest_alt_name: second "); ast_print(second, 200);
+
+    return NULL;
+
```
Before this change the output would be:
```
$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))

suggest_alt_name:  first box

suggest_alt_name: second (id doIt)

suggest_alt_name:    ast (reference (id astr))

suggest_alt_name:  first (id aStr)

suggest_alt_name: second (nominal (id $0) (id String) x val x x)

Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^
```
After removing the extra crlf in this change the output is nicer:
```
$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))
suggest_alt_name:  first box
suggest_alt_name: second (id doIt)
suggest_alt_name:    ast (reference (id astr))
suggest_alt_name:  first (id aStr)
suggest_alt_name: second (nominal (id $0) (id String) x val x x)
Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^
```
@jemc jemc merged commit e93d552 into ponylang:master Feb 21, 2018
dipinhora pushed a commit to dipinhora/ponyc that referenced this pull request Jun 5, 2018
the print routine in ast.c already prints a crlf so the one printed
in ast_fprint is unnecessary, this change removes the extra crlf.

To test I added some consecutive ast_print statements to
suggest_alt_name:
```
   if(case_ast != NULL)
   {
+    AST_GET_CHILDREN(case_ast, first, second);
+    printf("suggest_alt_name:    ast "); ast_print(ast, 200);
+    printf("suggest_alt_name:  first "); ast_print(first, 200);
+    printf("suggest_alt_name: second "); ast_print(second, 200);
+
+    return NULL;
+
```
Before this change the output would be:
```
$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))

suggest_alt_name:  first box

suggest_alt_name: second (id doIt)

suggest_alt_name:    ast (reference (id astr))

suggest_alt_name:  first (id aStr)

suggest_alt_name: second (nominal (id $0) (id String) x val x x)

Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^
```
After removing the extra crlf in this change the output is nicer:
```
$ ./build/debug/ponyc ../issue-2508/
Building builtin -> /home/wink/prgs/pony/ponyc/packages/builtin
Building ../issue-2508/ -> /home/wink/prgs/pony/issue-2508
suggest_alt_name:    ast (reference (id doit))
suggest_alt_name:  first box
suggest_alt_name: second (id doIt)
suggest_alt_name:    ast (reference (id astr))
suggest_alt_name:  first (id aStr)
suggest_alt_name: second (nominal (id $0) (id String) x val x x)
Error:
/home/wink/prgs/pony/issue-2508/main.pony:5:5: can't find declaration of 'doit'
    doit() // crash compiler
    ^
Error:
/home/wink/prgs/pony/issue-2508/main.pony:10:5: can't find declaration of 'astr'
    astr
    ^
```
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

Successfully merging this pull request may close these issues.

2 participants