<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>Classic -- a parser for classic Macaulay syntax</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_poly_lp__String_rp.html">next</a> | previous | <a href="_monomial__Ideal_lp__String_rp.html">forward</a> | backward | up | top | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>Classic -- a parser for classic Macaulay syntax</h1> <div class="single"><h2>Description</h2> <div><p>This package provides a parser for polynomials in the classic Macaulay format. Some users prefer it, for ease and speed of typing polynomials, ideals, and matrices.</p> <p>Only ring variables that are single letters, or single letters indexed by a sequence of numbers can be handled with this parser.</p> <p>The rules for creating polynomials using the classic parser include:</p> <ul><li>Spaces, tabs, and newline characters are completely ignored.</li> <li>A variable is either (1) a single letter, (2) a subscripted variable, or (3) a polynomial enclosed in parentheses.</li> <li>Subscripted variables, e.g., <tt>y_(1,1)</tt>, are written using brackets, as in <tt>y[1,1]</tt>. Instead of explicit numbers for subscripted variables, Macaulay2 user variables that have an integer value may be used.</li> <li>Coefficients are either integers or rational numbers, starting with a + or - (which may be omitted for the first monomial). Over finite fields, the division is performed in that field.</li> <li>A monomial is written without symbols for multiplication or exponentiation, where the (optional) coefficient comes first.</li> <li>A polynomial is a collection of monomials one after the other.</li> <li>Parenthesized subexpressions are allowed.</li> <li>Except for indices for subscripted variables, integers must be explicitly given.</li> <li>All of the variables used must already belong to a specific ring. If in doubt, first type <tt>use R</tt> to ensure that all the symbols of <tt>R</tt> are in use.</li> </ul> <p>The source code for this parser is relatively short, since it is based on the package <a href="../../Parsing/html/index.html" title="a framework for building parsers">Parsing</a>. Here it is.</p> <table class="examples"><tr><td><pre>symbolP = (x -> ( if not isGlobalSymbol x then error("symbol ",x," undefined"); getGlobalSymbol x)) % letterParser seqP = (comma, parser) -> prepend % parser @ * (last % comma @ parser) variableP = value % symbolP intP = NNParser | variableP subscriptP = ((lb,x,rb) -> x) % andP( "[", unsequence % seqP_"," intP, "]" ) ringVariableP = ((x,n) -> value if n === nil then x else x_n) % symbolP @ optP subscriptP numberP = ZZParser | QQParser powerP = ((x,n) -> if n === nil then x else x^n) % (futureParser parenExprP | ringVariableP) @ optP NNParser monomialP = times @@ deepSplice % optionalSignParser @ (numberP @ *powerP | +powerP ) polyP = plus @@ deepSplice % +monomialP | terminalParser 0 parenExprP = ((l,x,r) -> x) % andP("(", futureParser parenExprP | polyP, ")") listPolyP = toList % seqP_"," polyP arrayPolyP = toList % seqP_";" listPolyP export poly ; poly = method() poly String := RingElement => polyP : nonspaceAnalyzer ideal String := Ideal => ideal % listPolyP : nonspaceAnalyzer monomialIdeal String := MonomialIdeal => monomialIdeal % listPolyP : nonspaceAnalyzer matrix String := Matrix => opts -> matrix_opts % arrayPolyP : nonspaceAnalyzer</pre> </td></tr> </table> </div> </div> <div class="single"><h2>Author</h2> <ul><li><div class="single"><a href="http://www.math.uiuc.edu/~dan/">Daniel R. Grayson</a><span> <<a href="mailto:dan@math.uiuc.edu">dan@math.uiuc.edu</a>></span></div> </li> </ul> </div> <div class="single"><h2>Version</h2> This documentation describes version <b>1.0</b> of Classic.</div> <div class="single"><h2>Source code</h2> The source code from which this documentation is derived is in the file <a href="../../../../Macaulay2/Classic.m2">Classic.m2</a>.</div> <div class="single"><h2>Exports</h2> <ul><li><div class="single">Functions<ul><li><span>poly, see <span><a href="_poly_lp__String_rp.html" title="make a polynomial using classic Macaulay syntax">poly(String)</a> -- make a polynomial using classic Macaulay syntax</span></span></li> </ul> </div> </li> </ul> </div> <div><h3>Menu</h3> <ul><li><span><a href="_poly_lp__String_rp.html" title="make a polynomial using classic Macaulay syntax">poly(String)</a> -- make a polynomial using classic Macaulay syntax</span></li> <li><span><a href="_ideal_lp__String_rp.html" title="make an ideal using classic Macaulay syntax">ideal(String)</a> -- make an ideal using classic Macaulay syntax</span></li> <li><span><a href="_matrix_lp__String_rp.html" title="make a matrix using classic Macaulay syntax">matrix(String)</a> -- make a matrix using classic Macaulay syntax</span></li> </ul> </div> </div> </body> </html>