> <\body> Identifiers are formed using letters, digits and the special characters and . Identifiers must start with a letter or . Identifiers match the regular expression. Examples of identifiers are , , and . Some special predefined constants are: <\description> >The boolean constant . >The boolean constant . >The standard output stream. >The standard error stream. Notice that streams can be used with the operators \> as in C++: <\mmx-code> mmout \\ 3 \\ "\\n"; supports three types of literal constants: <\description> Strings can be braced into double quotes . Inside such a string a double quote must be blackslashed. In order to avoid blackslashing one can use the stronger string delimiters . <\mmx-code> s1 := "This is a string"; s2 := "Print \\"foo\\""; s2 := /"Print "foo"/; An integer literal is a sequence of digits, possible preceded by a minus sign. It matches the regular expression . Examples: , . A floating literal is a sequence of digits with a decimal point inside and an optional exponent. It matches the regular expression . Some examples: <\mmx-code> z := 0.0; w := -3.14159; x := 1.11e2007 Note that is not permited, >. To assign a value to a variable, we use the operator , while constant values are defined by the operator , and cannot be modified hereafter. <\session|mathemagix|default> <\unfolded-io> <|unfolded-io> a1 := 1 <|unfolded-io> <\unfolded-io> <|unfolded-io> a1_? == 2; a1_? <|unfolded-io> <\unfolded-io> <|unfolded-io> cst: Int == 11111*111111 <|unfolded-io> <\unfolded-io> <|unfolded-io> mut: Int := 1010*1234 <|unfolded-io> <\unfolded-io> <|unfolded-io> cst := - cst <|unfolded-io> <\errput> :: , \ cst := - cst ~~~ <\unfolded-io> <|unfolded-io> mut := - mut <|unfolded-io> Here we list the operators in priority order, together with their internal names: <\with|par-columns|2> >||>|>||>|>>||>|>>||>|||>| >||>|>||>|>||>|>||>|||>|\>>||>|\*>>||>|\%>>||>|\>>>||>|>>||>|=\>>||>|||>|>||>|||>|>||>|||>|>||>|||>|||>|>||>|>>||>|=>>||>|>>||>|=>>||>|>||>|>>||>|=>>||>|>>||>|=>>||>|||>|>>||>|>>||>|||>|>||>|>||>|||>|>||>|>||>|>||>|>||>|||>|>||>|>||>|>||>|>||>|>||>|>||>|>||>|||>|>||>|>||>|>||>|>||>|>||>|>||>|||>|>||>|||>|>||>|>||>|>||>|>||>|>||>|>||>|>||>>>>> \; Whenever writing a complex expression you should carefully consider these priority rules in order to avoid using extra parentheses. For example the expression <\mmx-code> if ((a*b)+(c)\(d)) then foo (); should be better written <\mmx-code> if a*b + c \ d then foo (); The Mathemagix grammar is specified in the file of the module. Instructions are separated with . <\cpp-code> x := 1; y := 3; z := x*y; The construction is as follows: block1 block2. condition is any expression that evaluates to a boolean. block1 and block2 are either one instruction or a block of instructions braced into .... The part is optional. <\mmx-code> if true then 1; if a = b then 1 else 2; if i = 0 then { x := 1; y := 2} else { z := 3; mmerr \\ "error" } For the sake of readability do not write\ <\mmx-code> if a = 0 then { b := 0 } but <\mmx-code> if a = 0 then b := 0; instead, since are not needed for a block with one instruction only. Notice that, according to the priority rules of the operators listed above, the expression <\mmx-code> if ((a = 0) and (b = 0)) then foo (); should be written <\mmx-code> if a = 0 and b = 0 then foo (); for the sake of readability. Loops are constructed as follows: [ E1] [ E2] [ E3] [ E4] block. Here ... means that the expression is optional. block is an instruction or a sequence of instruction delimited by .... exits the loop, and goes to the next step of the loop. <\mmx-code> do mmout \\ "no end "; // This loop has no end for i in 1..3 do mmout \\ i \\ " "; i := 0; while i \ 0 do { mmout \\ i \\ " "; i := i + 1 } Comments starting with extend to the end of the physical line. Such a comment may appear at the start of a line or following whitespace or code, but not within a string literal. Multi-line comments must be braced into and can be nested. <\mmx-code> x := 1; // Assign 1 to x. \; y := 2; /{ This \ \ \ is multi-line \ \ \ comment about y. }/ . If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.>