词法分析器的输出是什么

12_321 2013-12-20 03:52:01
一般是保存为什么形式的
...全文
2987 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
d4shman 2013-12-20
  • 打赏
  • 举报
回复
lex&yacc时常用的表达式解析组合。
用lex编辑源代码,将源代码存储为a.l,然后用进行编译,输入flex a.l,编译后生成lex.yy.c(yy 指的是yacc)文件,用c编译器打开(确保example.txt存储在相同目录下),编译运行即可.
输出形式是token:<单词种别,单词符号的属性值>



参考:http://blog.csdn.net/xn4545945/article/details/8273499
赵4老师 2013-12-20
  • 打赏
  • 举报
回复
C++ Tokens A token is the smallest element of a C++ program that is meaningful to the compiler. The C++ parser recognizes these kinds of tokens: identifiers, keywords, literals, operators, punctuators, and other separators. A stream of these tokens makes up a translation unit. Tokens are usually separated by “white space.” White space can be one or more: Blanks Horizontal or vertical tabs New lines Formfeeds Comments Syntax token : keyword identifier constant operator punctuator preprocessing-token : header-name identifier pp-number character-constant string-literal operator punctuator each nonwhite-space character that cannot be one of the above The parser separates tokens from the input stream by creating the longest token possible using the input characters in a left-to-right scan. Consider this code fragment: a = i+++j; The programmer who wrote the code might have intended either of these two statements: a = i + (++j) a = (i++) + j Because the parser creates the longest token possible from the input stream, it chooses the second interpretation, making the tokens i++, +, and j.
12_321 2013-12-20
  • 打赏
  • 举报
回复
引用 1 楼 turingo 的回复:
token
引用 楼主 u012420493 的回复:
一般是保存为什么形式的
编译器的token是什么,具体什么形式,只接触过进程线程的token
图灵狗 2013-12-20
  • 打赏
  • 举报
回复
token
引用 楼主 u012420493 的回复:
一般是保存为什么形式的

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧