6.5. Syntax Graphs.   

As we did with our title-name specification, so too can we construct a syntax graph with rules that can be used to produce pseudo-code for a parser.

(1) A graph symbol for each non-terminal symbol A


A::= 1|2|3|....n
can be made depending on following rules.

 
graph_symbol1.eps
(2) Terminal symbol:

x in an i sequence corresponds to a recognising statement
for this symbol. Analyser can then advance to next symbol.

 
graph_symbol2.eps
(3) Non-terminal symbol:

This is a call to routine to analyse B.
B in an i sequence corresponds to

 
graph_symbol3.eps
(4) Constructs - choice

A::= 1|2|3|....n is a choice.
i is constructed according to same rules given.

 
graph_symbol4.eps
(5) Constructs - sequence

A::= 123....n is a sequential approach.

 
graph_symbol5.eps
(6) Constructs - iteration

i = {a}

 
graph_symbol6.eps
EXAMPLE: We shall define

<expression>::=<simple expression> |
<simple expression><relational op><simple expression>
Use S = <simple expression> P = <sign>
R = <relational operator> F = <factor>
T = <term> A = <adding operator>
M = <multiplying operator>
expression::= S|SRS

 
graph_symbol7.eps