aboutsummaryrefslogtreecommitdiff
path: root/unix/boot/spp/rpp/rpprat/eatup.r
blob: df001caf8b9b99ac895b7364a39f612e5425bc0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#-h-  eatup			 1137  local   12/01/80  15:53:50
# eatup - process rest of statement; interpret continuations
   include  defs

   subroutine eatup

   character ptoken (MAXTOK), t, token (MAXTOK)
   character gettok
   integer nlpar, equal
   include COMMON_BLOCKS
   string serror "error"

   nlpar = 0
   token(1) = EOS

   repeat {
       call outstr (token)
       t = gettok (token, MAXTOK)
   } until (t != BLANK & t != TAB)

   if (t == ALPHA) {				# is it a "call error" stmt?
      if (equal (token, serror) == YES) {
	 # call errorc (token)
	 # return

	 # ERROR statement is now simply error checked like any other
	 # external procedure, so that it may be used the same way.
	 ername = YES
	 }
      }
   goto 10

   repeat {
      t = gettok (token, MAXTOK)
10    if (t == SEMICOL | t == NEWLINE)
	 break
      if (t == RBRACE | t == LBRACE) {
	 call pbstr (token)
	 break
	 }
      if (t == EOF) {
	 call synerr ("unexpected EOF.")
	 call pbstr (token)
	 break
	 }
      if (t == COMMA | t == PLUS | t == MINUS | t == STAR |
      (t == SLASH & body == YES) |
       t == LPAREN | t == AND | t == BAR | t == BANG | t == TILDE |
       t == NOT | t == CARET | t == EQUALS | t == UNDERLINE) {
	 while (gettok (ptoken, MAXTOK) == NEWLINE)
	    ;
	 call pbstr (ptoken)
	 if (t == UNDERLINE)
	    token (1) = EOS
	 }
      if (t == LPAREN)
	 nlpar = nlpar + 1
      else if (t == RPAREN)
	 nlpar = nlpar - 1
      if (t == ALPHA)
	 call squash (token)
      call outstr (token)
      } until (nlpar < 0)

   if (nlpar != 0)
      call synerr ("unbalanced parentheses.")

   return
   end