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 10:23:30 rswiston $ */
24 /* Parser.c contains the main procedure for program PARSER */
43 static char parserr[] = "\nM_token=%d, m_prevcon=%d, m_scanval=%d\n" ;
45 "prevcon=%d,token=%d,curcon=%d,scanval='%c'(%d),line=%d,netlevel=%d\n" ;
46 static char name[] = "m_name = '%s'\n" ;
47 static char literal[] = "m_literal = '%s'\n" ;
48 #if defined(hpux) || defined(_AIX) || defined(sun) || defined(linux)
49 char buffer[M_LITLEN + 80] ;
51 #define max4(a,b,c,d) (a>b&&a>c&&a>d) ? a : ((b>c&&b>d) ? b : (c>d ? c : d))
52 M_WCHAR buffer[max4(sizeof(parserr) + 3,
54 sizeof(name) + M_NAMELEN - 2,
55 sizeof(literal) + M_LITLEN - 2)] ;
72 m_prevcon = m_curcon ;
73 m_curcon = m_newcon(m_prevcon - 1, m_token - 1) ;
75 if (m_token != M_ENDFILE) {
76 m_error("Parsing table error") ;
77 sprintf(buffer, parserr, m_token, m_prevcon, m_scanval) ;
81 m_error("Unexpected end of document") ;
86 if ((! m_stacktop->oldtop) &&
89 m_state[m_stacktop->fsastack->current - 1].final &&
90 (m_token != M_ENDFILE) &&
91 (m_token != M_TEXT || ! m_whitespace((M_WCHAR) m_scanval))
93 m_error("Expecting end of document") ;
98 m_prevcon, m_token, m_curcon, m_scanval ? m_scanval : ' ',
99 m_scanval, m_line[m_sysecnt], m_netlevel) ;
101 if (m_token == M_NAME) {
102 sprintf(buffer, name, m_name) ;
105 if (m_token == M_LITERAL) {
106 sprintf(buffer, literal, m_literal) ;
112 if (m_token == M_ENDFILE) break ;