BeginComment:
This program reads bytes from STDIN and prints them in decimal format.

Copyright © 2020 Richard Lesh.  All rights reserved.
EndComment

Pragma: UseUtils

BeginProgram: StreamIO3

BeginMain:
	Statement: binmode(STDIN)
	ScalarDecl: <getbyte_t>? c
	ScalarDecl: <int> count = 0
###############################################################################
# Python and Swift don't have assignment operators usually
# used in this type of input loop so we have to assign separately.
###############################################################################
BeginEval: language =~ m/py|swift/
	BeginFor: getbyte(c); c != EOF; getbyte(c)
		Print: c!, " "
		Assign: count += 1
		BeginIf: count % 20 == 0
			PrintLine:
		EndIf
	EndFor
ElseEval
	BeginWhile: getbyte(c)
BeginEval: language =~ m/cpp/
		Print: ord(c), " "
ElseEval
		Print: c, " "
EndEval
		Assign: count += 1
		BeginIf: count % 20 == 0
			PrintLine:
		EndIf
	EndWhile
EndEval
	BeginIf: count % 20 != 0
		PrintLine:
	EndIf
EndMain
EndProgram
