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:
The source code for this parser is relatively short, since it is based on the package Parsing. Here it is.
export "poly" 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 poly = method() polyParser = polyP : nonspaceAnalyzer poly String := RingElement => x -> polyParser x idealParser = ideal % listPolyP : nonspaceAnalyzer ideal String := Ideal => x -> idealParser x monomialIdealParser = monomialIdeal % listPolyP : nonspaceAnalyzer monomialIdeal String := MonomialIdeal => x -> monomialIdealParser x matrix String := Matrix => opts -> matrix_opts % arrayPolyP : nonspaceAnalyzer |
This documentation describes version 1.0 of Classic.
The source code from which this documentation is derived is in the file Classic.m2.