Nuevo lenguaje de programación - Relax

Introducción

Hola a todos, soy el autor del lenguaje de programación Relax. Actualmente estoy desarrollando RVM (RelaxVirtualMachine) Y Relasm (Relax Assembly). Los primeros intentos de hacer mi propio idioma comenzaron a fines del verano de 2020, luego ni siquiera pensé en qué hacer un idioma, es muy difícil. El proyecto Relax en sí comenzó el 30 de diciembre de 2020. Ha pasado un mes y medio y ya puedes escribir algo sencillo en él.





el primer logo del idioma
el primer logo del idioma

¿Cómo compilo el código?

, relasm .rasm, - - .ree. 3 : Relasm.exe, RelaxVM.exe, QtCore.dll. : https://github.com/UnbelievableDevelopmentCompany/RVM/tree/master/x64/Release

https://github.com/UnbelievableDevelopmentCompany/Relasm/tree/master/x64/Release





, 3 , PATH( ). cmd Relasm :





Relasm main.rasm program.ree
RelaxVM program.ree
      
      



relasm -, .





Relasm

Relasm?





mclass MainClass
method public static void MainClass.Main():
	.maxstack 1
	push.str "hello world"
	callm std static Relax.Console.Write(Relax.String)
      
      



- hello world! . , Main( ). . - , . , , 1. "hello world" . . , Relasm. .





, hello world, - .





mclass MainClass
method public static void MainClass.Main():
	.maxstack 2
	;  
	local firstNum Relax.Int32
	local secondNum Relax.Int32
	local result Relax.Int32
	local op Relax.String

	;   
	callm std static Relax.Console.Read()
	callm std static Relax.Converter.StringToInt32(Relax.String)
	set firstNum

	;   
	callm std static Relax.Console.Read()
	set op

	;   
	callm std static Relax.Console.Read()
	callm std static Relax.Converter.StringToInt32(Relax.String)
	set secondNum

	;    

	;   
	get op
	push.str "+"
	callm std instance Relax.String.operator==(Relax.String)
	jmpif opAdd

	;   
	get op
	push.str "-"
	callm std instance Relax.String.operator==(Relax.String)
	jmpif opSub

	;   
	get op
	push.str "*"
	callm std instance Relax.String.operator==(Relax.String)
	jmpif opMul

	;   
	get op
	push.str "/"
	callm std instance Relax.String.operator==(Relax.String)
	jmpif opDiv


	opAdd: ;  
	get firstNum
	get secondNum
	add
	set result
	jmp end

	opSub: ;  
	get secondNum
	get firstNum
	sub
	set result
	jmp end

	opMul: ;  
	get firstNum
	get secondNum
	mul
	set result
	jmp end

	opDiv: ;  
	get secondNum
	get firstNum
	div
	set result
	jmp end



	end: ;    
	push.str "\nResult: "
	callm std static Relax.Console.Write(Relax.String)
	get result
	callm std static Relax.Console.Write(Relax.Int32)
      
      



. . . . 2 , result end, .





.





mclass MainClass

method public static void MainClass.Main():
	.maxstack 2
	;       
	push.int32 10
	push.str "Result - "

	;  
	callm usr static MainClass.StringPlusInt32(Relax.String, Relax.Int32)

	;     
	callm std static Relax.Console.Write(Relax.String)


method public static Relax.String MainClass.StringPlusInt32(Relax.String str, Relax.Int32 num):
	.maxstack 2
	get num
	callm std static Relax.Converter.Int32ToString(Relax.Int32) ;    
	get str
	callm std instance Relax.String.Concat(Relax.String) ;    str  
	return ;  
      
      



StringPlusInt32 , , Relax.Converter.Int32ToString str , . return. Main .





Relax es sólo un mes y medio, pero ya puede hacerlo. Se desarrollará durante mucho tiempo. Pero incluso ahora es posible escribir programas de consola simples.





Repositorio de máquinas virtuales (la documentación de relasm está ahí) - https://github.com/UnbelievableDevelopmentCompany/RVM



Repositorio de compiladores de Relasm - https://github.com/UnbelievableDevelopmentCompany/Relasm



Paquete para texto sublime 3 - RelasmST3Package








All Articles