01-前端概览

词法分析

  • 手写 - 有限自动机
  • 工具 - Lex,基于正则表达式

语法分析

  • 执行脚本语言的过程,就是遍历AST(抽象语法树)的过程
  • 知道AST的作用以后,那么,怎么构造AST?
    • 自顶向下:递归下降
    • 自底向上:搭积木,先构造小单元,在组装更大单元
    • 现成的工具:Yacc Antlr JavaCC…

语义分析

  • 消除语义模糊,生成一些属性信息,让计算机能够依据这些信息生成目标代码
  • 语义分析的某些成果,会作为属性标注在AST上
    • 比如在age这个标识符节点和45这个字节量节点上都会标识int类型
  • 树上还可以标记很多属性,有些属性在之前节点已经标注,比如行号
Author

Ryon

Posted on

2023-06-08

Updated on

2023-06-08

Licensed under

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

Comments

You forgot to set the shortname for Disqus. Please set it in _config.yml.