3 * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
4 * (Royal Institute of Technology, Stockholm, Sweden).
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the Institute nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 /* $Id: lex.l,v 1.31 2006/10/21 11:57:22 lha Exp $ */
53 static unsigned lineno = 1;
57 static void unterminated(const char *, unsigned);
61 /* This is for broken old lexes (solaris 10 and hpux) */
69 ABSENT { return kw_ABSENT; }
70 ABSTRACT-SYNTAX { return kw_ABSTRACT_SYNTAX; }
71 ALL { return kw_ALL; }
72 APPLICATION { return kw_APPLICATION; }
73 AUTOMATIC { return kw_AUTOMATIC; }
74 BEGIN { return kw_BEGIN; }
75 BIT { return kw_BIT; }
76 BMPString { return kw_BMPString; }
77 BOOLEAN { return kw_BOOLEAN; }
79 CHARACTER { return kw_CHARACTER; }
80 CHOICE { return kw_CHOICE; }
81 CLASS { return kw_CLASS; }
82 COMPONENT { return kw_COMPONENT; }
83 COMPONENTS { return kw_COMPONENTS; }
84 CONSTRAINED { return kw_CONSTRAINED; }
85 CONTAINING { return kw_CONTAINING; }
86 DEFAULT { return kw_DEFAULT; }
87 DEFINITIONS { return kw_DEFINITIONS; }
88 EMBEDDED { return kw_EMBEDDED; }
89 ENCODED { return kw_ENCODED; }
90 END { return kw_END; }
91 ENUMERATED { return kw_ENUMERATED; }
92 EXCEPT { return kw_EXCEPT; }
93 EXPLICIT { return kw_EXPLICIT; }
94 EXPORTS { return kw_EXPORTS; }
95 EXTENSIBILITY { return kw_EXTENSIBILITY; }
96 EXTERNAL { return kw_EXTERNAL; }
97 FALSE { return kw_FALSE; }
98 FROM { return kw_FROM; }
99 GeneralString { return kw_GeneralString; }
100 GeneralizedTime { return kw_GeneralizedTime; }
101 GraphicString { return kw_GraphicString; }
102 IA5String { return kw_IA5String; }
103 IDENTIFIER { return kw_IDENTIFIER; }
104 IMPLICIT { return kw_IMPLICIT; }
105 IMPLIED { return kw_IMPLIED; }
106 IMPORTS { return kw_IMPORTS; }
107 INCLUDES { return kw_INCLUDES; }
108 INSTANCE { return kw_INSTANCE; }
109 INTEGER { return kw_INTEGER; }
110 INTERSECTION { return kw_INTERSECTION; }
111 ISO646String { return kw_ISO646String; }
112 MAX { return kw_MAX; }
113 MIN { return kw_MIN; }
114 MINUS-INFINITY { return kw_MINUS_INFINITY; }
115 NULL { return kw_NULL; }
116 NumericString { return kw_NumericString; }
117 OBJECT { return kw_OBJECT; }
118 OCTET { return kw_OCTET; }
120 OPTIONAL { return kw_OPTIONAL; }
121 ObjectDescriptor { return kw_ObjectDescriptor; }
122 PATTERN { return kw_PATTERN; }
123 PDV { return kw_PDV; }
124 PLUS-INFINITY { return kw_PLUS_INFINITY; }
125 PRESENT { return kw_PRESENT; }
126 PRIVATE { return kw_PRIVATE; }
127 PrintableString { return kw_PrintableString; }
128 REAL { return kw_REAL; }
129 RELATIVE_OID { return kw_RELATIVE_OID; }
130 SEQUENCE { return kw_SEQUENCE; }
131 SET { return kw_SET; }
132 SIZE { return kw_SIZE; }
133 STRING { return kw_STRING; }
134 SYNTAX { return kw_SYNTAX; }
135 T61String { return kw_T61String; }
136 TAGS { return kw_TAGS; }
137 TRUE { return kw_TRUE; }
138 TYPE-IDENTIFIER { return kw_TYPE_IDENTIFIER; }
139 TeletexString { return kw_TeletexString; }
140 UNION { return kw_UNION; }
141 UNIQUE { return kw_UNIQUE; }
142 UNIVERSAL { return kw_UNIVERSAL; }
143 UTCTime { return kw_UTCTime; }
144 UTF8String { return kw_UTF8String; }
145 UniversalString { return kw_UniversalString; }
146 VideotexString { return kw_VideotexString; }
147 VisibleString { return kw_VisibleString; }
148 WITH { return kw_WITH; }
149 [-,;{}()|] { return *yytext; }
150 "[" { return *yytext; }
151 "]" { return *yytext; }
152 ::= { return EEQUAL; }
154 int c, start_lineno = lineno;
156 while((c = input()) != EOF) {
170 unterminated("comment", start_lineno);
173 int c, start_lineno = lineno;
177 while((c = input()) != EOF) {
188 if(seen_star && c == '/') {
197 seen_star = seen_slash = 0;
203 seen_star = seen_slash = 0;
210 unterminated("comment", start_lineno);
213 int start_lineno = lineno;
220 while((c = input()) != EOF) {
221 if(isspace(c) && skip_ws) {
242 while(p > buf && isspace((unsigned char)p[-1]))
250 unterminated("string", start_lineno);
252 fprintf(stderr, "string -- %s\n", buf);
253 yylval.name = estrdup(buf);
257 -?0x[0-9A-Fa-f]+|-?[0-9]+ { char *e, *y = yytext;
258 yylval.constant = strtol((const char *)yytext,
261 error_message("malformed constant (%s)", yytext);
265 [A-Za-z][-A-Za-z0-9_]* {
266 yylval.name = estrdup ((const char *)yytext);
271 \.\.\. { return ELLIPSIS; }
272 \.\. { return RANGE; }
273 . { error_message("Ignoring char(%c)\n", *yytext); }
276 #ifndef yywrap /* XXX */
285 error_message (const char *format, ...)
289 va_start (args, format);
290 fprintf (stderr, "%s:%d: ", get_filename(), lineno);
291 vfprintf (stderr, format, args);
297 unterminated(const char *type, unsigned start_lineno)
299 error_message("unterminated %s, possibly started on line %d\n", type, start_lineno);