Skip to content

It's a compiler for a programming language created by me. This was for a Six Semester project for the Languages and Automata

Notifications You must be signed in to change notification settings

HectorMu/Compiler

Repository files navigation

Compifan

A compiler created for a programming language made by myself. This was part of a Six Semester proyect. The language has lexic, sintactic and semantic rules, too it traduces my language to arduino. Cause the language was maded to control a fan connected to an arduino by serial port.

Languages rules:

  1. All the vars are declared out of the initial method called "Proceso".
  2. Can't exists functions out of the "Proceso" method.
  3. Only can exist a method called "Proceso".
  4. The fan must be on before give it instructions.
  5. The "Proceso" method and the conditions must have open and close delimiters, containig the instructions to run.
  6. The comments can go anywhere.
  7. Only exists integeres datatypes.

Program body

!!Im_a_comment int pin1=10;
int pin2=9; int a=6; -> var declaration Proceso () -> Principal process loop < ->Open delimiter Encender (pin1) ->Instructions and conditions Velocidad (pin1:5) Giro.Izquierda (pin1,pin2) Retardo (5) si (a>5) ->Condition expression < Giro.Derecha(pin2,pin1) Retardo (10) a-- ->Subtract operator

Token table
No. Token Category Function
1 int Reserved word Defines the datatype (integer) of the posterior assign expression
2 x=10 Assign expression Assign the value to a var defined by the user
3 Proceso Reserved word Default method that defines the process to run between the delimitators
4 () Instruction parameters Defines the parameters that a functions is receiving
5 < Open delimiter Defines that start of a block code to methods like "Proceso" and the "si" conditions
6 Encender Reserved word Turns on the fan reciving a parameter
(1) Instuction parameters Receives the parameters of the "Encender" instruction
7 Velocidad Reserved word Defines the fan velocity
(1:10) "Velocidad" parameters Receives the pin where the fan is connected to and the velocity of the fan, splited by a ":"
8 Retardo Reserved word Defines an await time before executes the next code
9 (5) Instruction parameters Receives a parameter which is the wait time in seconds
10 Giro.Derecha Reserved word Defines the fan turn direction to right
11 (1,2) Fan turn direction parameters Receives the connected fan pin to turn on and turn off to change the turn direction
12 Giro.Izquierda Reserved word Defines the fan turn direction to left
13 (2,1) Fan turn direction parameters Receives the connected fan pin to turn on and turn off to change the turn direction
14 si Reserved word Evaluates if a conditon is right or not to execute a code block
15 (x<10) Condition expression Receives a evaluation based on a declared user var or a number
16 x++/x-- Add and substract operatores Add or substract one to a defined var
17 > Close delimiter Defines the end of a code block

About

It's a compiler for a programming language created by me. This was for a Six Semester project for the Languages and Automata

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages