Classroom ▪ Final Project https://classroom.github.com/a/XJmZgSI2 ▪ TheCompiler ▪ Your final project ▪ Include Lexer ▪ Include Parser with error handling ▪ Include Semantic Analysis ▪ Include Code Generation ▪ Bonus: your generated code work with the provided VM
Simple Virtual Machine CPU ALU Register PC Memory program Code sto 0, s sto 0, d sto 0, c sto 0, d lod s, 0 lit “s”, 0 opr 14, 0 jmc #a1, false lod b, 0 Symbol Table
Number Action 0 Exit program 1 Return 2 ADD: POP A, POP B, PUSH B+A 3 SUBTRACT: POP A, POP B, PUSH B-A 4 MULTIPLY: POP A, POP B, PUSH B*A 5 DIVIDE: POP A, POP B, PUSH B/A 6 MOD: POP A, POP B, PUSH (B mod A) 7 POW: POP A, POP B, PUSH (A to the power B) 8 OR: POP A, POP B, PUSH (B or A) 9 AND: POP A, POP B, PUSH (B and A) 10 NOT: POP A, PUSH (not A) 11 TEST GREATER THAN: POP A, POP B, PUSH (B>A) 12 TEST LESS THAN: POP A, POP B, PUSH (B<A) 13 TEST GREATER THAN OR EQUAL: POP A, POP B, PUSH (B>=A)
Number Action 14 TEST LESS THAN OR EQUAL: POP A, POP B, PUSH (B<=A) 15 TEST EQUAL: POP A, POP B, PUSH (B=A) 16 TEST NOT EQUAL: POP A, POP B, PUSH (B<>A) 17 18 clear screen 19 read a value from the standard input 20 print a value to the standard output 21 print a value to the standard output and a newline character
These slides can only be used as study material for the Compilers course at Universidad Panamericana. They cannot be distributed or used for another purpose.