Compiler theory work 4

1. carding second chapter, understand and write a summary.

 A: Through the study of the second chapter, I learned the grammar of the visual concept, in the form of symbols and strings, grammar and language definition, focusing on the type of knowledge of grammar, context-free grammar and syntax tree, sentence analysis.

to sum up:

1, language is a sign system, a complete definition includes both syntax and semantics.

2, the syntax is a set of rules description language, grammar is used to illustrate an important tool in the form of these grammar rules.

3, including static semantic semantics and dynamic semantics, semantics clarify difficult than grammar and more.

 

 

2. Try to write grammar PL / 0 language. (Or do you think the better language rules)

Integer n n :: = 1 | 2 | ..... | 9 | 0

Identifier i i :: = <letters> | {<letters> | <number>}

Expression e :: = [+ | -] <item> {<subtraction operator> <term>}

Conditional statement :: = if <condition> then <statement>

Assignment :: = <id>: = <expression>

Compound statement :: = begin <statement> {; <statement>} end

Function :: = <Description Type> <function name> <compound statement>

 

 

Guess you like

Origin www.cnblogs.com/cnw834575008/p/11583461.html