view src/ploki/examples/uncomment.pk @ 12296:042127c1c142 draft

<fizzie> ` rm /hackenv/bin/bfi; ln -s /hackenv/lib/kps/bfi /hackenv/bin/bfi # no need for actual copies that you can forget to delete though
author HackEso <hackeso@esolangs.org>
date Sat, 04 Jan 2020 13:28:36 +0000
parents ac0403686959
children
line wrap: on
line source

#!../ploki
REM Usage: uncomment.pk [FILE [...]]
REM Opens each FILE in turn, removes C (and C++) comments, and prints
REM the results to stdout. Reads from stdin if FILE is omitted.

INSERT perl-util.pk HERE
LET status 0
IF \ARG < 2
	@delcom \EING
ELSE
	LET i 1
	FOR main-loop LET fh @APERS #<\ARG:i "R"#>
	IF @NOT fh
		WUNT \FEHL "\V\ARG:0: \V\ARG:i: \V\!
		LET status @NEG 1
	ELSE
		@delcom fh
		CLAUDS fh
	FI
	LET i += 1
	IF i < \ARG
		NEXT main-loop
	FI
FI

END status

FOR delcom LEET fh \@
	LEET s fh . @NEG 1
KTHX @s///g #<s "/((\\|?!?!/)\n!)*(/((\\|?!?!/)\n|'^\n')*|*!'^*'**!+((\\|?!?!/)\n!)*('^/*''^*'**!+((\\|?!?!/)\n!)*)*{/})|{(\"((\\|?!?!/).|'^\"')*\"|'!((\\|?!?!/).|'^'!')*'!|.)'^'!\"/'*}" @OMFG (" " ] @DEF-P \1 _ \0)#>