xref: /titanic_50/usr/src/cmd/sgs/lex/common/nrform (revision 174bc6499d233e329ecd3d98a880a7b07df16bfa)
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
26#pragma ident	"%Z%%M%	%I%	%E% SMI"
27
28block data
29integer cshift, csize, yynlin
30common /yyllib/ cshift, csize, yynlin
31data yynlin/YYNEWLINE/
32end
33block data
34common /yyldat/ yyfnd, ymorf, yyprev, yybgin, yytop
35integer yyfnd, yymorf, yyprev, yybgin, yytop
36data yybgin/1/
37data yyprev/YYNEWLINE/
38data yytop/YYTOPVAL/
39end
40integer function yylook(dummy)
41common /Lverif/ verif
42common /Ladvan/ advan
43common /Lstoff/ stoff
44common /Lsfall/ sfall
45common /Latable/ atable
46common /Lextra/ extra
47common /Lvstop/ vstop
48integer verif(Sverif), advan(Sadvan),stoff(Sstoff),match(Smatch)
49integer sfall(Ssfall),atable(Satable),extra(Sextra), vstop(Svstop)
50integer state, lsp, r
51integer  ch, n
52common /yyldat/ yyfnd, yymorf, yyprev, yybgin, yytop, yylsp, yylsta(YYLMAX)
53common /yyxel/ yyleng, yytext
54integer yyfnd, yymorf, yylsta, yylsp, yytext, yyprev, yyleng, yytop
55integer  lexshf, yytext(YYLMAX), yyback, yybgin
56integer z, t
57if (yymorf .eq. 0)
58	yyleng = 0
59else
60	yymorf=0
611776
62	lsp = 1
63	state = yybgin
64	if (yyprev .eq. YYNEWLINE)
65		state = state + 1
66	for (;;){
67		r = stoff(state)
68		if (r .eq. 0){
69			z = sfall(state)
70			if (z .eq. 0)
71				break
72			if(stoff(z) == 0) break
73			}
74		ch = input(dummy)
75		ich = lexshf(ch)
76		yyleng = yyleng+1
77		yytext(yyleng) = ch
78		1984
79		if(r .gt. 0){
80			t = r + ich
81			if (t<= yytop){
82			  if (verif(t) .eq. state){
83				if(advan(t) == YYERROR){
84					call unput(yytext(yyleng))
85					yyleng = yyleng - 1
86					break
87					}
88				state = advan(t)
89				yylsta(lsp) = state
90				lsp = lsp +1
91				goto 2001
92				}
93			  }
94			}
95		if(r < 0){
96			t = r + ich
97			if (t <= yytop .and. verif(t) .eq. state){
98				if(advan(t) == YYERROR){
99					call unput(yytext(yyleng))
100					yyleng = yyleng - 1
101					break
102					}
103				state = advan(t)
104				yylsta(lsp) = state
105				lsp = lsp +1
106				goto 2001
107				}
108			t = r + match(ich)
109			if(t <= yytop && state == verif(t)){
110				if(advan(t) == YYERROR){
111					call unput(yytext(yyleng))
112					yyleng = yyleng - 1
113					break
114					}
115			state = advan(t)
116			yylsta(lsp) = state
117			lsp = lsp + 1
118			goto 2001
119			}
120		}
121		else {
122			if (state > 0) state = sfall(state)
123			if (state .gt. 0) r = stoff(state)
124			if (state .gt. 0 .and. r .ne. 0)
125				goto 1984
126			call unput(yytext(yyleng))
127			yyleng = yyleng -1
128			break
129			}
130	2001
131		continue
132		}
133	while (lsp .gt. 1){
134		lsp = lsp -1
135		ilsp = yylsta(lsp)
136		yyfnd = atable(ilsp)
137		if (yyfnd .gt. 0)
138			if (vstop(yyfnd) .gt. 0){
139				r = vstop(yyfnd)
140				if (extra(r) .ne. 0){
141					for(;;){
142					ilsp = yylsta(lsp)
143					if (yyback(atable(ilsp), -r) .eq. 1)
144						break
145					lsp= lsp -1
146					call unput(yytext(yyleng))
147					yyleng = yyleng -1
148					}
149					}
150				yyprev = lexshf(yytext(yyleng))
151				yylsp = lsp
152				yyfnd = yyfnd + 1
153				yylook = r
154				yytext(yyleng+1) = 0
155				return
156				}
157		call unput(yytext(yyleng))
158		}
159	if (yytext(1) .eq. 0){
160		yylook=0
161		return
162		}
163	yyprev = input(dummy)
164	call output(yyprev)
165	yyprev = lexshf(yyprev)
166	yyleng = 0
167	goto 1776
168end
169integer function yyback (isub, n)
170common /Lvstop/ vstop
171integer vstop(Svstop)
172if (isub .ne. 0)
173while (vstop(isub) .ne. 0){
174	if (vstop(isub) .eq. m){
175		yyback = 1
176		return
177		}
178	isub = isub + 1
179	}
180yyback = 0
181return
182end
183