// Imports import {variables} from "../variables/variables"; import {eltP} from "codemirror/src/util/dom"; import {operations} from "./operations"; // Imports // ********************************************************************************* // Scheme for the operations list // ********************************************************************************* export const operationScheme = { hash: 'UUID for the operation', assignedVariable: 'Reference to the assigned variable', type: 'ASSIGN', operators: [], editing: true } // ********************************************************************************* // Scheme for the operators // ********************************************************************************* export const operatorScheme = { hash: 'UUID for the operator', type: 'Operator type', value: 'Operator value', variable: 'Reference to the variable', operator: 'Reference to operator' } // ********************************************************************************* // Operator types // ********************************************************************************* export const Operators = { VARIABLE: 'VARIABLE', VALUE: 'VALUE', OPERATOR: 'OPERATOR' } export const OperatorType = [ { name: 'Variável', value: Operators.VARIABLE }, { name: 'Valor', value: Operators.VALUE }, { name: 'Operator', value: Operators.OPERATOR } ] // ********************************************************************************* // Operation types // ********************************************************************************* export const OperationType = [ { name: ';', friendlyName: 'Fim', value: 'SEMICOLON' }, { name: '+', friendlyName: 'Soma', value: 'PLUS' }, { name: '-', friendlyName: 'Subtração', value: 'MINUS' }, { name: '*', friendlyName: 'Multiplicação', value: 'MULTIPLICATION' }, { name: '/', friendlyName: 'Divisão', value: 'DIVISION' }, { name: '(', friendlyName: 'Abre parenteses', value: 'OPEN_PARENTHESES' }, { name: ')', friendlyName: 'Fecha parenteses', value: 'CLOSE_PARENTHESES' }, ] // ********************************************************************************* // Operator kinds // ********************************************************************************* export const OperatorKind = [ { name: 'Variável', value: 'VARIABLE' }, { name: 'Valor', value: 'VALUE' } ] // ********************************************************************************* // Operation type html schemes // ********************************************************************************* export function htmlOperationTypeScheme () { let operationTypesSelect = ``; for (let i = 0; i < OperationType.length; i++) { operationTypesSelect += ``; } return `
`; } // ********************************************************************************* // Assign variable operation kind html schemes // ********************************************************************************* export function htmlOperationKindScheme (operation) { let operatorKindsSelect = ``; for (let i = 0; i < OperatorKind.length; i++) { operatorKindsSelect += ``; } return `
`; } // ********************************************************************************* // Assign variable html schemes // ********************************************************************************* export function htmlAssignVariableScheme () { const variablesSelect = htmlVariablesSelectScheme(); return `
  • `; } // ********************************************************************************* // Variable select html schemes // ********************************************************************************* export function htmlVariablesSelectScheme () { let variablesSelect = variables.length === 0 ? `` : ``; for (let i = 0; i < variables.length; i++) { variablesSelect += `` } return variablesSelect; } // ********************************************************************************* // ********************************************************************************* // Operator variable select // ********************************************************************************* export function htmlOperatorVariablesSelectScheme (operation, operator) { let variablesSelect = variables.length === 0 ? `` : ``; for (let i = 0; i < variables.length; i++) { variablesSelect += `` } return `
    `; } // ********************************************************************************* // Operator value input // ********************************************************************************* export function htmlOperatorValueInputScheme (operation, operator) { return `
    `; } // ********************************************************************************* // Operation type select // ********************************************************************************* export function htmlOperationTypeSelect (operation, operator) { let operationTypesSelect = ``; for (let i = 0; i < OperationType.length; i++) { operationTypesSelect += ``; } return `
    `; } // ********************************************************************************* // Print operation // ********************************************************************************* export function printOperationScheme (operation) { let variablesSelect = variables.length === 0 ? `` : ``; for (let i = 0; i < variables.length; i++) { variablesSelect += `` } return `
  • `; } // ********************************************************************************* // Util // ********************************************************************************* export function getOperatorTypeByValue (value) { for (let i = 0; i < OperatorType.length; i++) { if (OperatorType[i].value === value) return OperatorType[i]; } return null; } // ********************************************************************************* export function getOperationTypeByValue (value) { for (let i = 0; i < OperationType.length; i++) { if (OperationType[i].value === value) return OperationType[i]; } return null; } // ********************************************************************************* export function getOperatorByHash (operation, operatorHash) { for (let i = 0; i < operation.operators.length; i++) { if (operation.operators[i].hash === operatorHash) return operation.operators[i]; } return null; } // *********************************************************************************