Skip to content

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.TokenCategoryFunction
1intReserved wordDefines the datatype (integer) of the posterior assign expression
2x=10Assign expressionAssign the value to a var defined by the user
3ProcesoReserved wordDefault method that defines the process to run between the delimitators
4()Instruction parametersDefines the parameters that a functions is receiving
5<Open delimiterDefines that start of a block code to methods like "Proceso" and the "si" conditions
6EncenderReserved wordTurns on the fan reciving a parameter
(1)Instuction parametersReceives the parameters of the "Encender" instruction
7VelocidadReserved wordDefines the fan velocity
(1:10)"Velocidad" parametersReceives the pin where the fan is connected to and the velocity of the fan, splited by a ":"
8RetardoReserved wordDefines an await time before executes the next code
9(5)Instruction parametersReceives a parameter which is the wait time in seconds
10Giro.DerechaReserved wordDefines the fan turn direction to right
11(1,2)Fan turn direction parametersReceives the connected fan pin to turn on and turn off to change the turn direction
12Giro.IzquierdaReserved wordDefines the fan turn direction to left
13(2,1)Fan turn direction parametersReceives the connected fan pin to turn on and turn off to change the turn direction
14siReserved wordEvaluates if a conditon is right or not to execute a code block
15(x<10)Condition expressionReceives a evaluation based on a declared user var or a number
16x++/x--Add and substract operatoresAdd or substract one to a defined var
17>Close delimiterDefines 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

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages