1
0
mirror of https://github.com/PDP-10/its.git synced 2026-03-08 03:49:36 +00:00
Files
PDP-10.its/src/mprog/parse.umss02

83 lines
2.2 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
;"This RSUBR is used in the CALUTL package of MUDCAL (EHB)"
<TITLE FSP-PARSE>
<DECLARE ("VALUE" <VECTOR [REST <OR LOSE STRING>]> STRING)>
<PUSH TP* $TFIX> ; "Build empty vector"
<PUSH TP* [4]>
<MCALL 1 IVECTOR>
<PUSH TP* A> ; "Save it"
<PUSH TP* B>
LOOP <HRRZ A* (AB)> ; "Check string length"
<MOVE D* 1(AB)> ; "Get byte pointer"
ILOOP <JUMPE A* DONE> ; "Quit when string is empty"
<ILDB B* D> ; "Get next char"
<CAIE B* *11*> ; "Tab?"
<CAIN B* *40*> ; "Space?"
<SKIPA> ; "Yes - keep scanning"
<JRST SFIELD> ; "No - start of a field"
<MOVEM D* 1(AB)> ; "Update byte pointer"
<SOJA A* ILOOP> ; "Yes - and count"
SFIELD <HRRM A* (AB)> ; "Update string count"
<SETZM C> ; "Count sub-field"
COUNT <CAIE B* *40*> ; "Space?"
<CAIN B* *11*> ; "Tab?"
<JRST EFIELD> ; "Yes - end"
<CAIE B* !":> ; "Colon?"
<CAIN B* !";> ; "Semi-colon"
<JRST EFIELD> ; "Yes - end"
<AOS C> ; "Bump field size"
<ILDB B* D> ; "Get next char"
<SOJG A* COUNT> ; "Keep looking unless end of string"
EFIELD <PUSH TP* $TFIX> ; "Now get a string of the right length"
<PUSH TP* C>
<MCALL 1 ISTRING>
<PUSH TP* A> ; "Save the string"
<PUSH TP* B>
<HRRZS A> ; "Isolate length"
<HRRZ C* (AB)> ; "Get current input string length"
COPY <ILDB D* 1(AB)> ; "Copy characters"
<IDPB D* B>
<SOS C>
<SOJG A* COPY>
<HRRM C* (AB)> ; "Update input string length"
<JUMPE C* FNAME> ; "If end of string - file name"
<SOS (AB)> ; "Otherwise - get next char"
<ILDB A* 1(AB)> ; "And see what it is"
<CAIE A* *40*>
<CAIN A* *11*>
<JRST FNAME> ; "Space or tab - file name"
<CAIN A* !":>
<JRST DEV> ; "Colon - device"
<CAIN A* !";>
<JRST DIR> ; "Semi-colon - directory"
<JRST FNAME> ; "Huh?? - how did we get here"
FNAME <MOVE A* 1(TB)> ; "Get vector pointer"
<GETYP E* 4(A)> ; "Get file name 1"
<CAIN E* TSTRING> ; "Is it alread a string"
<JRST FNAME2> ; "Yes - file name 2"
<POP TP* 5(A)> ; "No - string on stack is file name 1"
<POP TP* 4(A)>
<JRST LOOP>
FNAME2 <POP TP* 7(A)> ; "String - file name 2"
<POP TP* 6(A)>
<JRST LOOP>
DEV <MOVE A* 1(TB)> ; "String is device"
<POP TP* 1(A)>
<POP TP* (A)>
<JRST LOOP>
DIR <MOVE A* 1(TB)> ; "String is directory"
<POP TP* 3(A)>
<POP TP* 2(A)>
<JRST LOOP>
DONE <POP TP* B> ; "Return the vector"
<POP TP* A>
<JRST FINIS>