summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/asn1/lex.l
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-08-09 03:04:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:33 -0500
commitc0e8144c5d1e402b36ebe04b843eba62e7ab9958 (patch)
tree1b885ceee1a88e8cb2822051690b023c8f8acb78 /source4/heimdal/lib/asn1/lex.l
parent4b93e377cd9809199487e20fa53d8a2c98ad32ea (diff)
downloadsamba-c0e8144c5d1e402b36ebe04b843eba62e7ab9958.tar.gz
samba-c0e8144c5d1e402b36ebe04b843eba62e7ab9958.tar.bz2
samba-c0e8144c5d1e402b36ebe04b843eba62e7ab9958.zip
r9221: Try to merge Heimdal across from lorikeet-heimdal to samba4.
This is my first attempt at this, so there may be a few rough edges. Andrew Bartlett (This used to be commit 9a1d2f2fec67930975da856a2d365345cec46216)
Diffstat (limited to 'source4/heimdal/lib/asn1/lex.l')
-rw-r--r--source4/heimdal/lib/asn1/lex.l182
1 files changed, 146 insertions, 36 deletions
diff --git a/source4/heimdal/lib/asn1/lex.l b/source4/heimdal/lib/asn1/lex.l
index f0c123404a..cb6512f36f 100644
--- a/source4/heimdal/lib/asn1/lex.l
+++ b/source4/heimdal/lib/asn1/lex.l
@@ -1,6 +1,6 @@
%{
/*
- * Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*/
-/* $Id: lex.l,v 1.25 2005/06/16 19:58:35 lha Exp $ */
+/* $Id: lex.l,v 1.26 2005/07/12 06:27:33 lha Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -52,62 +52,118 @@
static unsigned lineno = 1;
-#define YY_NO_UNPUT
-
#undef ECHO
static void handle_comment(int type);
-
+static char *handle_string(void);
%}
%%
-INTEGER { return INTEGER; }
-BOOLEAN { return BOOLEAN; }
-IMPORTS { return IMPORTS; }
-FROM { return FROM; }
-SEQUENCE { return SEQUENCE; }
-CHOICE { return CHOICE; }
-OF { return OF; }
-OCTET { return OCTET; }
-STRING { return STRING; }
-GeneralizedTime { return GeneralizedTime; }
-GeneralString { return GeneralString; }
-UTF8String { return UTF8String; }
-NULL { return NULLTYPE; }
-BIT { return BIT; }
-APPLICATION { return APPLICATION; }
-OPTIONAL { return OPTIONAL; }
-BEGIN { return TBEGIN; }
-END { return END; }
-DEFAULT { return DEFAULT; }
-DEFINITIONS { return DEFINITIONS; }
-ENUMERATED { return ENUMERATED; }
-EXTERNAL { return EXTERNAL; }
-OBJECT { return OBJECT; }
-IDENTIFIER { return IDENTIFIER; }
-[-,;{}()|\"] { return *yytext; }
+ABSENT { return kw_ABSENT; }
+ABSTRACT-SYNTAX { return kw_ABSTRACT_SYNTAX; }
+ALL { return kw_ALL; }
+APPLICATION { return kw_APPLICATION; }
+AUTOMATIC { return kw_AUTOMATIC; }
+BEGIN { return kw_BEGIN; }
+BIT { return kw_BIT; }
+BMPString { return kw_BMPString; }
+BOOLEAN { return kw_BOOLEAN; }
+BY { return kw_BY; }
+CHARACTER { return kw_CHARACTER; }
+CHOICE { return kw_CHOICE; }
+CLASS { return kw_CLASS; }
+COMPONENT { return kw_COMPONENT; }
+COMPONENTS { return kw_COMPONENTS; }
+CONSTRAINED { return kw_CONSTRAINED; }
+CONTAINING { return kw_CONTAINING; }
+DEFAULT { return kw_DEFAULT; }
+DEFINITIONS { return kw_DEFINITIONS; }
+EMBEDDED { return kw_EMBEDDED; }
+ENCODED { return kw_ENCODED; }
+END { return kw_END; }
+ENUMERATED { return kw_ENUMERATED; }
+EXCEPT { return kw_EXCEPT; }
+EXPLICIT { return kw_EXPLICIT; }
+EXPORTS { return kw_EXPORTS; }
+EXTENSIBILITY { return kw_EXTENSIBILITY; }
+EXTERNAL { return kw_EXTERNAL; }
+FALSE { return kw_FALSE; }
+FROM { return kw_FROM; }
+GeneralString { return kw_GeneralString; }
+GeneralizedTime { return kw_GeneralizedTime; }
+GraphicString { return kw_GraphicString; }
+IA5String { return kw_IA5String; }
+IDENTIFIER { return kw_IDENTIFIER; }
+IMPLICIT { return kw_IMPLICIT; }
+IMPLIED { return kw_IMPLIED; }
+IMPORTS { return kw_IMPORTS; }
+INCLUDES { return kw_INCLUDES; }
+INSTANCE { return kw_INSTANCE; }
+INTEGER { return kw_INTEGER; }
+INTERSECTION { return kw_INTERSECTION; }
+ISO646String { return kw_ISO646String; }
+MAX { return kw_MAX; }
+MIN { return kw_MIN; }
+MINUS-INFINITY { return kw_MINUS_INFINITY; }
+NULL { return kw_NULL; }
+NumericString { return kw_NumericString; }
+OBJECT { return kw_OBJECT; }
+OCTET { return kw_OCTET; }
+OF { return kw_OF; }
+OPTIONAL { return kw_OPTIONAL; }
+ObjectDescriptor { return kw_ObjectDescriptor; }
+PATTERN { return kw_PATTERN; }
+PDV { return kw_PDV; }
+PLUS-INFINITY { return kw_PLUS_INFINITY; }
+PRESENT { return kw_PRESENT; }
+PRIVATE { return kw_PRIVATE; }
+PrintableString { return kw_PrintableString; }
+REAL { return kw_REAL; }
+RELATIVE_OID { return kw_RELATIVE_OID; }
+SEQUENCE { return kw_SEQUENCE; }
+SET { return kw_SET; }
+SIZE { return kw_SIZE; }
+STRING { return kw_STRING; }
+SYNTAX { return kw_SYNTAX; }
+T61String { return kw_T61String; }
+TAGS { return kw_TAGS; }
+TRUE { return kw_TRUE; }
+TYPE-IDENTIFIER { return kw_TYPE_IDENTIFIER; }
+TeletexString { return kw_TeletexString; }
+UNION { return kw_UNION; }
+UNIQUE { return kw_UNIQUE; }
+UNIVERSAL { return kw_UNIVERSAL; }
+UTCTime { return kw_UTCTime; }
+UTF8String { return kw_UTF8String; }
+UniversalString { return kw_UniversalString; }
+VideotexString { return kw_VideotexString; }
+VisibleString { return kw_VisibleString; }
+WITH { return kw_WITH; }
+[-,;{}()|] { return *yytext; }
"[" { return *yytext; }
"]" { return *yytext; }
::= { return EEQUAL; }
-- { handle_comment(0); }
\/\* { handle_comment(1); }
-0x[0-9A-Fa-f]+|[0-9]+ { char *e, *y = yytext;
+"\"" { yylval.name = handle_string(); return STRING; }
+
+-?0x[0-9A-Fa-f]+|-?[0-9]+ { char *e, *y = yytext;
yylval.constant = strtol((const char *)yytext,
&e, 0);
if(e == y)
error_message("malformed constant (%s)", yytext);
else
- return CONSTANT;
+ return NUMBER;
}
[A-Za-z][-A-Za-z0-9_]* {
- yylval.name = strdup ((const char *)yytext);
- return IDENT;
+ yylval.name = estrdup ((const char *)yytext);
+ return IDENTIFIER;
}
[ \t] ;
\n { ++lineno; }
-\.\.\. { return DOTDOTDOT; }
-\.\. { return DOTDOT; }
+\.\.\. { return ELLIPSIS; }
+\.\. { return RANGE; }
. { error_message("Ignoring char(%c)\n", *yytext); }
%%
@@ -128,6 +184,7 @@ error_message (const char *format, ...)
fprintf (stderr, "%s:%d: ", get_filename(), lineno);
vfprintf (stderr, format, args);
va_end (args);
+ error_flag++;
}
static void
@@ -165,6 +222,12 @@ handle_comment(int type)
seen_slash = 1;
continue;
}
+ if(seen_star && c == '/') {
+ if(--level == 0)
+ return;
+ seen_star = 0;
+ continue;
+ }
if(c == '*') {
if(seen_slash) {
level++;
@@ -184,3 +247,50 @@ handle_comment(int type)
if(c == EOF)
error_message("unterminated comment, possibly started on line %d\n", start_lineno);
}
+
+static char *
+handle_string(void)
+{
+ int start_lineno = lineno;
+ int c;
+ char buf[1024];
+ char *p = buf;
+ int f = 0;
+ int skip_ws = 0;
+
+ while((c = input()) != EOF) {
+ if(isspace(c) && skip_ws) {
+ if(c == '\n')
+ lineno++;
+ continue;
+ }
+ skip_ws = 0;
+
+ if(c == '"') {
+ if(f) {
+ *p++ = '"';
+ f = 0;
+ } else
+ f = 1;
+ continue;
+ }
+ if(f == 1) {
+ unput(c);
+ break;
+ }
+ if(c == '\n') {
+ lineno++;
+ while(p > buf && isspace((unsigned char)p[-1]))
+ p--;
+ skip_ws = 1;
+ continue;
+ }
+ *p++ = c;
+ }
+ if(c == EOF)
+ error_message("unterminated string, possibly started on line %d\n", start_lineno);
+ *p++ = '\0';
+ fprintf(stderr, "string -- %s\n", buf);
+ return estrdup(buf);
+}
+