xref: /illumos-gate/usr/src/cmd/sgs/lex/common/nrform (revision e3ae4b35c024af1196582063ecee3ab79367227d)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright (c) 1993 by Sun Microsystems, Inc.
24 */
25
26block data
27integer cshift, csize, yynlin
28common /yyllib/ cshift, csize, yynlin
29data yynlin/YYNEWLINE/
30end
31block data
32common /yyldat/ yyfnd, ymorf, yyprev, yybgin, yytop
33integer yyfnd, yymorf, yyprev, yybgin, yytop
34data yybgin/1/
35data yyprev/YYNEWLINE/
36data yytop/YYTOPVAL/
37end
38integer function yylook(dummy)
39common /Lverif/ verif
40common /Ladvan/ advan
41common /Lstoff/ stoff
42common /Lsfall/ sfall
43common /Latable/ atable
44common /Lextra/ extra
45common /Lvstop/ vstop
46integer verif(Sverif), advan(Sadvan),stoff(Sstoff),match(Smatch)
47integer sfall(Ssfall),atable(Satable),extra(Sextra), vstop(Svstop)
48integer state, lsp, r
49integer  ch, n
50common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yytop, yylsp, yylsta(YYLMAX)
51common /yyxel/ yyleng, yytext
52integer yyfnd, yymorf, yylsta, yylsp, yytext, yyprev, yyleng, yytop
53integer  lexshf, yytext(YYLMAX), yyback, yybgin
54integer z, t
55if (yymorf .eq. 0)
56	yyleng = 0
57else
58	yymorf=0
591776
60	lsp = 1
61	state = yybgin
62	if (yyprev .eq. YYNEWLINE)
63		state = state + 1
64	for (;;){
65		r = stoff(state)
66		if (r .eq. 0){
67			z = sfall(state)
68			if (z .eq. 0)
69				break
70			if(stoff(z) == 0) break
71			}
72		ch = input(dummy)
73		ich = lexshf(ch)
74		yyleng = yyleng+1
75		yytext(yyleng) = ch
76		1984
77		if(r .gt. 0){
78			t = r + ich
79			if (t<= yytop){
80			  if (verif(t) .eq. state){
81				if(advan(t) == YYERROR){
82					call unput(yytext(yyleng))
83					yyleng = yyleng - 1
84					break
85					}
86				state = advan(t)
87				yylsta(lsp) = state
88				lsp = lsp +1
89				goto 2001
90				}
91			  }
92			}
93		if(r < 0){
94			t = r + ich
95			if (t <= yytop .and. verif(t) .eq. state){
96				if(advan(t) == YYERROR){
97					call unput(yytext(yyleng))
98					yyleng = yyleng - 1
99					break
100					}
101				state = advan(t)
102				yylsta(lsp) = state
103				lsp = lsp +1
104				goto 2001
105				}
106			t = r + match(ich)
107			if(t <= yytop && state == verif(t)){
108				if(advan(t) == YYERROR){
109					call unput(yytext(yyleng))
110					yyleng = yyleng - 1
111					break
112					}
113			state = advan(t)
114			yylsta(lsp) = state
115			lsp = lsp + 1
116			goto 2001
117			}
118		}
119		else {
120			if (state > 0) state = sfall(state)
121			if (state .gt. 0) r = stoff(state)
122			if (state .gt. 0 .and. r .ne. 0)
123				goto 1984
124			call unput(yytext(yyleng))
125			yyleng = yyleng -1
126			break
127			}
128	2001
129		continue
130		}
131	while (lsp .gt. 1){
132		lsp = lsp -1
133		ilsp = yylsta(lsp)
134		yyfnd = atable(ilsp)
135		if (yyfnd .gt. 0)
136			if (vstop(yyfnd) .gt. 0){
137				r = vstop(yyfnd)
138				if (extra(r) .ne. 0){
139					for(;;){
140					ilsp = yylsta(lsp)
141					if (yyback(atable(ilsp), -r) .eq. 1)
142						break
143					lsp= lsp -1
144					call unput(yytext(yyleng))
145					yyleng = yyleng -1
146					}
147					}
148				yyprev = lexshf(yytext(yyleng))
149				yylsp = lsp
150				yyfnd = yyfnd + 1
151				yylook = r
152				yytext(yyleng+1) = 0
153				return
154				}
155		call unput(yytext(yyleng))
156		}
157	if (yytext(1) .eq. 0){
158		yylook=0
159		return
160		}
161	yyprev = input(dummy)
162	call output(yyprev)
163	yyprev = lexshf(yyprev)
164	yyleng = 0
165	goto 1776
166end
167integer function yyback (isub, n)
168common /Lvstop/ vstop
169integer vstop(Svstop)
170if (isub .ne. 0)
171while (vstop(isub) .ne. 0){
172	if (vstop(isub) .eq. m){
173		yyback = 1
174		return
175		}
176	isub = isub + 1
177	}
178yyback = 0
179return
180end
181