Question

I'm using ragel with C as the host language.

I can recognise a newline simply with '\n', but I need to recognise the start of the file as an alternative.

In other implementations of regex this could be given by \A or $, but $ is reserved for other purposes, '\A' maps to something else (alarm?) and \A gives a parser error.

Was it helpful?

Solution

I don't think there's an escape sequence for that. However, you can detect it by checking if Ragel's ts variable equals 0.

OTHER TIPS

In text format You have 3 choice:

  • Old mac to nr 9 \n\r (and Commodore, Apple II, Microware OS-9)

  • Unices and new Mac OS X \n ( and BeOS, AmigaOS, MorphOS, RISC OS, Multics)

  • Windows uses \r\n (and DOS, OS/2, Symbian, DEC RT-11)

in Ragel defining end of line

endline = ( "\r" | "\n" )+ @{ increase_line_number; };

the start of line is begining (any - endline)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top