📜  自上而下的解析与自下而上的解析之间的区别

📅  最后修改于: 2021-06-28 07:03:45             🧑  作者: Mango

解析中存在两种类型的解析技术,第一种是自上而下的解析,第二种是自下而上的解析。

自上而下的解析是一种分析技术,它首先查看语法分析树的最高级别,然后使用语法规则对语法分析树进行处理,而自下而上的语法分析是一种首先查看语法分析的最低级别的语法分析技术树,并通过使用语法规则来构成分析树。

存在一些区别以区分这两种解析技术,如下所示:

S.No Top Down Parsing Bottom Up Parsing
1. It is a parsing strategy that first looks at the highest level of the parse tree and works down the parse tree by using the rules of grammar. It is a parsing strategy that first looks at the lowest level of the parse tree and works up the parse tree by using the rules of grammar.
2. Top-down parsing attempts to find the left most derivations for an input string. Bottom-up parsing can be defined as an attempts to reduce the input string to start symbol of a grammar.
3. In this parsing technique we start parsing from top (start symbol of parse tree) to down (the leaf node of parse tree) in top-down manner. In this parsing technique we start parsing from bottom (leaf node of parse tree) to up (the start symbol of parse tree) in bottom-up manner.
4. This parsing technique uses Left Most Derivation. This parsing technique uses Right Most Derivation.
5. It’s main decision is to select what production rule to use in order to construct the string. It’s main decision is to select when to use a production rule to reduce the string to get the starting symbol.