Codinghub23
Products
Terms
Contact
How to Purchase
More
English
Español
Português
Français
Deutsch
Italiano
Русский
close
Products
Terms
Contact
How to Purchase
Starting from:
$30
Add to cart
3-address code
Write a program to generate 3-address code for programs defined by the grammar below. +, -, *, /, =, [],
if, ifFalse, goto, !, <, , <=, =, ==, !=, param, call and ret are the allowed operators. Please submit ONLY
the source files.
The interpretation of the for statement is as follows:
for id = e1, e2 block is equivalent to
for (id = e1; id < e2; id ++) block
<program - class Program { <field_decl* <method_decl* }
<field_decl - <type (<id | <id [ <int_literal ] ) ( , <id | <id [ <int_literal ] )* ;
<field_decl - <type <id = <literal ;
<method_decl - ( <type | void ) <id ( ((<type <id) ( , <type <id)*)? ) <block
<block - { <var_decl* <statement* }
<var_decl - <type <id ( , <id)* ;
<type - int | boolean
<statement - <location <assign_op <expr ;
<statement - <method_call ;
<statement - if ( <expr ) <block ( else <block )?
<statement - for <id = <expr , <expr <block
<statement - return ( <expr )? ;
<statement - break ;
<statement - continue ;
<statement - <block
<assign_op - =
<assign_op - +=
<assign_op - -=
<method_call - <method_name ( (<expr ( , <expr )*)? )
<method_call - callout ( <string_literal ( , <callout_arg )* )
<method_name - <id
<location - <id
<location - <id [ <expr ]
<expr - <location
<expr - <method_call
<expr - <literal
<expr - <expr <bin_op <expr
<expr - - <expr
<expr - ! <expr
<expr - ( <expr )
<callout_arg - <expr | <string_literal
<bin_op - <arith_op | <rel_op | <eq_op | <cond_op
<arith_op - + | - | * | / | %
<rel_op - < | | <= | =
<eq_op - == | !=
<cond_op - && | ||
<literal - <int_literal | <char_literal | <bool_literal
<id - <alpha <alpha_num*
<alpha - [a-zA-Z_]
<alpha_num - <alpha | <digit
<digit - [0-9]
<hex_digit - <digit | [a-fA-F]
<int_literal - <decimal_literal | <hex_literal
<decimal_literal - <digit <digit*
<hex_literal - 0x <hex_digit <hex_digit*
<bool_literal - true | false
<char_literal - ‘<char’
<string_literal - “<char*”
Starting from:
$30
Add to cart
1 file (299.7KB)
More products
Programming Languages and Paradigms Assignment 8
$29
Add to cart
Programming Languages and Paradigms Assignment 7
$25
Add to cart
Programming Languages and Paradigms Assignment 6
$25
Add to cart