Input to dot mode is parsed into tokens as follows: All space characters are converted to a single blank. Any string that can be recognized as a Macaulay command is converted to a token of type oper; such tokens display as their original text, and share the precedence given to the virtual operator .cmd. Any quoted string is converted to a token of type ident, with the quotes stripped. A balanced braced expression (e.g. {\a2 ab}{ab b2}\) is converted as is to a single token of type brace. Such tokens are intended for future use, such as for flow control or deferred parsing. Macaulay-style identifiers and numbers are converted to tokens of type ident and number, respectively. A negative number must have its leading minus follow a space, or any operator except ), to be recognized: 1-2 is a difference, and 1 -2 is a pair of numbers. A lone _ is converted to a token of type ident, and is given a unique temporary name of the form @00@1; such variables are removed immediately after use. Finally, operators specific to dot mode (such as ` = , + *) are converted to tokens of type oper. The token list is terminated on each end by a token of type end, displayed as $.
To display the token list for an input line, end the line with the operator .stop, with a count of 0. For example:
.% a b = b a*((a=2)+(b=3)) .stop 0 $ a b = b a * ( ( a = 2 ) + ( b = 3 ) ) $
The token list is evaluated using operator precedence as follows: Each oper token, and the end tokens, have left and right precedence strings associated with them. The token list is scanned from right to left, comparing adjacent pairs of such tokens, until a pair is found where the right string of the left token alphabetizes before or is equal to the left string of the right token. The action associated with the right token is then carried out; this action will usually include a modification of the token list, such as replacing the token and its arguments with a result token. This process is then repeated until there are no more oper tokens, or an error occurs.
This process can be observed by turning on tracing, using the operator .trace. For example,
.% .trace
; tracing on
.% a b = b a*((a=2)+(b=3))
$ a b = b a * ( ( a = 2 ) + ( b = 3 ) ) $
^
$ a b = b a * ( ( a = 2 ) + ( b ) ) $
^
$ a b = b a * ( ( a = 2 ) + b ) $
^
$ a b = b a * ( ( a ) + b ) $
^
$ a b = b a * ( a + b ) $
^
$ a b = b a * ( @00@1 ) $
^
$ a b = b a * @00@1 $
^
$ a b = b @00@2 $
^
$ a b $
.% type a type b
$ type a type b $
^
10
$ type a $
^
3
To stop the evaluation loop after a specific number of steps, end the line with the operator .stop, with the desired count. For example:
.% a b = b a*((a=2)+(b=3)) .stop 5 $ a b = b a * ( @00@1 ) $Variables (including temporaries) can now be examined to sort out what happened.
To see the left and right precedence strings used in the evaluation loop, enter .parse by itself:
.% .parse
= z c
+ m n
- m n
* p q
, r s
\ z x
( y b
) b y
` a c
.cmd z c
.trace z x
.stop z x
.parse z x
$ a a
For example, if we adopt the convention that no right string can begin with "z", then an operator with a left string of "z" will be executed before any operator to its left on the token list.
To make a modification to this parse table, enter (for example):
.% ( .parse ya bMake changes at your own risk. However, you may need to fix an interaction we didn't consider. Please report all helpful changes; you may want to move them to your Macaulay.init file.