Selección de Instrucciones
Especificación de la etapa de selección de instrucciones (perteneciente a la fase de generación de código) utilizando como metalenguaje una especificación de código:
Code Functions
Functions | Code Templates |
run⟦program⟧ | run⟦program → varDefinition* statement*⟧ = metadata⟦program⟧ execute⟦statementi⟧ HALT |
execute⟦statement⟧ | execute⟦print → expression⟧ = #LINE {end.line} value⟦expression⟧ OUT<expression.type> execute⟦assignment → left:expression right:expression⟧ = |
value⟦expression⟧ | value⟦arithmetic → left:expression operator:string right:expression⟧ = value⟦left⟧ value⟦right⟧ if operator == "+" ADD<arithmetic.type> if operator == "-" SUB<arithmetic.type> if operator == "*" MUL<arithmetic.type> if operator == "/" DIV<arithmetic.type> value⟦variable → name:string⟧ = value⟦intLiteral → intValue:int⟧ = value⟦floatLiteral → floatValue:float⟧ = |
address⟦expression⟧ | address⟦arithmetic → left:expression operator:string right:expression⟧ = address⟦variable → name:string⟧ = address⟦intLiteral → intValue:int⟧ = address⟦floatLiteral → floatValue:float⟧ = |
metadata⟦program⟧ | metadata⟦program → varDefinition* statement*⟧ = #SOURCE {source_file} metadata⟦varDefinitioni⟧ |
metadata⟦varDefinition⟧ | metadata⟦varDefinition → type name:string⟧ = #GLOBAL {name}: {maplType(type)} |
Auxiliary Functions
Name | Description |
maplType(type) | Returns the MAPL equivalent to the MLang type argument: intType -> int floatType -> float |