Deprecated: Implicit conversion from float-string "1595586368.810" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1595586368.810" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1595586368.810" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1595586368.810" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1595586368.810" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1641883686.361" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1641883686.361" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1641883686.361" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1641883686.361" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1641883686.361" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1704149317.852" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1704149317.852" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1704149317.852" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1704149317.852" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1704149317.852" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1671989614.280" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1671989614.280" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1671989614.280" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1671989614.280" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1671989614.280" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
Compiler Design: GATE CSE 1991 | Question: 10b
edited by
4,120 views
14 votes
14 votes

Consider the following grammar for arithmetic expressions using binary operators $-$ and $/$ which are not associative

  • $E \rightarrow E -T\mid T$
  • $T \rightarrow T/F\mid F$  
  • $F \rightarrow (E) \mid id$

($E$ is the start symbol)

Does the grammar allow expressions with redundant parentheses as in $({id}/{id})$ or in $id -({id}/{id})$ ? If so, convert the grammar into one which does not generate expressions with redundant parentheses. Do this with minimum number of changes to the given production rules and adding at most one more production rule.

edited by

5 Answers

0 votes
0 votes
@Sachin Sir

E → E-T | T

T → T/F | F

F →  (G) | G

G → G-id | id

By this we can reduce the redundancy

Related questions

2.7k
views
1 answers
17 votes
go_editor asked Apr 24, 2016
2,703 views
Consider the following grammar for arithmetic expressions using binary operators $-$ and $/$ which are not associative$E \rightarrow E -T\mid T$$T \rightarrow T/F\mid F$ ...
4.5k
views
3 answers
19 votes
Kathleen asked Sep 12, 2014
4,451 views
Consider the following grammar for arithmetic expressions using binary operators $-$ and $/$ which are not associative$E \rightarrow E -T\mid T$$T \rightarrow T/F\mid F$ ...
4.3k
views
3 answers
22 votes
go_editor asked Apr 24, 2016
4,267 views
For the following code, indicate the output if static scope rulesdynamic scope rulesare usedvar a,b : integer; procedure P; a := 5; b := 10; end {P}; procedure Q; var a, ...
3.6k
views
3 answers
27 votes
Kathleen asked Sep 12, 2014
3,587 views
Consider the following pseudo-code (all data items are of type integer): procedure P(a, b, c); a := 2; c := a + b; end {P} begin x := 1; y := 5; z := 100; P(x, x*y, z); W...