2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: parser.c /main/3 1995/11/08 11:28:19 rswiston $ */
25 Copyright 1986 Tandem Computers Incorporated.
26 This product and information is proprietary of Tandem Computers Incorporated.
27 Copyright 1986, 1987, 1988, 1989 Hewlett-Packard Co.
30 /* Parser.c contains the main procedure for program PARSER */
49 static char parserr[] = "\nM_token=%d, m_prevcon=%d, m_scanval=%d\n" ;
51 "prevcon=%d,token=%d,curcon=%d,scanval='%c'(%d),line=%d,netlevel=%d\n" ;
52 static char name[] = "m_name = '%s'\n" ;
53 static char literal[] = "m_literal = '%s'\n" ;
54 #if defined(hpux) || defined(_AIX) || defined(sun)
55 char buffer[M_LITLEN + 80] ;
57 #define max4(a,b,c,d) (a>b&&a>c&&a>d) ? a : ((b>c&&b>d) ? b : (c>d ? c : d))
58 M_WCHAR buffer[max4(sizeof(parserr) + 3,
60 sizeof(name) + M_NAMELEN - 2,
61 sizeof(literal) + M_LITLEN - 2)] ;
73 m_prevcon = m_curcon ;
74 m_curcon = m_newcon(m_prevcon - 1, m_token - 1) ;
76 if (m_token != M_ENDFILE) {
77 m_error("Parsing table error") ;
78 sprintf(buffer, parserr, m_token, m_prevcon, m_scanval) ;
82 m_error("Unexpected end of document") ;
87 if ((! m_stacktop->oldtop) &&
90 m_state[m_stacktop->fsastack->current - 1].final &&
91 (m_token != M_ENDFILE) &&
92 (m_token != M_TEXT || ! m_whitespace((M_WCHAR) m_scanval))
94 m_error("Expecting end of document") ;
99 m_prevcon, m_token, m_curcon, m_scanval ? m_scanval : ' ',
100 m_scanval, m_line[m_sysecnt], m_netlevel) ;
102 if (m_token == M_NAME) {
103 sprintf(buffer, name, m_name) ;
106 if (m_token == M_LITERAL) {
107 sprintf(buffer, literal, m_literal) ;
113 if (m_token == M_ENDFILE) break ;