Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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 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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started