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>
.
我正在尝试编写一个配置文件解析器,以便在非标准C环境中使用。具体来说,我不能依赖
I'm looking to use Flex, but I need to use my own input structures rather than <stdio.h>
's FILE pointers.
我想使用Flex,但我需要使用自己的输入结构而不是
2 个解决方案
#1
you can define your own input method by defining the YY_INPUT method:
您可以通过定义YY_INPUT方法来定义自己的输入方法:
%{
#define YY_INPUT(buf,result,max_size) \
{ \
int c = getchar(); \
result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
}
%}
#2
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.
Ragel是一个通用的状态机编译器,您可以在C函数中使用生成的代码。它对构建标记器有特殊支持。
#1
you can define your own input method by defining the YY_INPUT method:
您可以通过定义YY_INPUT方法来定义自己的输入方法:
%{
#define YY_INPUT(buf,result,max_size) \
{ \
int c = getchar(); \
result = (c == EOF) ? YY_NULL : (buf[0] = c, 1); \
}
%}
#2
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.
Ragel是一个通用的状态机编译器,您可以在C函数中使用生成的代码。它对构建标记器有特殊支持。