tldm-universe/Ardent/UV/APP.PROGS/STRIPSTRS.B
2024-09-09 17:51:08 -04:00

85 lines
2.8 KiB
Brainfuck
Executable File

*******************************************************************************
*
* uniVerse port of PI/open STRIPSTRINGS subroutine
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
*******************************************************************************
*
* Maintenance log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description.........................................
* 10/14/98 23801 SAP Change copyrights.
* 07/20/94 13952 WLG Fix syntax for COPY where ID,"ID" is used to insert
* TOKEN instead of TYPE and POS.
* 06/01/93 11645 PVW Backout 10793 changes
* 12/31/92 10793 PVW Check if matching literal delimiters.
* 11/12/92 10214 PVW Port PI/open EDITOR to replace uniVerse EDITOR.
*
*******************************************************************************
*
* Remove literals from sentence for lexical analysis.
*
*******************************************************************************
$OPTIONS INFORMATION
SUBROUTINE STRIPSTRINGS(SENTENCE,SYMBOLS)
$INCLUDE UNIVERSE.INCLUDE UV.COM
$INCLUDE UNIVERSE.INCLUDE VERBINSERT.H
$INCLUDE UNIVERSE.INCLUDE SYMBOL.TBL.H
POS=0
NEXT.LITERAL:
A=INDEX(SENTENCE,"'",1)
Q=INDEX(SENTENCE,'"',1)
* If we find quotes, replace the quoted string in sentence with
* the index into the SYMBOLS array of where the literal is placed.
* However, if TOKEN has the syntax ID1,"ID2" we should insert the
* token ID2 because the caller will know to handle the token
* as a literal becuase of the comma
IF A AND (A<Q OR Q=0) THEN
TOKEN = FIELD(SENTENCE,"'",2)
IF (SENTENCE[COL1()-1,1] = ",") THEN
SENTENCE=SENTENCE[1,COL1()-1]:TOKEN:" ":SENTENCE[COL2()+1,999]
END ELSE
SYMBOL.ORIGIN = 0
SYMBOL.VALUE=LITERAL ; GOSUB LSYMBOL
SENTENCE=SENTENCE[1,COL1()-1]:CHAR(LITERAL):POS:" ":SENTENCE[COL2()+1,999]
SYMBOLS(POS)=TOKEN
END
GOTO NEXT.LITERAL
END
IF Q THEN
TOKEN = FIELD(SENTENCE,'"',2)
IF (SENTENCE[COL1()-1,1] = ",") THEN
SENTENCE=SENTENCE[1,COL1()-1]:TOKEN:" ":SENTENCE[COL2()+1,999]
END ELSE
SYMBOL.ORIGIN = 0
SYMBOL.VALUE=LITERAL ; GOSUB LSYMBOL
SENTENCE=SENTENCE[1,COL1()-1]:CHAR(LITERAL):POS:" ":SENTENCE[COL2()+1,999]
SYMBOLS(POS)=TOKEN
END
GOTO NEXT.LITERAL
END
SENTENCE=TRIM(SENTENCE) ;* REMOVE REDUNDANT SPACES
RETURN
$INCLUDE UNIVERSE.INCLUDE SYMBOLINS.H
END