git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@864 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1996-10-20 16:47:54 +00:00
parent 309846037c
commit dbdb412ba0
25 changed files with 595 additions and 479 deletions

View File

@@ -3,6 +3,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "der.h"

View File

@@ -3,6 +3,7 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "der.h"

View File

@@ -19,6 +19,7 @@ init_generate (char *filename)
fprintf (codefile,
"/* Generated from %s */\n"
"/* Do not edit */\n\n"
"#include <stdio.h>\n"
"#include <stdlib.h>\n"
"#include <time.h>\n"
"#include <der.h>\n"
@@ -222,7 +223,7 @@ encode_type (char *name, Type *t)
break;
for (m = t->members->prev; m && tag != m->val; m = m->prev) {
char *s = malloc(1 + strlen(name) + 1 + strlen(m->gen_name) + 3);
char *s = malloc(2 + strlen(name) + 1 + strlen(m->gen_name) + 3);
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
if (m->optional)
@@ -424,7 +425,7 @@ decode_type (char *name, Type *t)
"len = reallen;\n");
for (m = t->members; m && tag != m->val; m = m->next) {
char *s = malloc(1 + strlen(name) + 1 + strlen(m->gen_name) + 3);
char *s = malloc(2 + strlen(name) + 1 + strlen(m->gen_name) + 3);
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
fprintf (codefile, "{\n"

View File

@@ -10,10 +10,15 @@
#include "symbol.h"
#include "parse.h"
char *strdup(char *);
void error_message(char *, ...);
static unsigned lineno = 1;
static char filename[256];
%}
%%
INTEGER { return INTEGER; }
SEQUENCE { return SEQUENCE; }
@@ -28,21 +33,23 @@ OPTIONAL { return OPTIONAL; }
BEGIN { return TBEGIN; }
END { return END; }
DEFINITIONS { return DEFINITIONS; }
[][|{},()] { return *yytext; }
,|\{|\}|\(|\)|\[|\]|\| { return *yytext; }
::= { return EEQUAL; }
--[^\n]*\n { ; }
-?[0-9]+ { yylval.constant = atoi(yytext); return CONSTANT; }
[A-Za-z][-A-Za-z0-9_]* { yylval.name = strdup (yytext); return IDENTIFIER; }
[ \t] ;
\n { lineno++; }
. { fprintf(stderr, "Ignoring char(%c)\n", *yytext); }
. { error_message("Ignoring char(%c)\n", *yytext); }
%%
#ifndef yywrap /* XXX */
int
yywrap ()
{
return 1;
}
#endif
void
error_message (char *format, ...)

View File

@@ -12,6 +12,8 @@
static Type *new_type (Typetype t);
void yyerror (char *);
char *strdup(char *);
%}
%union {
@@ -167,6 +169,7 @@ new_type (Typetype tt)
t->members = NULL;
t->subtype = NULL;
t->symbol = NULL;
return t;
}
static void