FILE: Parse.mesa
Last edited by Ousterhout, January 24, 1984 1:04 pm
Christian LeCocq April 29, 1986 1:11:16 pm PDT
This file contains definitions for a whole bunch of procedures
used to parse commands.
DIRECTORY
Globals,
IO,
Rope;
Parse: CEDAR DEFINITIONS =
BEGIN
OPEN Globals;
Args: PROC[line: Rope.ROPE] RETURNS [Arg];
This procedure chops up a line of text into arguments. Each argument is just the information between areas of white space, with one exception. If an argument is a switch (it starts with a "-"), and more than one character follows the "-", then all characters after the first are moved to a separate argument.
Real: PROC[arg: Arg] RETURNS [parseOK: BOOLEAN, val: REAL];
This procedure turns an argument into a real number. If the argument doesn't exist or the number cannot be parsed then parseOK is FALSE and val is 0.
Int: PROC[arg: Arg] RETURNS [parseOK: BOOLEAN, val: INT];
This procedure turns an argument into an interger. If the argument doesn't exist or the number cannot be parsed then parseOK is FALSE, and val is 0.
Lookup: PROC[rope: Rope.ROPE, table: DESCRIPTOR FOR ARRAY OF Rope.ROPE] RETURNS [index: INT];
The rope is looked up in the table to find a matching entry. The table must be in a monotonic order (e.g. sorted forwards or backwards). The return value is the index in the table of the matching entry. The rope matches an entry if it is a unique abbreviation for the entry. If the rope is an ambiguous abbreviation, then -1 is returned. If the rope just doesn't match anything, -2 is returned.
WhiteSpace: IO.BreakProc;
A replacement for IO.WhiteSpace, which got chopped from Cedar 5.0. It returns sepr on SP, TAB, CR, or LF. Otherwise it returns other.
END.