Subversion Repositories planix.SVN

Rev

Rev 24 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 7u83 1
.TH MPC 1 
2
.SH NAME
3
mpc \- extended precision arithmetic code generator
4
.SH SYNOPSIS
5
.B mpc
6
[
7
.I file ...
8
]
9
.SH DESCRIPTION
10
.I Mpc
11
generates C functions from a simple language that operates on
12
extended precision integers using the
13
.IR mp (2)
14
library.
15
.SH LANGUAGE
16
The language consists of a series of function definitions of the form:
17
.IP
18
.I name
19
(
20
.I "parameter list"
21
) {
22
.I statements
23
}
24
.PP
25
All variables and parameters are extended precision integers and are
26
passed by reference. Statements are separated by semicolon and the
27
following statemens are defined:
28
.IP
29
.I name
30
.B =
31
.I expression
32
.IP
33
.B if
34
(
35
.I condition
36
) {
37
.I statements
38
}
39
.B "else if"
40
(
41
.I condition
42
) {
43
.I statements
44
}
45
.B else
46
{
47
.I statements
48
}
49
.IP
50
.B while
51
(
52
.I condition
53
) {
54
.I statements
55
}
56
.IP
57
.B break
58
.IP
59
.I
60
name
61
(
62
.I "parameter list"
63
)
64
.IP
65
.B
66
mod
67
(
68
.I modulus
69
) {
70
.I statements
71
}
72
.PP
73
There is no distinction between input and output parameters, but
74
conventionally, the outputs are put at the end of the
75
.I "parameter list"
76
and the language allows one to write
77
.IP
78
.I F
79
(
80
.IR X ,
81
.IR Y ,
82
.I Z
83
)
84
as
85
.IR Y ,
86
.I Z
87
.B =
88
.I F
89
(
90
.I X
91
)
92
.PP
93
Expressions are composed out of the following arithmetic operations:
94
.RS
95
.TF _____________
96
.TP
97
.B +
98
addition.
99
.TP
100
.B -
101
subtraction.
102
.TP
103
.B *
104
multiplication.
105
.TP
106
.B /
107
division, or multiplicative inverse when enclosed in
108
.B mod
109
block.
110
.TP
111
.B %
112
division remainder.
113
.TP
114
.B ^
115
exponentiation.
116
.TP
117
.BI >> constant
118
right shift by a constant.
119
.TP
120
.BI << constant
121
left shift by a constant.
122
.TP
123
.IB condition ? a : b
124
pick
125
.I a
126
when
127
.I condition is true, otherwise
128
.I b
129
when false.
130
.RE
131
.PD
132
.PP
133
Conditions can use the following operations:
134
.RS
135
.TF _____________
136
.TP
137
.B ==
138
equality.
139
.TP
140
.B !=
141
inequality.
142
.TP
143
.B >
144
bigger than.
145
.TP
146
.B <
147
smaller than.
148
.TP
149
.BI ! condition
150
negation.
151
.RE
152
.SH SOURCE
153
.B /sys/src/cmd/mpc.y
154
.SH "SEE ALSO"
155
.IR mp (2)