Post #2214834
2026-05-06 15:06 UTC
So let's say you're creating a DSL (Domain Specific Language).. for... Reasons™®©.. and you want to track things in the AST (Abstract Syntax Tree) and runtime values back to things in the original text. Good for you! That's a nice thing to do for users of the DSL. So cool. Your DSL script probably spans multiple lines, doesn't it? Uh huh. Ok. So in your parser, how are you detecting line breaks?
"Oh! Easy! \n!", you say.
I pause for dramatic effect, then burst out in maniacal laughter. Oh sweet summer child...
Yeah, that'll kinda work. Sorta. For *nix systems only. Unless they get files from somewhere else.
"??", you express.
Ah. See.. the world is So Much More Stupid than that.
"!?", you emote.
Yes. Lesse.. on MSDOS and Windows you need \r\n.. on a bunch of old systems (HP Series 80, Symbolics, OS-9, etc) you want just \r.. oh! But on some versions of RISC OS you want \n\r (rather than \r\n from M$).. old IBM systems want \025...
"!!", you weep.
Yeah. There are more, but they're a couple sigmas out.
Replies (1)
-
@whyrl@furry.engineer 2026-05-07 02:28
@frang@meow.social I've frequently encountered files with a combination of \n and \r\n line terminators.