// 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',
operators: []
}
// *********************************************************************************
// 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 operatorTypes = [
{
name: 'Variável',
value: Operators.VARIABLE
},
{
name: 'Valor',
value: Operators.VALUE
},
{
name: 'Operator',
value: Operators.OPERATOR
}
]
// *********************************************************************************
// Operation types
// *********************************************************************************
export const operationTypes = [
{
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 operatorKinds = [
{
name: 'Variável',
value: 'VARIABLE'
},
{
name: 'Valor',
value: 'VALUE'
}
]
// *********************************************************************************
// Operation type html schemes
// *********************************************************************************
export function htmlOperationTypeScheme () {
let operationTypesSelect = ``;
for (let i = 0; i < operationTypes.length; i++) {
operationTypesSelect += ``;
}
return `
`;
}
// *********************************************************************************
// Assign variable operation kind html schemes
// *********************************************************************************
export function htmlOperationKindScheme (operation) {
let operatorKindsSelect = ``;
for (let i = 0; i < operatorKinds.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 < operationTypes.length; i++) {
operationTypesSelect += ``;
}
return `
`;
}
// *********************************************************************************
// Util
// *********************************************************************************
export function getOperatorTypeByValue (value) {
for (let i = 0; i < operatorTypes.length; i++) {
if (operatorTypes[i].value === value)
return operatorTypes[i];
}
return null;
}
// *********************************************************************************
export function getOperationTypeByValue (value) {
for (let i = 0; i < operationTypes.length; i++) {
if (operationTypes[i].value === value)
return operationTypes[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;
}
// *********************************************************************************