Skip to content

This is a simple compiler for Mini Matlab. It is coded in lex and yacc file. It consist of some of the feature in matlab like trigonometric operation, concatenation of matrix, transpose of matrix, ...

License

Notifications You must be signed in to change notification settings

xinying100/Compiler_Mini_Matlab

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Compiler Mini Matlab

   Compilers are essential software tools that bridge the gap between high-level programming languages and the low-level machine code executed by computers. They play a crucial role in translating human-readable code into efficient and executable instructions. Given the assignment of developing a compiler, our team has developed a compiler that can perform the same functions as a Matlab software. We have implemented some of the exact same functions from Matlab. Through developing this software, we hope to be able to create a software that is like Matlab and add even more functions into it, being able to easily customize it.

Wrong format of operation:

No Wrong Output Correct
1 sin30 Undeclared Identifier ! sin(30)
2 tranpose([1 2 3]) The identifier is not a function transpose([1 2 3])
3 mod([1 2; 3 4]) The arguments number are too few, 1. Use 2 arguments. mod([1 2; 3 4], 3)

Operation Involved

 |-> Let a be constant.
 |-> Let b be vector.
 |-> Let c be matrix.
 |-> Let d be either constant, vector or matrix.


i ) Arithmetic -- 1 argument

No Function Explanation Example
1 + Addition d+d
2 - Subtraction d-d
3 * Multiplication d*d
4 / Division d/d
5 ^ Power d^d


ii ) Modulo -- 2 arguments

No Function Explanation Example
1 mod() Remainder after division mod(d,n)


iii ) Trigonometry -- 1 arguments

No Function Explanation Example
1 sin() Sine in radians sin(d)
2 cos() Cosine in radians cos(d)
3 tan() Tangent in radians tan(d)
4 asin() Inverse sine in radians asin(d)
5 acos() Inverse cosine in radians acos(d)
6 atan() Inverse tangent in radians atan(d)


iv ) Rounding -- 1 argument

No Function Explanation Example
1 round() Round to nearest integer round(d)
2 ceil() Round to nearest integer greater or equal to ceil(d)
3 floor() Round to nearest integer smaller or equal to floor(d)


v ) Exponents & Logarithms -- 1 argument

No Function Explanation Example
1 exp() Exponential exp(d)
2 log() Natural logarithm log(d)
3 log10() Logarithm base 10 log10(d)
4 sqrt() Square root sqrt(d)


vi ) Size & Shapes -- 1 argument

No Function Explanation Example
1 length() Length of largest array dimensions length(b)
length(c)
2 size() Array size size(b)
size(c)
3 ndims() Number of dimensions ndims(b)
ndims(c)
4 numel() Number of elements numel(b)
numel(c)


vii ) Transpose, Create & Combine Arrays -- 1,2 arguments

No Function Explanation Example
1 transpose() Transpose vector or matrix transpose(b)
transpose(c)
2 horzat() Concatenate arrays horizontally horzat(b,b)
horzat(c,c)
3 verzat() Concatenate arrays vertically verzat(b,b)
verzat(c,c)
4 zeros() Create arrays of all zeros zeros(a,a)
5 ones() Create arrays of all ones ones(a,a)


viii ) Reshape -- 3 arguments

No Function Explanation Example
1 reshape() Reshape arrays reshape(b,a,a)
reshape(c,a,a)


ix ) Generate Space Vector -- 3 arguments

No Function Explanation Example
1 linspace() Generate a3 number of points in [a1,a2] lineraly linspace(a1,a2,a3)
2 logspace() Generate a3 number of points in [a1,a2] logarithmically logspace(a1,a2,a3)


x ) Command, Datetime & Calendar -- 0 argument

No Function Explanation Example
1 clc Clear command window -
2 ans Most recent answer -
3 datetime Current date and time -
4 calendar Current month -

About

This is a simple compiler for Mini Matlab. It is coded in lex and yacc file. It consist of some of the feature in matlab like trigonometric operation, concatenation of matrix, transpose of matrix, ...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Yacc 86.4%
  • Lex 11.8%
  • C 1.6%
  • Shell 0.2%