-- GetInterFileImpl.Mesa
-- written by Paxton. January 1981
-- last written by Paxton. August 24, 1982 10:40 am
DIRECTORY
InterFile,
TextEdit,
RopeFrom,
CIFS,
File,
IO,
RopeEdit,
RopeIO,
RopeReader;
GetInterFileImpl:
CEDAR PROGRAM
IMPORTS CIFS, RopeFrom, RopeEdit, RopeIO, RopeReader, TextEdit
EXPORTS InterFile =
BEGIN OPEN InterFile;
FromFileError: PUBLIC ERROR = CODE;
FromFile:
PUBLIC
PROC [fileName:
ROPE, start: Offset ← 0, len: Offset ← MaxLen]
RETURNS [root: Ref] = {
fh: CIFS.OpenFile = CIFS.Open[fileName, CIFS.read];
file: File.Capability ← CIFS.GetFC[fh];
root ← FromFileC[file,start,len];
CIFS.Close[fh] };
FromFileC:
PUBLIC
PROC [file: File.Capability, start: Offset ← 0, len: Offset ← MaxLen]
RETURNS [Ref] = {
RETURN [FromRope[RopeFrom.File[file,start,len]]] };
FromStream:
PUBLIC
PROC [stream:
IO.Handle, len: Offset ← MaxLen]
RETURNS [Ref] = {
RETURN [FromRope[RopeIO.GetRope[stream,len]]] };
FromRope:
PUBLIC
PROC [rope:
ROPE, start: Offset ← 0, len: Offset ← MaxLen]
RETURNS [Ref] = {
source: RopeReader.Ref ← RopeReader.Create[];
RopeReader.SetPosition[source,RopeEdit.Substr[rope,start,len]];
RETURN [Tree[source]] };
Tree:
PROC [source: RopeReader.Ref]
RETURNS [root: Ref] = {
-- not implemented yet
RETURN [TextEdit.DocFromNode[TextEdit.FromRope[RopeReader.GetRope[source]]]] };
StartGetFile:
PUBLIC
PROC = {
};
END.
Current limited syntax for Tioga InterDoc files:
node = '{ typename property* contents child* '}
property = propname '= ( text | node )
text = '< character* '>
contents = ( text | run )* | other
run = '{ looks text '}
looks = "looks=" text
other = varietyname '[ text ']
child = node