www.delorie.com/gnu/docs/maxima/maxima_23.html   search  
 
Buy GNU books!


Maxima Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.5 SYNTAX

- It is possible to add new operators to MACSYMA (infix, prefix, postfix, unary, or matchfix with given precedences), to remove existing operators, or to redefine the precedence of existing operators. While MACSYMA's syntax should be adequate for most ordinary applications, it is possible to define new operators or eliminate predefined ones that get in the user's way. The extension mechanism is rather straightforward and should be evident from the examples below.
 
(C1) PREFIX("DDX")$
(C2) DDX Y$
     /* means                   "DDX"(Y) */
(C3) INFIX("<-")$
(C4) A<-DDX Y$
    /* means               "<-"(A,"DDX"(Y)) */

For each of the types of operator except SPECIAL, there is a corresponding creation function that will give the lexeme specified the corresponding parsing properties. Thus "PREFIX("DDX")" will make "DDX" a prefix operator just like "-" or "NOT". Of course, certain extension functions require additional information such as the matching keyword for a matchfix operator. In addition, binding powers and parts of speech must be specified for all keywords defined. This is done by passing additional arguments to the extension functions. If a user does not specify these additional parameters, MACSYMA will assign default values. The six extension functions with binding powers and parts of speech defaults (enclosed in brackets) are summarized below. PREFIX(operator, rbp[180], rpos[ANY], pos[ANY]) POSTFIX(operator, lbp[180], lpos[ANY], pos[ANY]) INFIX(operator, lbp[180], rbp[180], lpos[ANY], rpos[ANY],pos[ANY]) NARY(operator, bp[180], argpos[ANY], pos[ANY]) NOFIX(operator, pos[ANY]) MATCHFIX(operator, match, argpos[ANY], pos[ANY]) The defaults have been provided so that a user who does not wish to concern himself with parts of speech or binding powers may simply omit those arguments to the extension functions. Thus the following are all equivalent. PREFIX("DDX",180,ANY,ANY)$ PREFIX("DDX",180)$ PREFIX("DDX")$ It is also possible to remove the syntax properties of an operator by using the functions REMOVE or KILL. Specifically, "REMOVE("DDX",OP)" or "KILL("DDX")" will return "DDX" to operand status; but in the second case all the other properties of "DDX" will also be removed.
 

(C20) PREFIX("DDX",180,ANY,ANY)$

(C21) DDXYZ;

(D21) 				    DDX YZ

(C26) "ddx"(u):=u+4;

(D26) 			        DDX u := u + 4
(C27) ddx 8;

(D27) 				      12


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)