mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 13:00:39 +03:00
Fix typecheck for logic expressions
This commit is contained in:
parent
fc7af76cfe
commit
337c037e99
|
@ -6,23 +6,26 @@ import { RSErrorType } from '../utils/enums';
|
||||||
import { CstType, IConstituenta, IExpressionParse, IFunctionArg, type IRSForm } from '../utils/models';
|
import { CstType, IConstituenta, IExpressionParse, IFunctionArg, type IRSForm } from '../utils/models';
|
||||||
import { getCstExpressionPrefix } from '../utils/staticUI';
|
import { getCstExpressionPrefix } from '../utils/staticUI';
|
||||||
|
|
||||||
|
const LOGIC_TYPIIFCATION = 'LOGIC';
|
||||||
|
|
||||||
function checkTypeConsistency(type: CstType, typification: string, args: IFunctionArg[]): boolean {
|
function checkTypeConsistency(type: CstType, typification: string, args: IFunctionArg[]): boolean {
|
||||||
|
console.log(typification)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CstType.BASE:
|
case CstType.BASE:
|
||||||
case CstType.CONSTANT:
|
case CstType.CONSTANT:
|
||||||
case CstType.STRUCTURED:
|
case CstType.STRUCTURED:
|
||||||
case CstType.TERM:
|
case CstType.TERM:
|
||||||
return typification !== '' && args.length === 0;
|
return typification !== LOGIC_TYPIIFCATION && args.length === 0;
|
||||||
|
|
||||||
case CstType.AXIOM:
|
case CstType.AXIOM:
|
||||||
case CstType.THEOREM:
|
case CstType.THEOREM:
|
||||||
return typification === '' && args.length === 0;
|
return typification === LOGIC_TYPIIFCATION && args.length === 0;
|
||||||
|
|
||||||
case CstType.FUNCTION:
|
case CstType.FUNCTION:
|
||||||
return typification !== '' && args.length !== 0;
|
return typification !== LOGIC_TYPIIFCATION && args.length !== 0;
|
||||||
|
|
||||||
case CstType.PREDICATE:
|
case CstType.PREDICATE:
|
||||||
return typification === '' && args.length !== 0;
|
return typification === LOGIC_TYPIIFCATION && args.length !== 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +45,7 @@ function useCheckExpression({ schema }: { schema?: IRSForm }) {
|
||||||
onError: error => { setError(error); },
|
onError: error => { setError(error); },
|
||||||
onSuccess: parse => {
|
onSuccess: parse => {
|
||||||
if (activeCst && parse.parseResult) {
|
if (activeCst && parse.parseResult) {
|
||||||
if (activeCst.cstType == CstType.BASE || activeCst.cstType == CstType.CONSTANT) {
|
if (activeCst.cstType === CstType.BASE || activeCst.cstType === CstType.CONSTANT) {
|
||||||
if (expression !== getCstExpressionPrefix(activeCst)) {
|
if (expression !== getCstExpressionPrefix(activeCst)) {
|
||||||
parse.parseResult = false;
|
parse.parseResult = false;
|
||||||
parse.errors.push({
|
parse.errors.push({
|
||||||
|
|
|
@ -500,7 +500,7 @@ export function getTypificationLabel({isValid, resultType, args}: {
|
||||||
if (!isValid) {
|
if (!isValid) {
|
||||||
return 'N/A';
|
return 'N/A';
|
||||||
}
|
}
|
||||||
if (resultType === '') {
|
if (resultType === '' || resultType === 'LOGIC') {
|
||||||
resultType = 'Логический'
|
resultType = 'Логический'
|
||||||
}
|
}
|
||||||
if (args.length === 0) {
|
if (args.length === 0) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user