【发布时间】:2012-05-10 04:34:52
【问题描述】:
所以我必须制作一个匹配数字、浮点数、符号和 cmets 的 flex 程序。 正则表达式在文件中。
flex.l 文件http://pastebin.com/iuJ8WW6m
奇怪的是输出。
假设我给它:
0 0.0 323 323.4 1.3.4
variable another_variable
"string"
;comment
69
这是输出:
Number: -->0<--
Float: -->0.0<--
Number: -->323<--
Float: -->323.4<--
Float: -->1.3<--
Number: -->4<--
Symbol: -->variable<--
<--bol: -->another_variable
String: -->"string"<--
<--ment: -->;comment
Number: -->69<--
为什么“another_variable”的输出是这样的 another_variable ? 我知道一些 c/c++,对我来说这是 0 意义。
;comment
显然它需要最后 3 个字符 (
如果我只给它
;comment
输出是“评论:-->;评论
帮忙,谢谢!
【问题讨论】:
-
这是输出到终端吗?什么外壳/终端?到文本文件?
-
我正在使用 cygwin 编译它(在windwos上)。是的,输出是一个终端。