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

Exit 1 and print to stderr on parse error #28

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

kentakayama
Copy link
Contributor

Solves #27 .
These changes may affect a lot, including https://cbor.me/ .

@kentakayama
Copy link
Contributor Author

Before

$ echo "[]," | diag2cbor.rb > tailcomma.cbor
$ echo $?
0
$ cat tailcomma.cbor
*** can't parse [],
*** Expected one of [ \t\n\r], "/", '"', '{', '[', [0-9], [-+], '0', 'Infinity', '-Infinity', 'NaN', 'false', 'true', 'null', 'undefined', 'simple(', "h'", "'", "b64'", [a-z], "<<", '(' at line 2, column 1 (byte 5) after ,

$ echo "[0:1]" | diag2cbor.rb > colon_in_array.cbor
$ echo $?
0
$ cat colon_in_array.cbor
*** can't parse [0:1]
*** Expected one of [0-9], '(', [xX], [oO], [bB], '.', [Ee], [ \t\n\r], "/", ',', ']' at line 1, column 3 (byte 3) after [0

After

$ echo "[]," | diag2cbor.rb > tailcomma.cbor
*** can't parse [],
*** Expected one of [ \t\n\r], "/", '"', '{', '[', [0-9], [-+], '0', 'Infinity', '-Infinity', 'NaN', 'false', 'true', 'null', 'undefined', 'simple(', "h'", "'", "b64'", [a-z], "<<", '(' at line 2, column 1 (byte 5) after ,
$ echo $?
1
$ cat tailcomma.cbor

$ echo "[0:1]" | diag2cbor.rb > colon_in_array.cbor
*** can't parse [0:1]
*** Expected one of [0-9], '(', [xX], [oO], [bB], '.', [Ee], [ \t\n\r], "/", ',', ']' at line 1, column 3 (byte 3) after [0
$ echo $?
1
$ cat colon_in_array.cbor

@cabo
Copy link
Owner

cabo commented Sep 4, 2024

Thanks!
I'm on a keyboardless vacation right now; will get to this once back in Europe.

@kentakayama
Copy link
Contributor Author

Forget about this for a while, and have a nice vacation!

@cabo cabo merged commit ef05f4d into cabo:master Sep 18, 2024
@cabo
Copy link
Owner

cabo commented Sep 18, 2024

Merged, changed $stderr.puts style to warn, pushed gem 0.9.5 with this.
Thank you again!

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