-
Notifications
You must be signed in to change notification settings - Fork 37
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
print does not print anything if not followed by a space or ";" #73
Comments
Nice find! This was a lexer issue. Didn't intend to close this immediately, though I do think the commit above should fix things. I'll double-check soon and close this once there's a new version. |
I found it by running one of the onetrueawk tests. |
Similar issue with split: $ echo 'a b c' | frawk '{n = split($0, x, " "); print n; }'
3
$ echo 'a b c' | frawk '{n = split ($0, x, " "); print n; }'
$ echo 'a b c' | mawk '{n = split ($0, x, " "); print n; }'
3
$ echo 'a b c' | tawk '{n = split ($0, x, " "); print n; }'
3
$ echo 'a b c' | gawk '{n = split ($0, x, " "); print n; }'
3 And substr:
I assume that spaces are always allowed after a function name and before a "(". printf without arguments probably shouldn't be allowed (although tawk behaves differently): $ echo 'a' | tawk '{printf}'
a[no_newline]
# Doesn't print anything.
$ echo 'a' | frawk '{printf}'
$ echo 'a' | frawk '{printf;}'
Unrecognized token `;` found at line 1, column 8:line 1, column 9
Expected one of "!", "$", "(", "+", "++", "-", "--", "CALLSTART", "FLOAT", "HEX", "IDENT", "INT", "PATLIT" or "STRLIT"
$ echo 'a' | mawk '{printf}'
mawk: line 1: no arguments in call to printf
$ echo 'a' | gawk '{printf}'
gawk: cmd. line:1: (FILENAME=- FNR=1) fatal: printf: no arguments |
This isn't quite true.. in awk you can add spaces but only for builtin functions. For user-defined functions no spaces are allowed:
frawk treats all functions the same. This was a deliberate choice on my part to simplify parsing, and also avoid confusion. I could see adding it in, but if so I'd probably file it as a separate issue. |
In mawk it also works for custom functions (but not in gawk and onetrueawk).
It is indeed a pity that AWK allows so many small variations of the syntax. It would be nice if frawk would have an option which would run the passed awk code trough
This approach would of course only work when the provided awk programs don't contain frawk specific features. |
Just so I'm following correctly, are there any new examples here other than "spaces between function name and args" and the semicolon issues you pointed out in #49? If not, I may file a separate issue for the first issue and close this one. I'd really prefer to fix frawk's parsing rather than add a dependency on a separate tool, to say nothing of potential licensing issues of including something like gawk with frawk. I do understand that frawk has parsing bugs, though, and I really appreciate you pointing them out and filing these issues. |
The text was updated successfully, but these errors were encountered: