Skip to content

c2cat: simplify parsing and output, check consistency#373

Merged
bvdberg merged 1 commit intoc2lang:masterfrom
chqrlie:c2cat
Apr 29, 2026
Merged

c2cat: simplify parsing and output, check consistency#373
bvdberg merged 1 commit intoc2lang:masterfrom
chqrlie:c2cat

Conversation

@chqrlie
Copy link
Copy Markdown
Contributor

@chqrlie chqrlie commented Oct 8, 2025

  • output tokens with the original spelling
  • use Style enum and select on token kind
  • add --color and --nocolor to force/disable colors in output
  • add -c and --check to suppress output and just check syntax
  • show syntax errors to stderr

@chqrlie chqrlie force-pushed the c2cat branch 4 times, most recently from 16607a5 to c546d14 Compare October 18, 2025 20:11
@chqrlie chqrlie force-pushed the c2cat branch 3 times, most recently from b8fe8d3 to 401d61e Compare October 20, 2025 20:54
@chqrlie chqrlie force-pushed the c2cat branch 3 times, most recently from 84dfd88 to 6efd5ec Compare November 5, 2025 07:56
@chqrlie chqrlie force-pushed the c2cat branch 3 times, most recently from 08828f6 to c0dfcb9 Compare November 7, 2025 15:53
@bvdberg
Copy link
Copy Markdown
Member

bvdberg commented Dec 5, 2025

The idea of c2cat is to colorize the output, otherwise you could just use 'cat'. So adding a --nocolor options does not make sense..

@chqrlie
Copy link
Copy Markdown
Contributor Author

chqrlie commented Dec 5, 2025

c2cat can also be used to just parse the tokens and check for tokenization errors, or even just benchmark the tokenizer...
I will post an update to make this more obvious.

@chqrlie chqrlie force-pushed the c2cat branch 3 times, most recently from 13c5dae to ab72339 Compare December 11, 2025 11:34
@chqrlie chqrlie force-pushed the c2cat branch 3 times, most recently from 8c594c5 to f8de547 Compare December 18, 2025 22:27
@chqrlie chqrlie force-pushed the c2cat branch 5 times, most recently from 56a5ef0 to c8d407f Compare January 2, 2026 11:42
@chqrlie chqrlie force-pushed the c2cat branch 3 times, most recently from 0ee41c1 to 522bc3c Compare January 29, 2026 09:18
@chqrlie chqrlie force-pushed the c2cat branch 4 times, most recently from ed90cff to 5a3a539 Compare March 18, 2026 18:15
@chqrlie chqrlie force-pushed the c2cat branch 4 times, most recently from 031e5eb to 3b59ba7 Compare March 24, 2026 13:26
@chqrlie chqrlie force-pushed the c2cat branch 6 times, most recently from 885703a to 334ff0f Compare April 2, 2026 12:55
@chqrlie chqrlie force-pushed the c2cat branch 6 times, most recently from c57ba10 to 9e84c3d Compare April 11, 2026 11:02
@chqrlie chqrlie force-pushed the c2cat branch 7 times, most recently from 42726bc to 1c28ea8 Compare April 15, 2026 12:54
@bvdberg
Copy link
Copy Markdown
Member

bvdberg commented Apr 29, 2026

If I run 'c2cat <file.c2> --nocolor' I still get colored output...

@chqrlie
Copy link
Copy Markdown
Contributor Author

chqrlie commented Apr 29, 2026

I fixed that: options can be specified before or after filenames.
also recognize -- to stop further option parsing.
exit status is non zero if any parsing error is detected.

* output tokens with the original spelling
* use Style enum and select on token kind
* add `--color` and `--nocolor` to force/disable color in output
* add `-c` and `--check` to suppress output and just check syntax
* show syntax errors to stderr
* command line options accepted before and after filenames
* non zero exit status on errors
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