( "token" function "token" function "token" function "token" function)
so I can search the array for a match for against the input token with the tokens in the array - if there is a match run the code that is is the n+1 element from the token that was found.
What I can't figure out is how to get lisp just to treat the n+1 element like a command.
example...
I want to say have a token "DIR", the n+1 element in the array would be (ext:shell "ls").
or to abstract it a bit..
have (aref command-list 0 0 ) return "DIR" - the token
then have (aref command-list 0 1 ) return a function that executes
Would it be better to use somthing like a P-list for this?
Just a general comment - I continue to be suprised at just how nice lisp is. I wish I had found it earlier. Just trying hard to become good at the language.
Update:
Code: Select all
(SETQ COMMAND-TOKENS '(( APPEND . ( DAPPEND )) ( ASSIGN . ( DASSIGN )) ( ATTRIB . ( DATTRIB)) ( BACKUP . ( DBACKUP )) ( RESTORE . ( DRESTORE )) ( BASIC . ( DBASIC )) ( BASICA . ( DBASICA )) ( CALL . ( DCALL )) ( CD . ( DCD )) ( CHDIR . ( DCHDIR )) ( CHCP . ( DCHCP )) ( CHKDSK . ( DCHKDSK )) ( CHOICE . ( DCHOICE )) ( CLS . ( DCLS )) ( COPY . ( DCOPY )) ( CTTY . ( DCTTY )) ( DEFRAG . ( DDEFRAG )) ( DEL . ( DDEL )) ( ERASE . ( DERASE )) ( DELTREE . ( DDELTREE )) ( DIR . ( DDIR )) ( ECHO . ( DECHO )) ( EDIT . ( DEDIT )) ( EDLIN . ( DEDLIN )) ( EXE2BIN . ( DEXE2BIN )) ( EXIT . ( DEXIT )) ( FASTOPEN . ( DFASTOPEN )) ( FC . ( DFC )) ( COMP . ( DCOMP )) ( FDISK . ( DFDISK )) ( FIND . ( DFIND )) ( FOR . ( DFOR )) ( FORMAT . ( DFORMAT )) ( HELP . ( DHELP )) ( INTERSVR . ( DINTERSVR )) ( INTERLNK . ( DINTERLNK )) ( JOIN . ( DJOIN )) ( LABEL . ( DLABEL )) ( LOADFIX . ( DLOADFIX )) ( LOADHIGH . ( DLOADHIGH )) ( LH . ( DLH )) ( MD . ( DMD )) ( MKDIR . ( DMKDIR )) ( MEM . ( DMEM )) ( MEMMAKER . ( DMEMMAKER )) ( MODE . ( DMODE )) ( MORE . ( DMORE )) ( MOVE . ( DMOVE )) ( MSD . ( DMSD )) ( PATH . ( DPATH )) ( PAUSE . ( DPAUSE )) ( PRINT . ( DPRINT )) ( RD . ( DRD )) ( RMDIR . ( DRMDIR )) ( REM . ( DREM )) ( REN . ( DREN )) ( SCANDISK . ( DSCANDISK )) ( SET . ( DSET )) ( SETVER . ( DSETVER )) ( SHARE . ( DSHARE )) ( SMARTDRIVE . ( DSMARTDRIVE )) ( SORT . ( DSORT )) ( SUBST . ( DSUBSET )) ( SYS . ( DSYS )) ( TIME . ( DTIME )) ( DATE . ( DDATE )) ( TREE . ( DTREE )) ( TRUENAME . ( DTRUENAME )) ( TYPE . ( DTYPE )) ( UNDELETE . ( DUNDELETE )) ( VER . ( DVER )) ( VERIFY . ( DVERIFY )) ( XCOPY . ( DXCOPY ))))
Sorted....
EVAL!!!! Damn for somthing so simple how could I have overlooked this...


Code: Select all
(EVAL (CDR (ASSOC 'DIR COMMAND-TOKENS) ) )
The thing to think about now is how to pass parremeters to the parser... in the above example most of the functions would be useless without parameters....