From: Robert D. <rob...@us...> - 2007-09-16 03:01:11
|
Update of /cvsroot/maxima/maxima/doc/info In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv31116/doc/info Modified Files: Expressions.texi Rules.texi Log Message: Add some verbiage about "part of speech" to operator documentation. * doc/info/Expressions.texi: part of speech verbiage for infix * doc/info/Rules.texi: part of speech verbiage for matchfix Index: Expressions.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/Expressions.texi,v retrieving revision 1.54 retrieving revision 1.55 diff -u -d -r1.54 -r1.55 --- Expressions.texi 30 Jun 2007 19:10:41 -0000 1.54 +++ Expressions.texi 16 Sep 2007 03:00:52 -0000 1.55 @@ -1407,7 +1407,16 @@ @code{infix (@var{op}, @var{lbp}, @var{rbp}, @var{lpos}, @var{rpos}, @var{pos})} declares @var{op} to be an infix operator -with stated left and right binding powers and parts of speech. +with stated left and right binding powers +and parts of speech @var{lpos}, @var{rpos}, and @var{pos} +for the left operand, the right operand, and the operator result, respectively. + +"Part of speech", in reference to operator declarations, means expression type. +Three types are recognized: @code{expr}, @code{clause}, and @code{any}, +indicating an algebraic expression, a Boolean expression, or any kind of expression, +respectively. +Maxima can detect some syntax errors by comparing the +declared part of speech to an actual expression. The precedence of @var{op} with respect to other operators derives from the left and right binding powers of the operators in question. @@ -1482,6 +1491,28 @@ (%o5) ((foo,bar),baz) @end example +Maxima can detect some syntax errors by comparing the +declared part of speech to an actual expression. + +@c ===beg=== +@c infix ("##", 100, 99, expr, expr, expr); +@c if x ## y then 1 else 0; +@c infix ("##", 100, 99, expr, expr, clause); +@c if x ## y then 1 else 0; +@c ===end=== +@example +(%i1) infix ("##", 100, 99, expr, expr, expr); +(%o1) ## +(%i2) if x ## y then 1 else 0; +Incorrect syntax: Found algebraic expression where logical expression expected +if x ## y then + ^ +(%i2) infix ("##", 100, 99, expr, expr, clause); +(%o2) ## +(%i3) if x ## y then 1 else 0; +(%o3) if x ## y then 1 else 0 +@end example + @end deffn @defvr {Option variable} inflag Index: Rules.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/Rules.texi,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- Rules.texi 30 Jun 2007 19:10:41 -0000 1.29 +++ Rules.texi 16 Sep 2007 03:00:54 -0000 1.30 @@ -700,6 +700,13 @@ and result part-of-speech @var{pos}, and the delimiters @var{ldelimiter} and @var{rdelimiter}. +"Part of speech", in reference to operator declarations, means expression type. +Three types are recognized: @code{expr}, @code{clause}, and @code{any}, +indicating an algebraic expression, a Boolean expression, or any kind of expression, +respectively. +Maxima can detect some syntax errors by comparing the +declared part of speech to an actual expression. + @c DUNNO IF WE REALLY NEED TO MENTION BINDING POWER HERE -- AS NOTED IT'S IRRELEVANT @c An operator declared by @code{matchfix} is assigned a low binding power. @c Since a matchfix operator must be evaluated before any expression |