Question: Only solve question two please, question one is also uploaded on top for helping develop q2 Domain-specific languages (DSLs) are languages specialized for particular domains.


Only solve question two please, question one is also uploaded on top for helping develop q2
Domain-specific languages (DSLs) are languages specialized for particular domains. HTML, SQL, etc., are examples of DSLs. In this assignment, you have to develop a DSL for tensor algebra and implement a subset of its operators. A tensor is a higher dimensional analog of a matrix. A vector is a 1D tensor, and a matrix is a 2D tensor, and so on. Q1) Design and implement a language to represent matrices and perform the assignment, addition, and multiplication operations. Use an AST to represent the operations and use it to check the operand compatibility. [+2 extra marks] Parse the AST and generate the equivalent C code. Note 1: This question is restricted to matrices and not tensors Note 2: You are free to design your own language. The language should NOT include explicit loops. See an example language below. Note 3: The matrix dimensions should be integer constants Sample input program Tensor A[3][4]; Tensor B[4][5]; Tensor C[3][5]; Tensor D[3][5]; Tensor E[3][5]; D=C+ A*B; E=D; l/errors A*C; // semantic error C+B; // semantic error Q2. Extend Q1 to support assignment and addition operation for tensors Tensor A[3][4][5][6]; Tensor B[3][4][5][6]; Tensor C[3][4][5][6]; C=A+B Domain-specific languages (DSLs) are languages specialized for particular domains. HTML, SQL, etc., are examples of DSLs. In this assignment, you have to develop a DSL for tensor algebra and implement a subset of its operators. A tensor is a higher dimensional analog of a matrix. A vector is a 1D tensor, and a matrix is a 2D tensor, and so on. Q1) Design and implement a language to represent matrices and perform the assignment, addition, and multiplication operations. Use an AST to represent the operations and use it to check the operand compatibility. [+2 extra marks] Parse the AST and generate the equivalent C code. Note 1: This question is restricted to matrices and not tensors Note 2: You are free to design your own language. The language should NOT include explicit loops. See an example language below. Note 3: The matrix dimensions should be integer constants Sample input program Tensor A[3][4]; Tensor B[4][5]; Tensor C[3][5]; Tensor D[3][5]; Tensor E[3][5]; D=C+ A*B; E=D; l/errors A*C; // semantic error C+B; // semantic error Q2. Extend Q1 to support assignment and addition operation for tensors Tensor A[3][4][5][6]; Tensor B[3][4][5][6]; Tensor C[3][4][5][6]; C=A+B
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
