Fourth grammar and language work --- carding and summary

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

Over time, the second chapter books "grammar and language" learning is also coming to an end; can not say I have completely mastered the content of this chapter, but I also have a certain understanding, then I will make summary.

This chapter explains the symbol, the symbol string and grammar, which explain grammar in more detail and depth. First, there is quad grammar, each non-terminator, terminator, and an identifier rule set. The second is that there are four grammar, are 0 -type grammar, context-sensitive grammar, context-free grammars and regular grammar; here we mainly learn in depth about the grammar and context-independent, and can describe the grammar of the sentence derived intuitive tool is the syntax tree, if there is a grammar of a sentence corresponding to two different syntax tree, it says that the grammar is ambiguous. In addition to the syntax tree, we are in the process of derivation also points leftmost derivation and rightmost derivation, while the rightmost derivation is also known as canonical derivation.

In this chapter, for the grammar it is a certain understanding, but there are still do not know where. This part of grammar and syntax tree feel pretty good understanding, but a symbol that was part of the knowledge or with a lot do not know.

2. Try to write grammar PL / 0 language.

Integer n: n-> 0 | 1 | 2 | 3 | ...

Identifier i: i

Expression e: e: = a + b

Conditional statements: if A then B

Assignment: r: = m

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

Function: main ()

Program :: = [<Constant Description section>] [<Variable Description section>] [<Process Description section>] <statement>

Guess you like

Origin www.cnblogs.com/lychee2333/p/11583658.html