免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3895 | 回复: 5
打印 上一主题 下一主题

[C] 关于flex的多线程 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-06-14 10:38 |只看该作者 |倒序浏览
最近用flex&bison的时候,发现貌似默认flex是不可重入的,开多个线程同时调用yyparse()的时候,flex就混乱了,查了资料说flex的c代码默认是不可重入的,c++是可重入的,不过c代码加一些参数就可以实现多线程安全了,不知道有没有人了解具体怎么实现,指教下,谢谢

论坛徽章:
0
2 [报告]
发表于 2010-06-14 12:38 |只看该作者
加入
%pure_parser

论坛徽章:
0
3 [报告]
发表于 2010-06-14 13:27 |只看该作者
ls能详细点吗?

单单加一句pure_parse貌似不行,

论坛徽章:
0
4 [报告]
发表于 2010-06-14 21:52 |只看该作者
info flex
这种基本的能力你自己要会。

  1. `-R, --reentrant, `%option reentrant''
  2.      instructs flex to generate a reentrant C scanner.  The generated
  3.      scanner may safely be used in a multi-threaded environment. The
  4.      API for a reentrant scanner is different than for a non-reentrant
  5.      scanner *note Reentrant::).  Because of the API difference between
  6.      reentrant and non-reentrant `flex' scanners, non-reentrant flex
  7.      code must be modified before it is suitable for use with this
  8.      option.  This option is not compatible with the `--c++' option.

  9.      The option `--reentrant' does not affect the performance of the
  10.      scanner.
复制代码

  1. 19 Reentrant C Scanners
  2. ***********************

  3. `flex' has the ability to generate a reentrant C scanner. This is
  4. accomplished by specifying `%option reentrant' (`-R') The generated
  5. scanner is both portable, and safe to use in one or more separate
  6. threads of control.  The most common use for reentrant scanners is from
  7. within multi-threaded applications.  Any thread may create and execute
  8. a reentrant `flex' scanner without the need for synchronization with
  9. other threads.
复制代码

论坛徽章:
0
5 [报告]
发表于 2010-06-14 22:00 |只看该作者
如果你还不明白,那就自己想办法把
http://compilers.iecc.com/comparch/article/98-01-017
这个链接你可以参考一下

论坛徽章:
0
6 [报告]
发表于 2010-06-14 22:03 |只看该作者
看看,喜欢好的创意
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP