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