Finished implementing lists on symbolic mode

This commit is contained in:
claudiol 2018-07-24 18:13:32 -04:00
parent 216a8b6770
commit df82ef9948
3 changed files with 52 additions and 19 deletions

View file

@ -3646,15 +3646,17 @@ void bracketKeyHandler(BINT keymsg,BYTEPTR string)
void curlyBracketKeyHandler(BINT keymsg)
{
bracketKeyHandler(keymsg,(BYTEPTR)"{ }");
if( (halGetCmdLineMode()!='L')&&(halGetCmdLineMode()!='C'))
if((halGetCmdLineMode()=='A')||(halGetCmdLineMode()=='C')||(halGetCmdLineMode()=='L')) bracketKeyHandler(keymsg,(BYTEPTR)"{}");
else {
bracketKeyHandler(keymsg,(BYTEPTR)"{ }");
halSetCmdLineMode('P');
}
}
void squareBracketKeyHandler(BINT keymsg)
{
bracketKeyHandler(keymsg,(BYTEPTR)"[ ]");
if((halGetCmdLineMode()=='A')||(halGetCmdLineMode()=='C')||(halGetCmdLineMode()=='L')) bracketKeyHandler(keymsg,(BYTEPTR)"[]");
else bracketKeyHandler(keymsg,(BYTEPTR)"[ ]");
}
void secoBracketKeyHandler(BINT keymsg)
@ -3683,19 +3685,22 @@ void textBracketKeyHandler(BINT keymsg)
void ticksKeyHandler(BINT keymsg)
{
bracketKeyHandler(keymsg,(BYTEPTR)"''");
// GO INTO ALGEBRAIC MODE
if( (halGetCmdLineMode()!='L')&&(halGetCmdLineMode()!='C'))
{
bracketKeyHandler(keymsg,(BYTEPTR)"''");
halSetCmdLineMode('A');
}
else symbolKeyHandler(keymsg,(BYTEPTR)"'",0);
}
void tagKeyHandler(BINT keymsg)
{
if( (halGetCmdLineMode()!='L')&&(halGetCmdLineMode()!='C')) {
bracketKeyHandler(keymsg,(BYTEPTR)"::");
// LOCK ALPHA MODE
if( (halGetCmdLineMode()!='L')&&(halGetCmdLineMode()!='C'))
keyb_setshiftplane(0,0,1,1);
}
else symbolKeyHandler(keymsg,(BYTEPTR)":",0);
}

View file

@ -578,7 +578,7 @@ void LIB_HANDLER()
// ALLOW LIST PROCESSING AND MATRIX PROCESSING FIRST
if(ISLIST(*arg1) || ISLIST(*arg2)){
rplListBinaryDoCmd(arg1,arg2);
rplListBinaryDoCmd();
return;
}
@ -719,7 +719,7 @@ void LIB_HANDLER()
// ALLOW LIST PROCESSING AND MATRIX PROCESSING FIRST
if(ISLIST(*arg1) || ISLIST(*arg2)) {
rplListBinaryDoCmd(arg1,arg2);
rplListBinaryDoCmd();
return;
}
@ -798,7 +798,7 @@ void LIB_HANDLER()
// ALLOW LIST PROCESSING AND MATRIX PROCESSING FIRST
if(ISLIST(*arg1) || ISLIST(*arg2)){
rplListBinaryDoCmd(arg1,arg2);
rplListBinaryDoCmd();
return;
}
@ -1027,6 +1027,10 @@ void LIB_HANDLER()
return;
}
if(ISLIST(*rplPeekData(1))) {
rplListUnaryDoCmd();
return;
}
if(!ISSYMBOLIC(*rplPeekData(1))) return; // LEAVE IT ON THE STACK, NOT A SYMBOLIC
rplSymbAutoSimplify();
@ -1095,6 +1099,11 @@ void LIB_HANDLER()
rplSetExceptionHandler(IPtr+3); // SET THE EXCEPTION HANDLER TO THE SYMBEVAL1ERR WORD
if((Opcode==CMD_OPENBRACKET) || (Opcode==CMD_LISTOPENBRACKET)) {
// SPECIAL CASE, THESE COMMANDS NEED THE NUMBER OF ARGUMENTS PUSHED ON THE STACK
rplNewBINTPush(newdepth,DECBINT);
}
if((Opcode==CMD_OVR_MUL)||(Opcode==CMD_OVR_ADD)) {
// CHECK FOR FLATTENED LIST, APPLY MORE THAN ONCE IF MORE THAN 2 ARGUMENTS
if(newdepth<=2) rplPutLAMn(1,(WORDPTR)zero_bint); // SIGNAL OPCODE IS DONE
@ -1217,6 +1226,7 @@ void LIB_HANDLER()
rplSetExceptionHandler(IPtr+3); // SET THE EXCEPTION HANDLER TO THE SYMBEVAL1ERR WORD
// PUSH THE NEXT OBJECT IN THE STACK
rplPushData(Opcodeptr);
@ -1237,6 +1247,12 @@ void LIB_HANDLER()
rplSetExceptionHandler(IPtr+3); // SET THE EXCEPTION HANDLER TO THE SYMBEVAL1ERR WORD
if((Opcode==CMD_OPENBRACKET) || (Opcode==CMD_LISTOPENBRACKET)) {
// SPECIAL CASE, THESE COMMANDS NEED THE NUMBER OF ARGUMENTS PUSHED ON THE STACK
rplNewBINTPush(newdepth,DECBINT);
}
if((Opcode==CMD_OVR_MUL)||(Opcode==CMD_OVR_ADD)) {
// CHECK FOR FLATTENED LIST, APPLY MORE THAN ONCE IF MORE THAN 2 ARGUMENTS
if(newdepth<=2) rplPutLAMn(1,(WORDPTR)zero_bint); // SIGNAL OPCODE IS DONE
@ -1545,7 +1561,7 @@ void LIB_HANDLER()
// ALLOW LIST PROCESSING AND MATRIX PROCESSING FIRST
if(ISLIST(*arg1) || ISLIST(*arg2)){
rplListBinaryDoCmd(arg1,arg2);
rplListBinaryDoCmd();
return;
}

View file

@ -190,11 +190,19 @@ void rplSymbApplyOperator(WORD Opcode,BINT nargs)
return;
}
}
rplCopyObject(ptr,obj);
// REPLACE QUOTED IDENT WITH UNQUOTED ONES FOR SYMBOLIC OBJECTS
if(ISIDENT(*ptr)) *ptr=SETLIBNUMBIT(*ptr,UNQUOTED_BIT);
ptr=rplSkipOb(ptr);
if(ISLIST(*obj)) {
BINT listsize=OBJSIZE(*obj);
memmovew(ptr+2,obj+1,listsize-1);
ptr[0]=MKPROLOG(DOSYMB,listsize);
ptr[1]=CMD_LISTOPENBRACKET;
ptr+=listsize+1; // OVERWRITE THE ENDLIST COMMAND IN THE LIST, NOT NEEDED IN SYMBOLICS
}
else {
rplCopyObject(ptr,obj);
// REPLACE QUOTED IDENT WITH UNQUOTED ONES FOR SYMBOLIC OBJECTS
if(ISIDENT(*ptr)) *ptr=SETLIBNUMBIT(*ptr,UNQUOTED_BIT);
ptr=rplSkipOb(ptr);
}
}
rplDropData(nargs-1);
rplOverwriteData(1,newobject);
@ -2706,14 +2714,18 @@ WORDPTR rplSymbNumericReduce(WORDPTR object)
}
rplCallOperator(**stkptr);
// SPECIAL CASE: FOR BRACKET OPERATORS WE NEED TO KEEP THEM AS SYMBOLIC
if((**stkptr==CMD_OPENBRACKET)||(**stkptr==CMD_LISTOPENBRACKET)) rplSymbApplyOperator(**stkptr,nargs);
else rplCallOperator(**stkptr);
if(Exceptions) { rplBlameError(*stkptr); DSTop=endofstk+1; return 0; }
if(!ISNUMBERORUNIT(*rplPeekData(1))) {
// THIS IS STRANGE, A COMMAND WITH NUMERIC INPUT SHOULD RETURN A NUMERIC OUTPUT
// TODO: IF THE RESULT IS SYMBOLIC, NEED TO EXPAND BEFORE INSERTING, SO ADDITIONAL SIMPLIFICATION CAN BE DONE INSIDE
// IT'S LIKELY A COMPLEX NUMBER, A VECTOR/MATRIX OR A LIST. IN ANY CASE, DON'T TRY TO SIMPLIFY
// TODO: IF THE RESULT IS SYMBOLIC, NEED TO EXPAND BEFORE INSERTING, SO ADDITIONAL SIMPLIFICATION CAN BE DONE INSIDE
WORDPTR *ptr,*endofobj=rplSymbSkipInStack(stkptr); // POINT TO THE NEXT OBJECT
ptr=endofobj+1;