views:

100

answers:

2

I'm trying to write a config-file parser for use in a non-standard C environment. Specifically, I can't rely on the utilities provided by <stdio.h>.

I'm looking to use Flex, but I need to use my own input structures rather than <stdio.h>'s FILE pointers.

+1  A: 

Ragel is a generic state machine compiler, which you can use the generated code inside a C function. It has special support for building tokenizers.

artificialidiot
+2  A: 

you can define your own input method by defining the YY_INPUT method:

 %{
     #define YY_INPUT(buf,result,max_size) \
         { \
         int c = getchar(); \
         result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
         }
     %}
Maurice Perry
Thanks, that looks like exactly what I'm looking for.
lacqui