2019/09/18 Job 03

1. Known grammar:

S->a|^|(T)

T->T,S|S

Analysis sentence (T, (^, a)), find all phrases, phrases and handle directly.

A: The following syntax tree

All phrases: ^ a ^, a (^, a) T, (^, a) (T, (^, a))

Direct phrases: ^ a

Handle: ^

 

2. The context-free grammar structure description language:

(1) {anbn|n>=0}

(2) {ambn|m>=n>=0}

(3) if the statement

The if statement

答:(1). G[S]: S->aSb | ab | ε 

     (2). G[S]: S->aSb | a | ε

  . (3) if the statement -> if <condition> then <statement> | if <condition> then <statement> else <statement>

Guess you like

Origin www.cnblogs.com/Roromiya/p/11551172.html