If anyone wants to take a stab at it and send a pull request, I'm happy to bring it in.
Rough idea for the parsing:
Remove comments (start with '//)
Split on whitespace but honor whitespace in quotes.
Quoted tokens are string literals
Check the token against a map (Example, ESC would convert to 1B)
Check if the token starts with 0x and convert from the hex.
Otherwise token is decimal
Map
'// ============================================================================
'// Issuing receipts
'// ============================================================================
'// Initialize printer
ESC "@"
'// --- Print stamp --->>>
'// Set line spacing: For the TM-T20, 1.13 mm (18/406 inches)
ESC "3" 18
'// Set unidirectional print mode: Cancel unidirectional print mode (Unnecessary
'// in the TM-T20, so it is comment out)
'// For models equipped with the ESC U command, implementation is recommended.
'// Designate unidirectional printing with the ESC U command to get a print
'// result with equal upper and lower parts for the stamp frame symbol
'// ESC "U" 1
'// Select justification: Centering
ESC "a" 1
Epson has an example format for receipts that looks like it can be parsed and converted into binary format.
See: https://download4.epson.biz/sec_pubs/pos/reference_en/escpos/receipt.html
If anyone wants to take a stab at it and send a pull request, I'm happy to bring it in.
Rough idea for the parsing:
'//
)Map