Semantic Rules / Abstract Syntax Tree Rules

First of all, are the semantic rules and the abstract rules of the syntax tree identical?

Now, if I have language specifications and I have CFG, then I need to build the abstract rules of the syntax tree. Any source is appreciated. Thank.

+5
source share
2 answers

"Abstract syntax tree" Rules (this is a strange terminology) can be interpreted as those rules that form the construction of abstract syntax in the process of parsing. They are usually written in the grammar rule for the nonterminal T as constructors over abstract syntax trees created by parsing auxiliary phrases T. If

 T = '(' A ';' B ')' ;

is a grammar rule, the AST constructor for T may be

   T(A,B)

involves building a T node with AST children constructed for subparameters A and B.

- , , . , ( "" ); , . , , ,

  "declare s as function; ...  s=7; ..."

- , (, "s - " - , declare, "s " ) , ().

+3

, , .

http://www.cs.purdue.edu/homes/xyzhang/spring11/notes/ast.pdf

:

The resulting grammar is called the concrete grammar.  
The corresponding derivation tree is called the parse tree.

> - , .

:

http://www.cs.rochester.edu/~nelson/courses/csc_173/grammars/parsetrees.html

.

0

All Articles