next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Classic :: Classic

Classic -- a parser for classic Macaulay syntax

Description

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.

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

Author

Version

This documentation describes version 1.0 of Classic.

Source code

The source code from which this documentation is derived is in the file Classic.m2.

Exports

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

Menu