The Gateway to Computer Science Excellence
+1 vote
32 views

Translate the  following arithmetic expression into:

  1. $a=b[i]+c[j]$
  2. $a[i]=b\ast c-b\ast d$
  3. $x=f(y+1)+2$
  4. $x=\ast p + \&y$

 

  1. A Syntax tree
  2. Quadruples
  3. Triples
  4. Indirect triples
in Compiler Design by Veteran (55k points) | 32 views

1 Answer

+2 votes

1. a=b[i]+c[j]

Quadruples

  Operator Argument1 Argument2 Result
0 =[] b i t1
1 =[] c j t2
2 + t1 t2 t3
3 = t3   a

Triples

  Operator Argument1 Argument2
0 =[] b i
1 =[] c j
2 + (0) (1)
3 = a (2)

Indirect Triples

0 (0)
1 (1)
2 (2)
3 (3)

 

2. a[i]=b∗c−b∗d

Quadruples

  Operator Argument1 Argument2 Result
0 * b c t1
1 * b d t2
2 - t1 t2 t3
3 []= a i t4
4 = t3   t4

Triples

  Operator Argument1 Argument2
0 * b c
1 * b d
2 - (0) (1)
3 []= a i
4 = (3) (2)
by Active (5.1k points)
edited by
0

Is it right for equation 3 & 4?

0
i'm not sure of representing function calls in DAG
0

@Lakshman Patel RJIT

Do you know the answers?

0
I don't have answers. You can download the solution of this book and cross verify it.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,616 answers
195,897 comments
102,352 users