ParseImpl.mesa
Last Modified: Stewart, April 25, 1983 3:35 pm
DIRECTORY
Convert,
Parse,
Rope USING [ROPE];
ParseImpl: CEDAR PROGRAM
IMPORTS Convert
EXPORTS Parse =
BEGIN
SyntaxError: PUBLIC SIGNAL = CODE;
Int: PUBLIC PROC [r: Rope.ROPE, radix: NAT ← 10] RETURNS [INT] = {
v: Convert.Value ← Convert.Parse[text: [rope[r]], template: [signed[base: radix]]].value;
WITH val: v SELECT FROM
error => SyntaxError;
signed => RETURN[val.signed];
ENDCASE => SyntaxError;
RETURN[0];
};
Card: PUBLIC PROC [r: Rope.ROPE, radix: NAT ← 10] RETURNS [LONG CARDINAL] = {
v: Convert.Value ← Convert.Parse[text: [rope[r]], template: [unsigned[base: radix]]].value;
WITH val: v SELECT FROM
error => SyntaxError;
unsigned => RETURN[val.unsigned];
ENDCASE => SyntaxError;
RETURN[0];
};
END.
April 25, 1983 3:35 pm, LCS, created