Nouveau langage de programmation - Relax

introduction

Bonjour à tous, je suis l'auteur du langage de programmation Relax. Je développe actuellement RVM (RelaxVirtualMachine) ET Relasm (Relax Assembly). Les premières tentatives pour créer ma propre langue ont commencé à la fin de l'été 2020, puis je ne me suis même pas demandé quoi faire une langue - c'est tellement difficile. Le projet Relax lui-même a commencé le 30 décembre 2020. Un mois et demi s'est écoulé et vous pouvez déjà écrire quelque chose de simple dessus.





le premier logo de la langue
le premier logo de la langue

Comment compiler le code?

, 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 n'est que d'un mois et demi, mais il peut déjà le faire. Il se développera pendant longtemps. Mais même maintenant, il est possible d'écrire des programmes de console simples.





Référentiel de machines virtuelles (la documentation relasm est là) - https://github.com/UnbelievableDevelopmentCompany/RVM



Dépôt du compilateur Relasm - https://github.com/UnbelievableDevelopmentCompany/Relasm



Package pour sublime text 3 - RelasmST3Package








All Articles