C ORDER_VAR ROUTINES C---------------------------------------------------------------------- C- C- Purpose and Methods : These routines manage a stack of VARIABLEs, in C- order to keep track of their ordering. The main variable is: C- C- INTEGER ORDER_VAR(1:STACK_PTR) C- C- ORDER_VAR(STACK_PTR) tells where in ORDER_VAR(1:STACK_PTR-2) is the C- current top of the stack. ORDER_VAR(STACK_LIST) tells how many C- variables vary in a LIST statement. No section uses more than 6 C- variables, and STACK_PTR >= 8. The stack elements are the tokens C- representing the different variables. C- C- Created 19-JUN-1990 MICHIGAN STATE UNIVERSITY, TRIGGER CONTROL SOFTWARE C- C---------------------------------------------------------------------- C C C SUBROUTINE PUSH_VAR( NEW_VAR, ORDER_VAR ) C---------------------------------------------------------------------- C- C- Purpose and Methods : Adds a variable on to the stack. Will cause a fatal C- error if increasing past top of stack is attempted. C- C- Inputs : NEW_VAR the token to be added to the stack C- ORDER_VAR (*MODIFIED*) the stack of specified variables. C- ORDER_VAR(STACK_PTR) = how many variables are C- currently on the stack. ORDER_VAR(STACK_LIST) = C- how many of those variables are from a LIST C- statement C- Outputs : none C- Controls: none C- C- Created 19-JUN-1990 MICHIGAN STATE UNIVERSITY, TRIGGER CONTROL SOFTWARE C- C---------------------------------------------------------------------- IMPLICIT NONE C---------------------------------------------------------------------- C C global declarations C INCLUDE 'D0$LEVEL1:PARSE_TOKENS.PARAMS' INCLUDE 'D0$LEVEL1:PARSE_TOKENS.INC' C C argument declarations C INTEGER NEW_VAR INTEGER ORDER_VAR(1:STACK_PTR) C C C IF ( ORDER_VAR(STACK_PTR) .GE. (STACK_PTR - 2)) THEN CALL MESSAGE_OUT(MES_PROG_PUSH_VAR, 0, ' ') GOTO 999 ENDIF C ORDER_VAR(STACK_PTR) = ORDER_VAR(STACK_PTR) + 1 ORDER_VAR( ORDER_VAR(STACK_PTR) ) = NEW_VAR C 999 RETURN END C C C SUBROUTINE PULL_VAR( ORDER_VAR, OLD_VAR ) C---------------------------------------------------------------------- C- C- Purpose and Methods : Removes the top variable from the stack. Will C- cause a fatal error if this routine is called with an empty C- stack. C- C- Inputs : ORDER_VAR (*MODIFIED*) the stack of specified variables. C- ORDER_VAR(STACK_PTR) = how many variables are C- currently on the stack. ORDER_VAR(STACK_LIST) = C- how many of those variables are from a LIST C- statement C- C- Outputs : OLD_VAR returns the value from the top of the C- stack C- Controls: none C- C- Created 19-JUN-1990 MICHIGAN STATE UNIVERSITY, TRIGGER CONTROL SOFTWARE C- C---------------------------------------------------------------------- IMPLICIT NONE C---------------------------------------------------------------------- C C global declarations C INCLUDE 'D0$LEVEL1:PARSE_TOKENS.PARAMS' INCLUDE 'D0$LEVEL1:PARSE_TOKENS.INC' C C argument declartions C INTEGER ORDER_VAR(1:STACK_PTR) INTEGER OLD_VAR C C C IF ( ORDER_VAR(STACK_PTR) .LT. 1 ) THEN CALL MESSAGE_OUT(MES_PROG_PULL_VAR, 0, ' ') GOTO 999 ENDIF C OLD_VAR = ORDER_VAR( ORDER_VAR(STACK_PTR)) ORDER_VAR(STACK_PTR) = ORDER_VAR(STACK_PTR) -1 C 999 RETURN END C C C SUBROUTINE POS_VAR( WHICH_VAR, ORDER_VAR, VAR_POS ) C---------------------------------------------------------------------- C- C- Purpose and Methods : Find what position in the stack WHICH_VAR is C- located. Returns 0 in VAR_POS if the variable is not in the C- stack. C- C- Inputs : C- WHICH_VAR the variable in question C- ORDER_VAR the stack of specified variables C- ORDER_VAR(STACK_PTR) = how many variables are C- currently on the stack. ORDER_VAR(STACK_LIST) = C- how many of those variables are from a LIST C- statement C- C- Outputs : C- VAR_POS returns the location of WHICH_VAR. 0 if not in C- stack. C- C- Controls: none C- C- Created 19-JUN-1990 MICHIGAN STATE UNIVERSITY, TRIGGER CONTROL SOFTWARE C- C---------------------------------------------------------------------- IMPLICIT NONE C---------------------------------------------------------------------- C C global declarations C INCLUDE 'D0$LEVEL1:PARSE_TOKENS.PARAMS' INCLUDE 'D0$LEVEL1:PARSE_TOKENS.INC' C C argument declarations C INTEGER WHICH_VAR INTEGER ORDER_VAR(1:STACK_PTR) INTEGER VAR_POS C C local variables C INTEGER COUNT C C C VAR_POS = 0 DO COUNT = 1, ORDER_VAR(STACK_PTR) IF ( WHICH_VAR .EQ. ORDER_VAR(COUNT) ) VAR_POS = COUNT END DO C 999 RETURN END