在编译的哪个步骤中删除注释? [英] In which step of compilation are comments removed?

查看:19
本文介绍了在编译的哪个步骤中删除注释?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编译一个程序有几个步骤:

  • 线重建
  • 词法分析
  • 预处理.
  • 语法分析
  • 语义分析

第一步去除评论是线路重构"吗?

Is removal of comments in the first step "line reconstruction"?

推荐答案

  • 预处理是它自己的一个阶段,它有自己的扫描和解析,先于词法分析.
  • 我是一名编译器作家,我从未听说过行重建".编译器不处理行:它们处理令牌流.您的引文特别指出,这是一些奇怪语言的特例.
  • 您忽略了流程分析、优化、寄存器分配和代码生成等.
  • 在词法分析过程中,评论被忽略,而不是被删除,有时在概念上将其描述为筛选"和扫描",在这种情况下,您可以说评论被筛选掉,就像空格一样.
    • Preprocessing is a phase of its own with its own scanning and parsing, which precede lexical analysis.
    • I'm a compiler writer and I've never heard of 'line reconstruction'. Compilers don't process lines: they process token streams. Your citation specifically says this is a special case for a few odd languages.
    • You've left out flow analysis, optimization, register allocation, and code generation, and a few more.
    • Comments are ignored, not removed, during lexical analysis, which is sometimes conceptually described as 'screening' and 'scanning', in which case you can say comments are screened out, like white space.
    • 这篇关于在编译的哪个步骤中删除注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆