免费注册 查看新帖 |

Chinaunix

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

学习Lex遇到的问题集 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-02-10 12:51 |显示全部楼层 |倒序浏览
我想要提取html文件中的超链接  准备用Lex来做



这个帖子是我学习Lex遇到的问题  我的qq是 724881183  邮箱是wilbur8415@163.com


希望与大家一起交流

论坛徽章:
0
2 [报告]
发表于 2008-02-10 12:52 |显示全部楼层
2008.2.10

1)Lex开始状态  在BEGIN到某个状态后 会继续执行接下面的C语句妈?  直到把这个动作执行完?

例如 :

<STATE>.   {BEGIN   INITIAL;    int a =1;}

在STATE状态 匹配任何字符后  又跳回INITIAL状态  那么 int a=1  还会不会被执行?

(我一直理解这个BEGIN有点像 GOTO语句)


2)在执行  yy_push_state(STATE);   后   如果在某处调用了 yy_pop_state();  是不是状态就立刻跳转到 STATE状态?


3)关于动作     一般 ; (分号) 就是说忽略的意思

那么后面什么动作都没有 只有空行 是什么意思  例如:

  .|/n        /*什么都没有*/

论坛徽章:
0
3 [报告]
发表于 2008-02-10 17:29 |显示全部楼层
Three routines are available for manipulating stacks of start conditions:

`void yy_push_state(int new_state)'
pushes the current start condition onto the top of the start condition stack and switches to new_state as though you had used `BEGIN new_state' (recall that start condition names are also integers).
`void yy_pop_state()'
pops the top of the stack and switches to it via BEGIN.
`int yy_top_state()'
returns the top of the stack without altering the stack's contents.
The start condition stack grows dynamically and so has no built-in size limitation. If memory is exhausted, program execution aborts.

To use start condition stacks, your scanner must include a `%option stack' directive (see Options below).


push难道是直接转状态了 (as though you had used `BEGIN new_state' )

[ 本帖最后由 wilbur8415 于 2008-2-10 18:48 编辑 ]

论坛徽章:
0
4 [报告]
发表于 2008-02-10 18:43 |显示全部楼层
cjaizss能否先说一下 第2个的答案 因为我这里还没有linux环境 测试不了

论坛徽章:
0
5 [报告]
发表于 2008-02-10 22:10 |显示全部楼层
谢cjaizss 了 哈哈

我在看一个开源的小型搜索引擎 TSE 它里面提取链接就用的lex


我也可能提取其他的 不止是超链接 还有 图片地址等  我觉得可能用正则比较方便



我在下Cygwin  用的镜像是Cygwin.cn的    那个站点不知道是不是连接有问题 下到一

半就停止了   试了5,6遍
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP