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.

Only ring variables that are single letters, or single letters indexed by a sequence of numbers can be handled with this parser.

The rules for creating polynomials using the classic parser include:

- Spaces, tabs, and newline characters are completely ignored.
- A variable is either (1) a single letter, (2) a subscripted variable, or (3) a polynomial enclosed in parentheses.
- Subscripted variables, e.g.,
`y_(1,1)`, are written using brackets, as in`y[1,1]`. Instead of explicit numbers for subscripted variables, Macaulay2 user variables that have an integer value may be used. - 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.
- A monomial is written without symbols for multiplication or exponentiation, where the (optional) coefficient comes first.
- A polynomial is a collection of monomials one after the other.
- Parenthesized subexpressions are allowed.
- Except for indices for subscripted variables, integers must be explicitly given.
- All of the variables used must already belong to a specific ring. If in doubt, first type
`use R`to ensure that all the symbols of`R`are in use.

The source code for this parser is relatively short, since it is based on the package Parsing. Here it is.

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 |

- Functions and commands
- poly, see poly(String) -- make a polynomial using classic Macaulay syntax

- poly(String) -- make a polynomial using classic Macaulay syntax
- ideal(String) -- make an ideal using classic Macaulay syntax
- matrix(String) -- make a matrix using classic Macaulay syntax