赋值语句 标识符 表达式 表达式 表达式 标识符 表达式 表达式 标识符 整数
赋值语句 标识符 表达式 表达式 + 表达式 表达式 标识符 整数 标识符 := 表达式 *
id1:=id2+id3*N idl Position d2 米 initial id3 N rate 60
id1:=id2+id3*N := + N 60 * id1 Position id2 initial id3 rate
术语 语法分析(syntax analysis or parsing) The purpose of syntax analysis is to determine the source program's phrase structure.This process is also called parsing.The source program is parsed to check whether it conforms to the source language's syntax,and to construct a suitable representation of its phrase structure. 语法树(推导树)(parse tree or derivation tree)
术语 语法分析(syntax analysis or parsing) The purpose of syntax analysis is to determine the source program’s phrase structure.This process is also called parsing.The source program is parsed to check whether it conforms to the source language’s syntax,and to construct a suitable representation of its phrase structure. 语法树(推导树)(parse tree or derivation tree)
语义分析 语义审查(静态语义) 一上下文相关性 - 类型匹配 - 类型转换 例: Program pO); Var rate:real; procedure initial; position :initial rate 60 /error * /error * /warning */
语义分析 语义审查(静态语义) – 上下文相关性 – 类型匹配 – 类型转换 例: Program p(); Var rate:real; procedure initial; … position := initial + rate * 60 /* error */ /* error */ /* warning */; …
又如: int arr [2],abc; abc=arr 10; Program p(); Var rate:real; Var initial :real; Var position real position:=initial rate 60
又如: int arr [2],abc; abc = arr * 10; … Program p(); Var rate:real; Var initial :real; Var position :real ; … position := initial + rate * 60