Thread: [Redbutton-devel] SF.net SVN: redbutton: [328] redbutton-author/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2007-08-22 13:19:39
|
Revision: 328
http://redbutton.svn.sourceforge.net/redbutton/?rev=328&view=rev
Author: skilvington
Date: 2007-08-22 06:19:38 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
import the yacc grammar compiler
Added Paths:
-----------
redbutton-author/trunk/Makefile
redbutton-author/trunk/ccc.l
redbutton-author/trunk/ccc.y
Added: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile (rev 0)
+++ redbutton-author/trunk/Makefile 2007-08-22 13:19:38 UTC (rev 328)
@@ -0,0 +1,35 @@
+CC=gcc
+CFLAGS=-Wall -O2
+
+LEX=lex
+YACC=yacc
+
+DESTDIR=/usr/local
+
+OBJS= mhegc.o \
+ token.o \
+ utils.o
+
+TARDIR=`basename ${PWD}`
+
+ccc: ccc.y ccc.l
+ ${LEX} -i ccc.l
+ ${YACC} -d ccc.y
+ ${CC} ${CFLAGS} -o ccc lex.yy.c y.tab.c
+
+mhegc: ${OBJS}
+ ${CC} ${CFLAGS} -o mhegc ${OBJS} ${LIBS}
+
+.c.o:
+ ${CC} ${CFLAGS} -c $<
+
+install: mhegc
+ install -m 755 mhegc ${DESTDIR}/bin
+
+clean:
+ rm -f mhegc *.o core
+
+tar:
+ make clean
+ (cd ..; tar zcvf ${TARDIR}.tar.gz --exclude .svn ${TARDIR})
+
Added: redbutton-author/trunk/ccc.l
===================================================================
--- redbutton-author/trunk/ccc.l (rev 0)
+++ redbutton-author/trunk/ccc.l 2007-08-22 13:19:38 UTC (rev 328)
@@ -0,0 +1,18 @@
+%{
+#include <string.h>
+#include "y.tab.h"
+%}
+%%
+\/\/[^\n\r\f]* return COMMENT;
+\"[^"]*\" yylval = strdup(yytext); return LITERAL;
+[a-z][a-z0-9]* yylval = strdup(yytext); return IDENTIFIER;
+"::=" return DEFINEDAS;
+"|" return ALTERNATIVE;
+"[" return LBRACKET;
+"]" return RBRACKET;
+"+" return ONEORMORE;
+"." return ENDCLAUSE;
+[\n\r\f] /* ignore end of line */
+[ \t]+ /* ignore whitespace */
+. return INVALID;
+%%
Added: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y (rev 0)
+++ redbutton-author/trunk/ccc.y 2007-08-22 13:19:38 UTC (rev 328)
@@ -0,0 +1,94 @@
+%{
+#include <stdio.h>
+#include <string.h>
+
+#define YYSTYPE char *
+
+void
+yyerror(const char *str)
+{
+ fprintf(stderr, "yyerror: %s\n", str);
+}
+
+int
+yywrap(void)
+{
+ return 1;
+}
+
+int
+main(void)
+{
+ yyparse();
+
+ return 0;
+}
+
+%}
+
+%token COMMENT
+%token LITERAL
+%token IDENTIFIER
+%token DEFINEDAS
+%token ALTERNATIVE
+%token LBRACKET
+%token RBRACKET
+%token ONEORMORE
+%token ENDCLAUSE
+%token INVALID
+
+%%
+clauses:
+ |
+ clauses clause
+ ;
+
+clause:
+ COMMENT
+ |
+ IDENTIFIER DEFINEDAS definition ENDCLAUSE
+ {
+ printf("DEFINE:'%s'\n", $1);
+ }
+ ;
+
+definition:
+ and_items
+ |
+ or_items
+ ;
+
+and_items:
+ item
+ |
+ and_items item
+ ;
+
+or_items:
+ item ALTERNATIVE item
+ |
+ or_items ALTERNATIVE item
+ ;
+
+item:
+ LITERAL
+ {
+ printf("LITERAL:'%s'\n", $1);
+ }
+ |
+ IDENTIFIER
+ {
+ printf("IDENTIFIER:'%s'\n", $1);
+ }
+ |
+ LBRACKET IDENTIFIER RBRACKET
+ {
+ printf("[IDENTIFIER]:'%s'\n", $2);
+ }
+ |
+ IDENTIFIER ONEORMORE
+ {
+ printf("IDENTIFIER+:'%s'\n", $1);
+ }
+ ;
+%%
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-22 15:32:49
|
Revision: 331
http://redbutton.svn.sourceforge.net/redbutton/?rev=331&view=rev
Author: skilvington
Date: 2007-08-22 08:32:46 -0700 (Wed, 22 Aug 2007)
Log Message:
-----------
keep track of the current input line number
Modified Paths:
--------------
redbutton-author/trunk/ccc.l
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/ccc.l
===================================================================
--- redbutton-author/trunk/ccc.l 2007-08-22 13:32:05 UTC (rev 330)
+++ redbutton-author/trunk/ccc.l 2007-08-22 15:32:46 UTC (rev 331)
@@ -1,6 +1,7 @@
%{
#include <string.h>
#include "y.tab.h"
+extern int yylineno;
%}
%%
\/\/[^\n\r\f]* return COMMENT;
@@ -12,7 +13,7 @@
"]" return RBRACKET;
"+" return ONEORMORE;
"." return ENDCLAUSE;
-[\n\r\f] /* ignore end of line */
+[\n\r\f] yylineno ++;
[ \t]+ /* ignore whitespace */
. return INVALID;
%%
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-22 13:32:05 UTC (rev 330)
+++ redbutton-author/trunk/ccc.y 2007-08-22 15:32:46 UTC (rev 331)
@@ -4,10 +4,13 @@
#define YYSTYPE char *
+/* input line we are currently parsing */
+int yylineno = 1;
+
void
yyerror(const char *str)
{
- fprintf(stderr, "yyerror: %s\n", str);
+ fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
}
int
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-23 08:43:46
|
Revision: 334
http://redbutton.svn.sourceforge.net/redbutton/?rev=334&view=rev
Author: skilvington
Date: 2007-08-23 01:43:41 -0700 (Thu, 23 Aug 2007)
Log Message:
-----------
make sure it works with flex/bison and lex/yacc
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/ccc.l
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-08-22 16:30:14 UTC (rev 333)
+++ redbutton-author/trunk/Makefile 2007-08-23 08:43:41 UTC (rev 334)
@@ -1,8 +1,10 @@
CC=gcc
CFLAGS=-Wall -O2
-LEX=lex
-YACC=yacc
+LEX=flex
+YACC=bison
+#LEX=lex
+#YACC=yacc
DESTDIR=/usr/local
@@ -13,9 +15,9 @@
TARDIR=`basename ${PWD}`
ccc: ccc.y ccc.l
- ${LEX} -i ccc.l
- ${YACC} -d ccc.y
- ${CC} ${CFLAGS} -o ccc lex.yy.c y.tab.c
+ ${LEX} -i -t ccc.l > lex.ccc.c
+ ${YACC} -b ccc -d ccc.y
+ ${CC} ${CFLAGS} -o ccc lex.ccc.c ccc.tab.c
mhegc: ${OBJS}
${CC} ${CFLAGS} -o mhegc ${OBJS} ${LIBS}
@@ -27,7 +29,7 @@
install -m 755 mhegc ${DESTDIR}/bin
clean:
- rm -f mhegc ccc *.o core
+ rm -f mhegc ccc lex.ccc.c ccc.tab.[ch] *.o core
tar:
make clean
Modified: redbutton-author/trunk/ccc.l
===================================================================
--- redbutton-author/trunk/ccc.l 2007-08-22 16:30:14 UTC (rev 333)
+++ redbutton-author/trunk/ccc.l 2007-08-23 08:43:41 UTC (rev 334)
@@ -1,6 +1,6 @@
%{
#include <string.h>
-#include "y.tab.h"
+#include "ccc.tab.h"
extern int yylineno;
%}
%%
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-24 10:15:11
|
Revision: 346
http://redbutton.svn.sourceforge.net/redbutton/?rev=346&view=rev
Author: skilvington
Date: 2007-08-24 03:15:03 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
the parser works, but only if SET items appear in the order they are defined in the grammar
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/ccc.y
redbutton-author/trunk/grammar
Added Paths:
-----------
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
redbutton-author/trunk/parser.y.footer
redbutton-author/trunk/parser.y.header
redbutton-author/trunk/utils.c
redbutton-author/trunk/utils.h
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-08-24 09:36:13 UTC (rev 345)
+++ redbutton-author/trunk/Makefile 2007-08-24 10:15:03 UTC (rev 346)
@@ -9,19 +9,39 @@
DESTDIR=/usr/local
OBJS= mhegc.o \
- token.o \
+ parser.o \
utils.o
TARDIR=`basename ${PWD}`
+mhegc: ${OBJS}
+ ${CC} ${CFLAGS} -o mhegc ${OBJS} ${LIBS}
+
+mhegc.o: mhegc.c parser.tab.h
+ ${CC} ${CFLAGS} -c mhegc.c
+
+parser.tab.h: parser.o
+
ccc: ccc.y ccc.l
${LEX} -i -t ccc.l > lex.ccc.c
${YACC} -b ccc -d ccc.y
${CC} ${CFLAGS} -o ccc lex.ccc.c ccc.tab.c
-mhegc: ${OBJS}
- ${CC} ${CFLAGS} -o mhegc ${OBJS} ${LIBS}
+parser.l: parser.l.header grammar ccc
+ cat parser.l.header > parser.l
+ cat grammar | ./ccc -l >> parser.l
+ cat parser.l.footer >> parser.l
+parser.y: parser.y.header parser.y.footer grammar ccc
+ cat parser.y.header > parser.y
+ cat grammar | ./ccc >> parser.y
+ cat parser.y.footer >> parser.y
+
+parser.o: parser.l parser.y
+ ${LEX} -i -t parser.l > lex.parser.c
+ ${YACC} -b parser -d parser.y
+ ${CC} ${CFLAGS} -c -o parser.o lex.parser.c parser.tab.c
+
.c.o:
${CC} ${CFLAGS} -c $<
@@ -29,7 +49,7 @@
install -m 755 mhegc ${DESTDIR}/bin
clean:
- rm -f mhegc ccc lex.ccc.c ccc.tab.[ch] *.o core
+ rm -f mhegc ccc lex.*.c *.tab.[ch] parser.l parser.y *.o core
tar:
make clean
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-24 09:36:13 UTC (rev 345)
+++ redbutton-author/trunk/ccc.y 2007-08-24 10:15:03 UTC (rev 346)
@@ -51,6 +51,8 @@
struct buf oneormores; /* grammar section for Identifier+ rules */
} state;
+int yyparse(void);
+
void usage(char *);
void fatal(char *);
Modified: redbutton-author/trunk/grammar
===================================================================
--- redbutton-author/trunk/grammar 2007-08-24 09:36:13 UTC (rev 345)
+++ redbutton-author/trunk/grammar 2007-08-24 10:15:03 UTC (rev 346)
@@ -1,6 +1,8 @@
// MHEG5 Textual Format
// includes UK MHEG Profile additions
+InterchangedObject ::= ApplicationClass | SceneClass .
+
// B.4.1 Root Class
Root ::= ObjectIdentifier .
Added: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c (rev 0)
+++ redbutton-author/trunk/mhegc.c 2007-08-24 10:15:03 UTC (rev 346)
@@ -0,0 +1,39 @@
+/*
+ * mhegc.c
+ */
+
+/*
+ * Copyright (C) 2007, Simon Kilvington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "parser.tab.h"
+
+int yyparse(void);
+extern int yydebug;
+
+int
+main(int argc, char *argv[])
+{
+ yydebug=1;
+ yyparse();
+
+ return EXIT_SUCCESS;
+}
+
Added: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer (rev 0)
+++ redbutton-author/trunk/parser.l.footer 2007-08-24 10:15:03 UTC (rev 346)
@@ -0,0 +1,2 @@
+. return INVALID;
+%%
Added: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header (rev 0)
+++ redbutton-author/trunk/parser.l.header 2007-08-24 10:15:03 UTC (rev 346)
@@ -0,0 +1,15 @@
+%{
+#include <string.h>
+#define YYSTYPE char *
+#include "parser.tab.h"
+extern int yylineno;
+%}
+%%
+([-0-9][0-9]*)|(0x[0-9a-f]+) yylval = strdup(yytext); return INTEGER;
+true|false yylval = strdup(yytext); return BOOLEAN;
+\"((\\\")|[^"])*\" yylval = strdup(yytext); return STRING;
+'[^']*' yylval = strdup(yytext); return QPRINTABLE;
+`[^`]*` yylval = strdup(yytext); return BASE64;
+null return Null;
+[\n\r\f] yylineno ++;
+[ \t]+ /* ignore whitespace */
Added: redbutton-author/trunk/parser.y.footer
===================================================================
--- redbutton-author/trunk/parser.y.footer (rev 0)
+++ redbutton-author/trunk/parser.y.footer 2007-08-24 10:15:03 UTC (rev 346)
@@ -0,0 +1 @@
+
Added: redbutton-author/trunk/parser.y.header
===================================================================
--- redbutton-author/trunk/parser.y.header (rev 0)
+++ redbutton-author/trunk/parser.y.header 2007-08-24 10:15:03 UTC (rev 346)
@@ -0,0 +1,31 @@
+%{
+#include <stdio.h>
+#include <string.h>
+
+#define YYSTYPE char *
+#define YYERROR_VERBOSE
+#define YYDEBUG 1
+
+int yylineno = 1;
+
+void
+yyerror(const char *str)
+{
+ fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+}
+
+int
+yywrap(void)
+{
+ return 1;
+}
+
+%}
+
+%token INTEGER
+%token BOOLEAN
+%token STRING
+%token QPRINTABLE
+%token BASE64
+%token Null
+%token INVALID
Added: redbutton-author/trunk/utils.c
===================================================================
--- redbutton-author/trunk/utils.c (rev 0)
+++ redbutton-author/trunk/utils.c 2007-08-24 10:15:03 UTC (rev 346)
@@ -0,0 +1,147 @@
+/*
+ * utils.c
+ */
+
+/*
+ * Copyright (C) 2007, Simon Kilvington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <ctype.h>
+
+#include "utils.h"
+
+/*
+ * I don't want to double the size of my code just to deal with malloc failures
+ * if you've run out of memory you're fscked anyway, me trying to recover is not gonna help...
+ */
+
+void *
+safe_malloc(size_t nbytes)
+{
+ void *buf;
+
+ if((buf = malloc(nbytes)) == NULL)
+ fatal("Out of memory");
+
+ return buf;
+}
+
+/*
+ * safe_realloc(NULL, n) == safe_malloc(n)
+ */
+
+void *
+safe_realloc(void *oldbuf, size_t nbytes)
+{
+ void *newbuf;
+
+ if(oldbuf == NULL)
+ return safe_malloc(nbytes);
+
+ if((newbuf = realloc(oldbuf, nbytes)) == NULL)
+ fatal("Out of memory");
+
+ return newbuf;
+}
+
+/*
+ * safe_free(NULL) is okay
+ */
+
+void
+safe_free(void *buf)
+{
+ if(buf != NULL)
+ free(buf);
+
+ return;
+}
+
+void
+error(char *message, ...)
+{
+ va_list ap;
+
+ va_start(ap, message);
+ vfprintf(stderr, message, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+
+ return;
+}
+
+void
+fatal(char *message, ...)
+{
+ va_list ap;
+
+ va_start(ap, message);
+ vfprintf(stderr, message, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+
+ exit(EXIT_FAILURE);
+}
+
+/* number of bytes per line */
+#define HEXDUMP_WIDTH 16
+
+void
+hexdump(unsigned char *data, size_t nbytes)
+{
+ size_t nout;
+ int i;
+
+ nout = 0;
+ while(nout < nbytes)
+ {
+ /* byte offset at start of line */
+ if((nout % HEXDUMP_WIDTH) == 0)
+ printf("0x%.8x ", nout);
+ /* the byte value in hex */
+ printf("%.2x ", data[nout]);
+ /* the ascii equivalent at the end of the line */
+ if((nout % HEXDUMP_WIDTH) == (HEXDUMP_WIDTH - 1))
+ {
+ printf(" ");
+ for(i=HEXDUMP_WIDTH-1; i>=0; i--)
+ printf("%c", isprint(data[nout - i]) ? data[nout - i] : '.');
+ printf("\n");
+ }
+ nout ++;
+ }
+
+ /* the ascii equivalent if we haven't just done it */
+ if((nout % HEXDUMP_WIDTH) != 0)
+ {
+ /* pad to the start of the ascii equivalent */
+ for(i=(nout % HEXDUMP_WIDTH); i<HEXDUMP_WIDTH; i++)
+ printf(" ");
+ printf(" ");
+ /* print the ascii equivalent */
+ nout --;
+ for(i=(nout % HEXDUMP_WIDTH); i>=0; i--)
+ printf("%c", isprint(data[nout - i]) ? data[nout - i] : '.');
+ printf("\n");
+ }
+
+ return;
+}
+
Added: redbutton-author/trunk/utils.h
===================================================================
--- redbutton-author/trunk/utils.h (rev 0)
+++ redbutton-author/trunk/utils.h 2007-08-24 10:15:03 UTC (rev 346)
@@ -0,0 +1,39 @@
+/*
+ * utils.h
+ */
+
+/*
+ * Copyright (C) 2007, Simon Kilvington
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __UTILS_H__
+#define __UTILS_H__
+
+#include <stdlib.h>
+#include <stdarg.h>
+
+void *safe_malloc(size_t);
+void *safe_realloc(void *, size_t);
+void safe_free(void *);
+
+void hexdump(unsigned char *, size_t);
+
+void error(char *, ...);
+void fatal(char *, ...);
+
+#endif /* __UTILS_H__ */
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-24 13:36:11
|
Revision: 347
http://redbutton.svn.sourceforge.net/redbutton/?rev=347&view=rev
Author: skilvington
Date: 2007-08-24 06:36:03 -0700 (Fri, 24 Aug 2007)
Log Message:
-----------
fix a compiler warning
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
redbutton-author/trunk/parser.y.header
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-24 10:15:03 UTC (rev 346)
+++ redbutton-author/trunk/ccc.y 2007-08-24 13:36:03 UTC (rev 347)
@@ -52,6 +52,7 @@
} state;
int yyparse(void);
+int yylex(void);
void usage(char *);
void fatal(char *);
Modified: redbutton-author/trunk/parser.y.header
===================================================================
--- redbutton-author/trunk/parser.y.header 2007-08-24 10:15:03 UTC (rev 346)
+++ redbutton-author/trunk/parser.y.header 2007-08-24 13:36:03 UTC (rev 347)
@@ -6,6 +6,8 @@
#define YYERROR_VERBOSE
#define YYDEBUG 1
+int yylex(void);
+
int yylineno = 1;
void
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-28 16:16:02
|
Revision: 354
http://redbutton.svn.sourceforge.net/redbutton/?rev=354&view=rev
Author: skilvington
Date: 2007-08-28 09:15:53 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
try generating C code for the compiler rather than a yacc grammar
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/ccc.y
Added Paths:
-----------
redbutton-author/trunk/asn1type.c
redbutton-author/trunk/asn1type.h
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-08-26 10:40:33 UTC (rev 353)
+++ redbutton-author/trunk/Makefile 2007-08-28 16:15:53 UTC (rev 354)
@@ -23,10 +23,10 @@
parser.tab.h: parser.tab.c
-ccc: ccc.y ccc.l
+ccc: ccc.y ccc.l asn1type.o
${LEX} -i -t ccc.l > lex.ccc.c
${YACC} -b ccc -d ccc.y
- ${CC} ${CFLAGS} -o ccc lex.ccc.c ccc.tab.c
+ ${CC} ${CFLAGS} -o ccc lex.ccc.c ccc.tab.c asn1type.o
parser.l: parser.l.header parser.l.footer grammar ccc
cat parser.l.header > parser.l
Added: redbutton-author/trunk/asn1type.c
===================================================================
--- redbutton-author/trunk/asn1type.c (rev 0)
+++ redbutton-author/trunk/asn1type.c 2007-08-28 16:15:53 UTC (rev 354)
@@ -0,0 +1,220 @@
+/*
+ * asn1type.c
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "asn1type.h"
+
+#define MATCH(NAME, TYPE) if(strcmp(name, #NAME) == 0) return ASN1TYPE_ ## TYPE;
+
+enum asn1type
+asn1type(char *name)
+{
+ MATCH(InterchangedObject, CHOICE)
+ MATCH(Group, SET) // MATCH(GroupClass, SET)
+ MATCH(StandardIdentifier, SEQUENCE)
+ MATCH(GroupItem, CHOICE)
+ MATCH(ApplicationClass, SET)
+ MATCH(DefaultAttribute, CHOICE)
+ MATCH(FontBody, CHOICE)
+ MATCH(SceneClass, SET)
+ MATCH(SceneCoordinateSystem, SEQUENCE)
+ MATCH(AspectRatio, SEQUENCE)
+ MATCH(NextScene, SEQUENCE)
+ MATCH(Ingredient, SET) // MATCH(IngredientClass, SET)
+ MATCH(ContentBody, CHOICE)
+ MATCH(ReferencedContent, SEQUENCE)
+ MATCH(LinkClass, SET)
+ MATCH(LinkCondition, SEQUENCE)
+ MATCH(EventTypeEnum, ENUMERATED) // MATCH(EventType, ENUMERATED)
+ MATCH(EventDataBody, CHOICE) // MATCH(EventData, CHOICE)
+ MATCH(Program, SET) // MATCH(ProgramClass, SET)
+ MATCH(ResidentProgramClass, SET)
+ MATCH(RemoteProgramClass, SET)
+ MATCH(InterchangedProgramClass, SET)
+ MATCH(PaletteClass, SET)
+ MATCH(FontClass, SET)
+ MATCH(CursorShapeClass, SET)
+ MATCH(Variable, SET) // MATCH(VariableClass, SET)
+ MATCH(OriginalValueBody, CHOICE) // MATCH(OriginalValue, CHOICE)
+ MATCH(BooleanVariableClass, SET)
+ MATCH(IntegerVariableClass, SET)
+ MATCH(OctetStringVariableClass, SET)
+ MATCH(ObjectRefVariableClass, SET)
+ MATCH(ContentRefVariableClass, SET)
+ MATCH(PresentableClass, SET)
+ MATCH(TokenManagerClass, SET)
+ MATCH(Movement, SEQUENCE)
+ MATCH(TokenGroupBody, SET) // MATCH(TokenGroupClass, SET)
+ MATCH(TokenGroupItem, SEQUENCE)
+ MATCH(ActionSlot, CHOICE)
+ MATCH(ListGroupClass, SET)
+ MATCH(Visible, SET) // MATCH(VisibleClass, SET)
+ MATCH(BoxSize, SEQUENCE) // MATCH(OriginalBoxSize, SEQUENCE)
+ MATCH(BitmapClass, SET)
+ MATCH(LineArtBody, SET) // MATCH(LineArtClass, SET)
+ MATCH(RectangleClass, SET)
+ MATCH(DynamicLineArtClass, SET)
+ MATCH(TextBody, SET) // MATCH(TextClass, SET)
+ MATCH(JustificationEnum, ENUMERATED) // MATCH(Justification, ENUMERATED)
+ MATCH(LineOrientationEnum, ENUMERATED) // MATCH(LineOrientation, ENUMERATED)
+ MATCH(StartCornerEnum, ENUMERATED) // MATCH(StartCorner, ENUMERATED)
+ MATCH(StreamClass, SET)
+ MATCH(StreamComponent, CHOICE)
+ MATCH(StorageEnum, ENUMERATED) // MATCH(Storage, ENUMERATED)
+ MATCH(AudioClass, SET)
+ MATCH(VideoClass, SET)
+ MATCH(TerminationEnum, ENUMERATED) // MATCH(Termination, ENUMERATED)
+ MATCH(RTGraphicsClass, SET)
+ MATCH(Interactible, SET) // MATCH(InteractibleClass, SET)
+ MATCH(SliderClass, SET)
+ MATCH(OrientationEnum, ENUMERATED) // MATCH(Orientation, ENUMERATED)
+ MATCH(SliderStyleEnum, ENUMERATED) // MATCH(SliderStyle, ENUMERATED)
+ MATCH(EntryFieldClass, SET)
+ MATCH(InputTypeEnum, ENUMERATED) // MATCH(InputType, ENUMERATED)
+ MATCH(HyperTextClass, SET)
+ MATCH(Button, SET) // MATCH(ButtonClass, SET)
+ MATCH(HotspotClass, SET)
+ MATCH(PushButtonBody, SET) // MATCH(PushButtonClass, SET)
+ MATCH(SwitchButtonClass, SET)
+ MATCH(ButtonStyleEnum, ENUMERATED) // MATCH(ButtonStyle, ENUMERATED)
+ MATCH(ActionClass, SEQUENCE)
+ MATCH(ElementaryAction, CHOICE)
+ MATCH(Add, SEQUENCE)
+ MATCH(AddItem, SEQUENCE)
+ MATCH(Append, SEQUENCE)
+ MATCH(Call, SEQUENCE)
+ MATCH(CallActionSlot, SEQUENCE)
+ MATCH(Clone, SEQUENCE)
+ MATCH(CloseConnection, SEQUENCE)
+ MATCH(DelItem, SEQUENCE)
+ MATCH(DeselectItem, SEQUENCE)
+ MATCH(Divide, SEQUENCE)
+ MATCH(DrawArc, SEQUENCE)
+ MATCH(DrawLine, SEQUENCE)
+ MATCH(DrawOval, SEQUENCE)
+ MATCH(DrawPolygon, SEQUENCE)
+ MATCH(DrawPolyline, SEQUENCE)
+ MATCH(DrawRectangle, SEQUENCE)
+ MATCH(DrawSector, SEQUENCE)
+ MATCH(Fork, SEQUENCE)
+ MATCH(GetAvailabilityStatus, SEQUENCE)
+ MATCH(GetBoxSize, SEQUENCE)
+ MATCH(GetCellItem, SEQUENCE)
+ MATCH(GetCursorPosition, SEQUENCE)
+ MATCH(GetEngineSupport, SEQUENCE)
+ MATCH(GetEntryPoint, SEQUENCE)
+ MATCH(GetFillColour, SEQUENCE)
+ MATCH(GetFirstItem, SEQUENCE)
+ MATCH(GetHighlightStatus, SEQUENCE)
+ MATCH(GetInteractionStatus, SEQUENCE)
+ MATCH(GetItemStatus, SEQUENCE)
+ MATCH(GetLabel, SEQUENCE)
+ MATCH(GetLastAnchorFired, SEQUENCE)
+ MATCH(GetLineColour, SEQUENCE)
+ MATCH(GetLineStyle, SEQUENCE)
+ MATCH(GetLineWidth, SEQUENCE)
+ MATCH(GetListItem, SEQUENCE)
+ MATCH(GetListSize, SEQUENCE)
+ MATCH(GetOverwriteMode, SEQUENCE)
+ MATCH(GetPortion, SEQUENCE)
+ MATCH(GetPosition, SEQUENCE)
+ MATCH(GetRunningStatus, SEQUENCE)
+ MATCH(GetSelectionStatus, SEQUENCE)
+ MATCH(GetSliderValue, SEQUENCE)
+ MATCH(GetTextContent, SEQUENCE)
+ MATCH(GetTextData, SEQUENCE)
+ MATCH(GetTokenPosition, SEQUENCE)
+ MATCH(GetVolume, SEQUENCE)
+ MATCH(Modulo, SEQUENCE)
+ MATCH(Move, SEQUENCE)
+ MATCH(MoveTo, SEQUENCE)
+ MATCH(Multiply, SEQUENCE)
+ MATCH(OpenConnection, SEQUENCE)
+ MATCH(PutBefore, SEQUENCE)
+ MATCH(PutBehind, SEQUENCE)
+ MATCH(ReadPersistent, SEQUENCE)
+ MATCH(ScaleBitmap, SEQUENCE)
+ MATCH(ScaleVideo, SEQUENCE)
+ MATCH(ScrollItems, SEQUENCE)
+ MATCH(SelectItem, SEQUENCE)
+ MATCH(SendEvent, SEQUENCE)
+ MATCH(SetBoxSize, SEQUENCE)
+ MATCH(SetCachePriority, SEQUENCE)
+ MATCH(SetCounterEndPosition, SEQUENCE)
+ MATCH(SetCounterPosition, SEQUENCE)
+ MATCH(SetCounterTrigger, SEQUENCE)
+ MATCH(SetCursorPosition, SEQUENCE)
+ MATCH(SetCursorShape, SEQUENCE)
+ MATCH(SetData, SEQUENCE)
+ MATCH(SetEntryPoint, SEQUENCE)
+ MATCH(SetFillColour, SEQUENCE)
+ MATCH(SetFirstItem, SEQUENCE)
+ MATCH(SetFontRef, SEQUENCE)
+ MATCH(SetHighlightStatus, SEQUENCE)
+ MATCH(SetInteractionStatus, SEQUENCE)
+ MATCH(SetLabel, SEQUENCE)
+ MATCH(SetLineColour, SEQUENCE)
+ MATCH(SetLineStyle, SEQUENCE)
+ MATCH(SetLineWidth, SEQUENCE)
+ MATCH(SetOverwriteMode, SEQUENCE)
+ MATCH(SetPaletteRef, SEQUENCE)
+ MATCH(SetPortion, SEQUENCE)
+ MATCH(SetPosition, SEQUENCE)
+ MATCH(SetSliderValue, SEQUENCE)
+ MATCH(SetSpeed, SEQUENCE)
+ MATCH(SetTimer, SEQUENCE)
+ MATCH(NewTimer, SEQUENCE)
+ MATCH(SetTransparency, SEQUENCE)
+ MATCH(SetVariable, SEQUENCE)
+ MATCH(SetVolume, SEQUENCE)
+ MATCH(Step, SEQUENCE)
+ MATCH(StorePersistent, SEQUENCE)
+ MATCH(Subtract, SEQUENCE)
+ MATCH(TestVariable, SEQUENCE)
+ MATCH(ToggleItem, SEQUENCE)
+ MATCH(TransitionTo, SEQUENCE)
+ MATCH(ConnectionTagOrNull, CHOICE)
+ MATCH(ComparisonValue, CHOICE)
+ MATCH(EmulatedEventData, CHOICE)
+ MATCH(NewColour, CHOICE)
+ MATCH(NewContent, CHOICE)
+ MATCH(NewFont, CHOICE)
+ MATCH(NewReferencedContent, SEQUENCE)
+ MATCH(NewContentSize, CHOICE)
+ MATCH(NewVariableValue, CHOICE)
+ MATCH(Parameter, CHOICE)
+ MATCH(Point, SEQUENCE)
+ MATCH(Rational, SEQUENCE)
+ MATCH(ObjectReference, CHOICE)
+ MATCH(ExternalReference, SEQUENCE)
+ MATCH(IndirectReference, CHOICE)
+ MATCH(GenericObjectReference, CHOICE)
+ MATCH(GenericContentReference, CHOICE)
+ MATCH(GenericInteger, CHOICE)
+ MATCH(GenericBoolean, CHOICE)
+ MATCH(GenericOctetString, CHOICE)
+ MATCH(Colour, CHOICE)
+ MATCH(XYPosition, SEQUENCE)
+ MATCH(SetInputReg, SEQUENCE) // MATCH(SetInputRegister, SEQUENCE)
+ MATCH(SetCellPosition, SEQUENCE)
+ MATCH(SetBitmapDecodeOffset, SEQUENCE)
+ MATCH(GetBitmapDecodeOffset, SEQUENCE)
+ MATCH(SetBackgroundColour, SEQUENCE)
+ MATCH(SetTextColour, SEQUENCE)
+ MATCH(SetFontAttributes, SEQUENCE)
+ MATCH(SetVideoDecodeOffset, SEQUENCE)
+ MATCH(GetVideoDecodeOffset, SEQUENCE)
+ MATCH(SetSliderParameters, SEQUENCE)
+ MATCH(GetFocusPosition, SEQUENCE)
+ MATCH(SetFocusPosition, SEQUENCE)
+ MATCH(OctetString, CHOICE);
+
+ fprintf(stderr, "Unknown ASN1 type: %s\n", name);
+ exit(EXIT_FAILURE);
+
+ return ASN1TYPE_UNKNOWN;
+}
Added: redbutton-author/trunk/asn1type.h
===================================================================
--- redbutton-author/trunk/asn1type.h (rev 0)
+++ redbutton-author/trunk/asn1type.h 2007-08-28 16:15:53 UTC (rev 354)
@@ -0,0 +1,19 @@
+/*
+ * asn1type.h
+ */
+
+#ifndef __ASN1TYPE_H__
+#define __ASN1TYPE_H__
+
+enum asn1type
+{
+ ASN1TYPE_UNKNOWN,
+ ASN1TYPE_CHOICE,
+ ASN1TYPE_ENUMERATED,
+ ASN1TYPE_SET,
+ ASN1TYPE_SEQUENCE
+};
+
+enum asn1type asn1type(char *);
+
+#endif /* __ASN1TYPE_H__ */
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-26 10:40:33 UTC (rev 353)
+++ redbutton-author/trunk/ccc.y 2007-08-28 16:15:53 UTC (rev 354)
@@ -8,6 +8,8 @@
#include <stdarg.h>
#include <ctype.h>
+#include "asn1type.h"
+
#define YYSTYPE char *
/* build up a list of items that define the current identifier */
@@ -51,6 +53,7 @@
struct str_list *tokens; /* "%token" section of the yacc output file */
struct buf grammar; /* grammar section of the yacc output file */
struct str_list *oneormores; /* grammar section for Identifier+ rules */
+ struct buf parser; /* C code for the parser */
} state;
int yyparse(void);
@@ -173,11 +176,11 @@
main(int argc, char *argv[])
{
char *prog_name = argv[0];
- /* by default output the grammar */
bool show_lexer = false;
+ bool show_parser = false;
int arg;
- while((arg = getopt(argc, argv, "l")) != EOF)
+ while((arg = getopt(argc, argv, "lp")) != EOF)
{
switch(arg)
{
@@ -185,6 +188,10 @@
show_lexer = true;
break;
+ case 'p':
+ show_parser = true;
+ break;
+
default:
usage(prog_name);
break;
@@ -199,6 +206,7 @@
state.tokens = NULL;
buf_init(&state.grammar);
state.oneormores = NULL;
+ buf_init(&state.parser);
yyparse();
@@ -207,6 +215,11 @@
/* output lexer */
printf("%s", state.lexer.str);
}
+ else if(show_parser)
+ {
+ /* output C code */
+ printf("%s", state.parser.str);
+ }
else
{
/* output grammar */
@@ -223,7 +236,7 @@
void
usage(char *prog_name)
{
- fprintf(stderr, "Syntax: %s [-l]\n", prog_name);
+ fprintf(stderr, "Syntax: %s [-l] [-p]\n", prog_name);
exit(EXIT_FAILURE);
}
@@ -271,6 +284,7 @@
{
struct item *item;
struct item *next;
+ unsigned int nitems;
buf_append(&state.grammar, "%s:\n\t", name);
@@ -280,6 +294,155 @@
buf_append(&state.grammar, ";\n\n");
+ /* C code for the parser */
+ buf_append(&state.parser, "void parse_%s(struct state *state)\n{\n", name);
+ /* count how many items make it up */
+ nitems = 0;
+ /* skip literals at the start */
+ item = state.items;
+ while(item && item->type == IT_LITERAL)
+ item = item->next;
+ /* don't count literals at the end */
+ while(item && item->type != IT_LITERAL)
+ {
+ nitems ++;
+ item = item->next;
+ }
+ if(nitems == 1)
+ {
+ item = state.items;
+ while(item && item->type == IT_LITERAL)
+ {
+buf_append(&state.parser, "// TODO: eat %s\n\n", item->name);
+ item = item->next;
+ }
+ buf_append(&state.parser, "\ttoken_t next = next_token();\n\n");
+ if(item->type == IT_IDENTIFIER)
+ {
+ buf_append(&state.parser, "\t/* %s */\n", item->name);
+ buf_append(&state.parser, "\tif(is_%s(next))\n", item->name);
+ buf_append(&state.parser, "\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parser, "\telse\n");
+ buf_append(&state.parser, "\t\tparse_error(\"Expecting %s\");\n", item->name);
+ }
+ else if(item->type == IT_OPTIONAL)
+ {
+ buf_append(&state.parser, "\t/* [%s] */\n", item->name);
+ buf_append(&state.parser, "\tif(is_%s(next))\n", item->name);
+ buf_append(&state.parser, "\t\tparse_%s(state);\n", item->name);
+ }
+ else if(item->type == IT_ONEORMORE)
+ {
+ buf_append(&state.parser, "\t/* %s+ */\n", item->name);
+ buf_append(&state.parser, "\twhile(is_%s(next))\n", item->name);
+ buf_append(&state.parser, "\t{\n");
+ buf_append(&state.parser, "\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parser, "\t\tnext = next_token();\n");
+ buf_append(&state.parser, "\t}\n");
+ buf_append(&state.parser, "\n\tunget_token(next);\n");
+ }
+ else
+ {
+ fatal("nitems==1 but not Identifier/[Identifier]/Identifier+");
+ }
+ item = item->next;
+ while(item)
+ {
+buf_append(&state.parser, "\n// TODO: eat %s\n", item->name);
+ item = item->next;
+ }
+ }
+ else
+ {
+ switch(asn1type(name))
+ {
+ case ASN1TYPE_CHOICE:
+ case ASN1TYPE_ENUMERATED:
+ /* assert */
+ if(state.and_items)
+ fatal("CHOICE or ENUMERATED type, but and_items set");
+ buf_append(&state.parser, "\ttoken_t next = next_token();\n\n");
+ buf_append(&state.parser, "\t/* CHOICE or ENUMERATED */\n");
+ item = state.items;
+ for(item=state.items; item; item=item->next)
+ {
+ /* is it the first */
+ if(item == state.items)
+ buf_append(&state.parser, "\t");
+ else
+ buf_append(&state.parser, "\telse ");
+ if(item->type == IT_IDENTIFIER)
+ {
+ buf_append(&state.parser, "if(is_%s(next))\n", item->name);
+ buf_append(&state.parser, "\t\tparse_%s(state);\n", item->name);
+ }
+ else if(item->type == IT_LITERAL)
+ {
+ char *tok_name = unquote(item->name);
+ buf_append(&state.parser, "if(is_%s(next))\n", tok_name);
+ buf_append(&state.parser, "\t\tparse_%s(state);\n", tok_name);
+ free(tok_name);
+ }
+ else
+ {
+ fatal("CHOICE/ENUMERATED but not Identifier or Literal");
+ }
+ }
+ buf_append(&state.parser, "\telse\n");
+ buf_append(&state.parser, "\t\tparse_error(\"Unexpected token\");\n");
+ break;
+
+ case ASN1TYPE_SET:
+ /* assert */
+ if(!state.and_items)
+ fatal("SET type, but and_items not set");
+ item = state.items;
+ while(item && item->type == IT_LITERAL)
+ {
+buf_append(&state.parser, "// TODO: eat %s\n\n", item->name);
+ item = item->next;
+ }
+ buf_append(&state.parser, "\t/* SET */\n");
+buf_append(&state.parser, "// TODO: SET\n");
+ break;
+
+ case ASN1TYPE_SEQUENCE:
+ /* assert */
+ if(!state.and_items)
+ fatal("SEQUENCE type, but and_items not set");
+ buf_append(&state.parser, "\t/* SEQUENCE */\n");
+ buf_append(&state.parser, "\ttoken_t next;\n");
+ item = state.items;
+ for(item=state.items; item; item=item->next)
+ {
+ if(item->type != IT_IDENTIFIER && item->type != IT_LITERAL && item->type != IT_OPTIONAL)
+ fatal("SEQUENCE but not Identifier, Literal or Optional");
+ buf_append(&state.parser, "\n\t/* %s */\n", item->name);
+ if(item->type == IT_LITERAL)
+ {
+buf_append(&state.parser, "// TODO: eat %s\n", item->name);
+ }
+ else
+ {
+ buf_append(&state.parser, "\tnext = next_token();\n");
+ buf_append(&state.parser, "\tif(is_%s(next))\n", item->name);
+ buf_append(&state.parser, "\t\tparse_%s(state);\n", item->name);
+ if(item->type != IT_OPTIONAL)
+ {
+ buf_append(&state.parser, "\telse\n");
+ buf_append(&state.parser, "\t\tparse_error(\"Expecting %s\");\n", item->name);
+ }
+ }
+ }
+ break;
+
+ default:
+ fatal("Illegal ASN1TYPE");
+ break;
+ }
+ }
+ buf_append(&state.parser, "}\n\n", name);
+
/* free the items */
item = state.items;
while(item)
@@ -556,3 +719,4 @@
return;
}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-30 16:16:32
|
Revision: 360
http://redbutton.svn.sourceforge.net/redbutton/?rev=360&view=rev
Author: skilvington
Date: 2007-08-30 09:16:25 -0700 (Thu, 30 Aug 2007)
Log Message:
-----------
generate C code for a parser rather than a yacc grammar
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/ccc.y
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
Added Paths:
-----------
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.footer
redbutton-author/trunk/parser.h.header
redbutton-author/trunk/tokens.h.header
Removed Paths:
-------------
redbutton-author/trunk/parser.y.footer
redbutton-author/trunk/parser.y.header
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-08-30 08:30:55 UTC (rev 359)
+++ redbutton-author/trunk/Makefile 2007-08-30 16:16:25 UTC (rev 360)
@@ -10,40 +10,25 @@
OBJS= mhegc.o \
lex.parser.o \
- parser.tab.o \
+ parser.o \
utils.o
TARDIR=`basename ${PWD}`
-mhegc: ${OBJS}
+mhegc: parser.h ${OBJS}
${CC} ${CFLAGS} -o mhegc ${OBJS} ${LIBS}
-mhegc.o: mhegc.c parser.tab.h
- ${CC} ${CFLAGS} -c mhegc.c
-
-parser.tab.h: parser.tab.c
-
ccc: ccc.y ccc.l asn1type.o
${LEX} -i -t ccc.l > lex.ccc.c
${YACC} -b ccc -d ccc.y
${CC} ${CFLAGS} -o ccc lex.ccc.c ccc.tab.c asn1type.o
-parser.l: parser.l.header parser.l.footer grammar ccc
- cat parser.l.header > parser.l
- cat grammar | ./ccc -l >> parser.l
- cat parser.l.footer >> parser.l
-
-parser.y: parser.y.header parser.y.footer grammar ccc
- cat parser.y.header > parser.y
- cat grammar | ./ccc >> parser.y
- cat parser.y.footer >> parser.y
-
-lex.parser.c: parser.l
+lex.parser.o parser.o parser.h: parser.l.* parser.c.* parser.h.* tokens.h.* grammar ccc
+ cat grammar | ./ccc -l parser.l -p parser.c -h parser.h -t tokens.h
${LEX} -i -t parser.l > lex.parser.c
+ ${CC} ${CFLAGS} -c lex.parser.c
+ ${CC} ${CFLAGS} -c parser.c
-parser.tab.c: parser.y
- ${YACC} -b parser -d parser.y
-
.c.o:
${CC} ${CFLAGS} -c $<
@@ -51,7 +36,7 @@
install -m 755 mhegc ${DESTDIR}/bin
clean:
- rm -f mhegc ccc lex.*.c *.tab.[ch] parser.l parser.y *.o core
+ rm -f mhegc ccc lex.ccc.c ccc.tab.[ch] lex.parser.c parser.[lch] tokens.h *.o core
tar:
make clean
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-30 08:30:55 UTC (rev 359)
+++ redbutton-author/trunk/ccc.y 2007-08-30 16:16:25 UTC (rev 360)
@@ -7,6 +7,8 @@
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
+#include <limits.h>
+#include <errno.h>
#include "asn1type.h"
@@ -51,14 +53,15 @@
bool and_items; /* true => identifier must contain all items */
struct buf lexer; /* lex output file */
struct str_list *tokens; /* "%token" section of the yacc output file */
- struct buf grammar; /* grammar section of the yacc output file */
- struct str_list *oneormores; /* grammar section for Identifier+ rules */
struct buf parse_fns; /* parse_Xxx() C functions for the parser */
struct buf is_fns; /* is_Xxx() C functions for the parser */
struct buf parse_hdr; /* parse_Xxx() prototypes for the parser */
struct buf is_hdr; /* is_Xxx() C prototypes for the parser */
} state;
+/* header for files we generate */
+#define STANDARD_HEADER "/*\n * This file was automatically generated. Do not Edit!\n */\n\n"
+
int yyparse(void);
int yylex(void);
@@ -68,18 +71,17 @@
void add_item(enum item_type, char *);
void output_def(char *);
-void output_item(struct item *, bool);
void print_tokens(struct str_list *);
char *add_token(struct str_list **, char *);
char *unquote(char *);
-void print_oneormores(struct str_list *);
-void add_oneormore(struct str_list **, char *);
-
void buf_init(struct buf *);
void buf_append(struct buf *, char *, ...);
+FILE *safe_fopen(char *, char *);
+void file_append(FILE *, char *);
+
/* input line we are currently parsing */
int yylineno = 1;
@@ -179,28 +181,35 @@
main(int argc, char *argv[])
{
char *prog_name = argv[0];
- bool show_lexer = false;
- bool show_parser = false;
- bool show_header = false;
+ char *lexer_name = NULL;
+ char *parser_name = NULL;
+ char *header_name = NULL;
+ char *tokens_name = NULL;
int arg;
struct str_list *t;
+ char header[PATH_MAX];
+ char footer[PATH_MAX];
- while((arg = getopt(argc, argv, "lph")) != EOF)
+ while((arg = getopt(argc, argv, "l:p:h:t:")) != EOF)
{
switch(arg)
{
case 'l':
- show_lexer = true;
+ lexer_name = optarg;
break;
case 'p':
- show_parser = true;
+ parser_name = optarg;
break;
case 'h':
- show_header = true;
+ header_name = optarg;
break;
+ case 't':
+ tokens_name = optarg;
+ break;
+
default:
usage(prog_name);
break;
@@ -213,8 +222,6 @@
state.items = NULL;
buf_init(&state.lexer);
state.tokens = NULL;
- buf_init(&state.grammar);
- state.oneormores = NULL;
buf_init(&state.parse_fns);
buf_init(&state.is_fns);
buf_init(&state.parse_hdr);
@@ -222,43 +229,98 @@
yyparse();
- if(show_lexer)
+
+ /*
+ * add parse_Xxx functions for the tokens
+ * #define is_Xxx functions for the tokens
+ */
+ for(t=state.tokens; t; t=t->next)
{
- /* output lexer */
- printf("%s", state.lexer.str);
+ buf_append(&state.parse_fns, "void parse_%s(struct state *state)\n{\n", t->name);
+buf_append(&state.parse_fns, "// TODO\n");
+ buf_append(&state.parse_fns, "}\n\n", t->name);
+ /* parse_Xxx prototype */
+ buf_append(&state.parse_hdr, "void parse_%s(struct state *);\n", t->name);
+ /* #define is_Xxx function */
+ buf_append(&state.is_hdr, "#define is_%s(TOK)\t(TOK == %s)\n", t->name, t->name);
}
- else if(show_parser)
+
+ /* output lexer */
+ if(lexer_name != NULL)
{
- /* output C code */
- printf("%s", state.parse_fns.str);
- printf("%s", state.is_fns.str);
+ FILE *lexer_file = safe_fopen(lexer_name, "w");
+ fprintf(lexer_file, STANDARD_HEADER);
+ /* output the header if there is one */
+ snprintf(header, sizeof(header), "%s.header", lexer_name);
+ file_append(lexer_file, header);
+ /* output our stuff */
+ fprintf(lexer_file, "%s", state.lexer.str);
+ /* output the footer if there is one */
+ snprintf(footer, sizeof(footer), "%s.footer", lexer_name);
+ file_append(lexer_file, footer);
+ fclose(lexer_file);
}
- else if(show_header)
+
+ /* output parser C code */
+ if(parser_name != NULL)
{
- /* output C header file */
- printf("%s", state.parse_hdr.str);
- printf("%s", state.is_hdr.str);
- /* add is_Xxx functions for the tokens */
- for(t=state.tokens; t; t=t->next)
- printf("#define is_%s(TOK)\t(TOK == %s)\n", t->name, t->name);
+ FILE *parser_file = safe_fopen(parser_name, "w");
+ fprintf(parser_file, STANDARD_HEADER);
+ /* output the header if there is one */
+ snprintf(header, sizeof(header), "%s.header", parser_name);
+ file_append(parser_file, header);
+ /* output our stuff */
+ fprintf(parser_file, "%s", state.parse_fns.str);
+ fprintf(parser_file, "%s", state.is_fns.str);
+ /* output the footer if there is one */
+ snprintf(footer, sizeof(footer), "%s.footer", parser_name);
+ file_append(parser_file, footer);
+ fclose(parser_file);
}
- else
+
+ /* output parser header file */
+ if(header_name != NULL)
{
- /* output grammar */
- print_tokens(state.tokens);
- printf("%%%%\n");
- printf("%s", state.grammar.str);
- print_oneormores(state.oneormores);
- printf("%%%%\n");
+ FILE *header_file = safe_fopen(header_name, "w");
+ fprintf(header_file, STANDARD_HEADER);
+ /* output the header if there is one */
+ snprintf(header, sizeof(header), "%s.header", header_name);
+ file_append(header_file, header);
+ /* output our stuff */
+ fprintf(header_file, "%s", state.parse_hdr.str);
+ fprintf(header_file, "%s", state.is_hdr.str);
+ /* output the footer if there is one */
+ snprintf(footer, sizeof(footer), "%s.footer", header_name);
+ file_append(header_file, footer);
+ fclose(header_file);
}
+ /* output a header file defining the tokens for the lexer */
+ if(tokens_name != NULL)
+ {
+ unsigned int tok_val;
+ FILE *tokens_file = safe_fopen(tokens_name, "w");
+ fprintf(tokens_file, STANDARD_HEADER);
+ /* output the header if there is one */
+ snprintf(header, sizeof(header), "%s.header", tokens_name);
+ file_append(tokens_file, header);
+ /* output our stuff */
+ tok_val = 256;
+ for(t=state.tokens; t; t=t->next)
+ fprintf(tokens_file, "#define %s\t%u\n", t->name, tok_val++);
+ /* output the footer if there is one */
+ snprintf(footer, sizeof(footer), "%s.footer", tokens_name);
+ file_append(tokens_file, footer);
+ fclose(tokens_file);
+ }
+
return EXIT_SUCCESS;
}
void
usage(char *prog_name)
{
- fprintf(stderr, "Syntax: %s [-l|-p|-h]\n", prog_name);
+ fprintf(stderr, "Syntax: %s [-l <lexer-file>] [-p <parser-c-file>] [-h <parser-h-file>] [-t <tokens-file>]\n", prog_name);
exit(EXIT_FAILURE);
}
@@ -298,6 +360,10 @@
new_item->type = type;
new_item->include = true;
+ /* if it is a literal, make a token for it */
+ if(new_item->type == IT_LITERAL)
+ add_token(&state.tokens, new_item->name);
+
return;
}
@@ -308,14 +374,6 @@
struct item *next;
unsigned int nitems;
- buf_append(&state.grammar, "%s:\n\t", name);
-
- /* output each item that makes up this identifier */
- for(item=state.items; item; item=item->next)
- output_item(item, true);
-
- buf_append(&state.grammar, ";\n\n");
-
/* C code for the parse_Xxx functions */
buf_append(&state.parse_hdr, "void parse_%s(struct state *);\n", name);
buf_append(&state.parse_fns, "void parse_%s(struct state *state)\n{\n", name);
@@ -573,74 +631,6 @@
}
void
-output_item(struct item *item, bool recurse)
-{
- char *tok_name;
- struct item *rest;
-
- switch(item->type)
- {
- case IT_LITERAL:
- tok_name = add_token(&state.tokens, item->name);
- buf_append(&state.grammar, tok_name);
- break;
-
- case IT_IDENTIFIER:
- buf_append(&state.grammar, item->name);
- break;
-
- case IT_OPTIONAL:
- if(recurse)
- {
- /*
- * we are an optional item,
- * so first output the remaining items
- * this creates a rule which does not including us
- */
- item->include = false;
- for(rest=item->next; rest; rest=rest->next)
- output_item(rest, true);
- /* or it with a rule which does contain us */
- if(item->next == NULL)
- buf_append(&state.grammar, "\n\t");
- buf_append(&state.grammar, "|\n\t");
- /*
- * now output the items before us and output ourself,
- * this constructs a rule including us
- */
- item->include = true;
- for(rest=state.items; rest!=item; rest=rest->next)
- output_item(rest, false);
- buf_append(&state.grammar, item->name);
- }
- else if(item->include)
- {
- buf_append(&state.grammar, item->name);
- }
- break;
-
- case IT_ONEORMORE:
- /* add "OneOrMoreIdentifier" to the grammar */
- buf_append(&state.grammar, "OneOrMore%s", item->name);
- /* add the OneOrMoreIdentifier to our list */
- add_oneormore(&state.oneormores, item->name);
- break;
-
- default:
- fatal("Unexpected item type");
- break;
- }
-
- /* do we need all the items, or just one of them */
- if(state.and_items)
- buf_append(&state.grammar, item->next ? (item->include ? " " : "") : "\n\t");
- else
- buf_append(&state.grammar, item->next ? "\n\t|\n\t" : "\n\t");
-
- return;
-}
-
-void
print_tokens(struct str_list *t)
{
while(t)
@@ -751,47 +741,6 @@
return output;
}
-void
-print_oneormores(struct str_list *list)
-{
- while(list)
- {
- /* output the OneOrMoreIdentifier rule */
- printf("OneOrMore%s:\n", list->name);
- printf("\t%s\n", list->name);
- printf("\t|\n");
- printf("\tOneOrMore%s %s\n", list->name, list->name);
- printf("\t;\n\n");
- list = list->next;
- }
-
- return;
-}
-
-void
-add_oneormore(struct str_list **head, char *name)
-{
- struct str_list *list;
-
- /* check we haven't got it already */
- for(list=*head; list; list=list->next)
- {
- if(strcmp(list->name, name) == 0)
- return;
- }
-
- /* take a copy of the string */
- if((list = malloc(sizeof(struct str_list))) == NULL
- || (list->name = strdup(name)) == NULL)
- fatal("Out of memory");
-
- /* add it to the head of the list */
- list->next = *head;
- *head = list;
-
- return;
-}
-
#define INIT_BUF_SIZE 1024
void
@@ -834,4 +783,47 @@
return;
}
+FILE *
+safe_fopen(char *path, char *mode)
+{
+ FILE *f;
+ if((f = fopen(path, mode)) == NULL)
+ {
+ fprintf(stderr, "Unable to open %s: %s\n", path, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ return f;
+}
+
+void
+file_append(FILE *out, char *path)
+{
+ FILE *append = fopen(path, "r");
+ char buf[BUFSIZ];
+ size_t nread;
+
+ /* don't care if the file does not exist */
+ if(append == NULL)
+ {
+ if(errno == ENOENT)
+ return;
+ fprintf(stderr, "Unable to read %s: %s\n", path, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ /* we are using stdio, so copy in BUFSIZ blocks */
+ while(!feof(append))
+ {
+ nread = fread(buf, 1, sizeof(buf), append);
+ if(fwrite(buf, 1, nread, out) != nread)
+ {
+ fprintf(stderr, "Unable to append %s: %s", path, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ return;
+}
+
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-08-30 08:30:55 UTC (rev 359)
+++ redbutton-author/trunk/mhegc.c 2007-08-30 16:16:25 UTC (rev 360)
@@ -23,17 +23,15 @@
#include <stdio.h>
#include <stdlib.h>
-#include "parser.tab.h"
+#include "parser.h"
-int yyparse(void);
-extern int yydebug;
-
int
main(int argc, char *argv[])
{
- yydebug=1;
- yyparse();
+ struct state state;
+ parse_InterchangedObject(&state);
+
return EXIT_SUCCESS;
}
Added: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header (rev 0)
+++ redbutton-author/trunk/parser.c.header 2007-08-30 16:16:25 UTC (rev 360)
@@ -0,0 +1,53 @@
+#include <stdio.h>
+
+#include "parser.h"
+#include "tokens.h"
+
+int yylineno = 1;
+
+int yylex(void);
+
+void
+yyerror(const char *str)
+{
+ fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+}
+
+int
+yywrap(void)
+{
+ return 1;
+}
+
+/*
+ * parser functions for the predefined types
+ */
+
+void parse_INTEGER(struct state *state)
+{
+}
+
+void parse_BOOLEAN(struct state *state)
+{
+}
+
+
+void parse_STRING(struct state *state)
+{
+}
+
+
+void parse_QPRINTABLE(struct state *state)
+{
+}
+
+
+void parse_BASE64(struct state *state)
+{
+}
+
+
+void parse_Null(struct state *state)
+{
+}
+
Added: redbutton-author/trunk/parser.h.footer
===================================================================
--- redbutton-author/trunk/parser.h.footer (rev 0)
+++ redbutton-author/trunk/parser.h.footer 2007-08-30 16:16:25 UTC (rev 360)
@@ -0,0 +1,10 @@
+#define is_INVALID(TOK) (TOK == 1)
+#define is_INTEGER(TOK) (TOK == 2)
+#define is_BOOLEAN(TOK) (TOK == 3)
+#define is_STRING(TOK) (TOK == 4)
+#define is_QPRINTABLE(TOK) (TOK == 5)
+#define is_BASE64(TOK) (TOK == 6)
+#define is_Null(TOK) (TOK == 7)
+
+#endif /* __NEW_PARSER_H__ */
+
Added: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header (rev 0)
+++ redbutton-author/trunk/parser.h.header 2007-08-30 16:16:25 UTC (rev 360)
@@ -0,0 +1,8 @@
+#ifndef __NEW_PARSER_H__
+#define __NEW_PARSER_H__
+
+#include <stdbool.h>
+
+struct state { int dummy; };
+typedef int token_t;
+
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-08-30 08:30:55 UTC (rev 359)
+++ redbutton-author/trunk/parser.l.footer 2007-08-30 16:16:25 UTC (rev 360)
@@ -1,2 +1,21 @@
. return INVALID;
%%
+
+/* don't use #define in case they are macros too */
+token_t
+next_token(void)
+{
+ return yylex();
+}
+
+void
+unget_token(token_t tok)
+{
+ unput(tok);
+}
+
+void
+parse_error(char *err)
+{
+ yyerror(err);
+}
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-08-30 08:30:55 UTC (rev 359)
+++ redbutton-author/trunk/parser.l.header 2007-08-30 16:16:25 UTC (rev 360)
@@ -1,15 +1,14 @@
%{
-#include <string.h>
-#define YYSTYPE char *
-#include "parser.tab.h"
+#include "parser.h"
+#include "tokens.h"
extern int yylineno;
%}
%%
-([-0-9][0-9]*)|(0x[0-9a-f]+) yylval = strdup(yytext); return INTEGER;
-true|false yylval = strdup(yytext); return BOOLEAN;
-\"((\\\")|[^"])*\" yylval = strdup(yytext); return STRING;
-'[^']*' yylval = strdup(yytext); return QPRINTABLE;
-`[^`]*` yylval = strdup(yytext); return BASE64;
+([-0-9][0-9]*)|(0x[0-9a-f]+) return INTEGER;
+true|false return BOOLEAN;
+\"((\\\")|[^"])*\" return STRING;
+'[^']*' return QPRINTABLE;
+`[^`]*` return BASE64;
null return Null;
[\n\r\f] yylineno ++;
[ \t]+ /* ignore whitespace */
Deleted: redbutton-author/trunk/parser.y.footer
===================================================================
--- redbutton-author/trunk/parser.y.footer 2007-08-30 08:30:55 UTC (rev 359)
+++ redbutton-author/trunk/parser.y.footer 2007-08-30 16:16:25 UTC (rev 360)
@@ -1 +0,0 @@
-
Deleted: redbutton-author/trunk/parser.y.header
===================================================================
--- redbutton-author/trunk/parser.y.header 2007-08-30 08:30:55 UTC (rev 359)
+++ redbutton-author/trunk/parser.y.header 2007-08-30 16:16:25 UTC (rev 360)
@@ -1,33 +0,0 @@
-%{
-#include <stdio.h>
-#include <string.h>
-
-#define YYSTYPE char *
-#define YYERROR_VERBOSE
-#define YYDEBUG 1
-
-int yylex(void);
-
-int yylineno = 1;
-
-void
-yyerror(const char *str)
-{
- fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
-}
-
-int
-yywrap(void)
-{
- return 1;
-}
-
-%}
-
-%token INTEGER
-%token BOOLEAN
-%token STRING
-%token QPRINTABLE
-%token BASE64
-%token Null
-%token INVALID
Added: redbutton-author/trunk/tokens.h.header
===================================================================
--- redbutton-author/trunk/tokens.h.header (rev 0)
+++ redbutton-author/trunk/tokens.h.header 2007-08-30 16:16:25 UTC (rev 360)
@@ -0,0 +1,7 @@
+#define INVALID 1
+#define INTEGER 2
+#define BOOLEAN 3
+#define STRING 4
+#define QPRINTABLE 5
+#define BASE64 6
+#define Null 7
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-31 07:22:12
|
Revision: 362
http://redbutton.svn.sourceforge.net/redbutton/?rev=362&view=rev
Author: skilvington
Date: 2007-08-31 00:21:40 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
parse everything except enum values
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/ccc.y
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.footer
redbutton-author/trunk/parser.h.header
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
redbutton-author/trunk/tokens.h.header
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/Makefile 2007-08-31 07:21:40 UTC (rev 362)
@@ -1,6 +1,9 @@
CC=gcc
CFLAGS=-Wall -O2
+# for vasprintf
+DEFS=-D_GNU_SOURCE
+
LEX=flex
YACC=bison
#LEX=lex
@@ -16,21 +19,21 @@
TARDIR=`basename ${PWD}`
mhegc: parser.h ${OBJS}
- ${CC} ${CFLAGS} -o mhegc ${OBJS} ${LIBS}
+ ${CC} ${CFLAGS} ${DEFS} -o mhegc ${OBJS} ${LIBS}
ccc: ccc.y ccc.l asn1type.o
${LEX} -i -t ccc.l > lex.ccc.c
${YACC} -b ccc -d ccc.y
- ${CC} ${CFLAGS} -o ccc lex.ccc.c ccc.tab.c asn1type.o
+ ${CC} ${CFLAGS} ${DEFS} -o ccc lex.ccc.c ccc.tab.c asn1type.o
lex.parser.o parser.o parser.h: parser.l.* parser.c.* parser.h.* tokens.h.* grammar ccc
cat grammar | ./ccc -l parser.l -p parser.c -h parser.h -t tokens.h
${LEX} -i -t parser.l > lex.parser.c
- ${CC} ${CFLAGS} -c lex.parser.c
- ${CC} ${CFLAGS} -c parser.c
+ ${CC} ${CFLAGS} ${DEFS} -c lex.parser.c
+ ${CC} ${CFLAGS} ${DEFS} -c parser.c
.c.o:
- ${CC} ${CFLAGS} -c $<
+ ${CC} ${CFLAGS} ${DEFS} -c $<
install: mhegc
install -m 755 mhegc ${DESTDIR}/bin
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/ccc.y 2007-08-31 07:21:40 UTC (rev 362)
@@ -1,5 +1,4 @@
%{
-#define _GNU_SOURCE /* for vasprintf */
#include <unistd.h>
#include <stdio.h>
#include <string.h>
@@ -72,7 +71,6 @@
void output_def(char *);
-void print_tokens(struct str_list *);
char *add_token(struct str_list **, char *);
char *unquote(char *);
@@ -377,6 +375,7 @@
/* C code for the parse_Xxx functions */
buf_append(&state.parse_hdr, "void parse_%s(struct state *);\n", name);
buf_append(&state.parse_fns, "void parse_%s(struct state *state)\n{\n", name);
+buf_append(&state.parse_fns, "printf(\"<%s>\\n\");\n", name);
/* count how many items make it up */
nitems = 0;
/* skip literals at the start */
@@ -391,13 +390,17 @@
}
if(nitems == 1)
{
+ buf_append(&state.parse_fns, "\ttoken_t next;\n\n");
item = state.items;
while(item && item->type == IT_LITERAL)
{
-buf_append(&state.parse_fns, "// TODO: eat %s\n\n", item->name);
+ char *tok_name = unquote(item->name);
+ buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ free(tok_name);
item = item->next;
}
- buf_append(&state.parse_fns, "\ttoken_t next = next_token();\n\n");
+ buf_append(&state.parse_fns, "\tnext = peek_token();\n\n");
if(item->type == IT_IDENTIFIER)
{
buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
@@ -418,9 +421,8 @@
buf_append(&state.parse_fns, "\twhile(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t{\n");
buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", item->name);
- buf_append(&state.parse_fns, "\t\tnext = next_token();\n");
+ buf_append(&state.parse_fns, "\t\tnext = peek_token();\n");
buf_append(&state.parse_fns, "\t}\n");
- buf_append(&state.parse_fns, "\n\tunget_token(next);\n");
}
else
{
@@ -429,7 +431,10 @@
item = item->next;
while(item)
{
-buf_append(&state.parse_fns, "\n// TODO: eat %s\n", item->name);
+ char *tok_name = unquote(item->name);
+ buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ free(tok_name);
item = item->next;
}
}
@@ -442,7 +447,7 @@
/* assert */
if(state.and_items)
fatal("CHOICE or ENUMERATED type, but and_items set");
- buf_append(&state.parse_fns, "\ttoken_t next = next_token();\n\n");
+ buf_append(&state.parse_fns, "\ttoken_t next = peek_token();\n\n");
buf_append(&state.parse_fns, "\t/* CHOICE or ENUMERATED */\n");
item = state.items;
for(item=state.items; item; item=item->next)
@@ -481,12 +486,15 @@
item = state.items;
while(item && item->type == IT_LITERAL)
{
-buf_append(&state.parse_fns, "// TODO: eat %s\n\n", item->name);
+ char *tok_name = unquote(item->name);
+ buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ free(tok_name);
item = item->next;
}
buf_append(&state.parse_fns, "\t/* SET */\n");
buf_append(&state.parse_fns, "\twhile(true)\n\t{\n");
- buf_append(&state.parse_fns, "\t\tnext = next_token();\n");
+ buf_append(&state.parse_fns, "\t\tnext = peek_token();\n");
while(item && item->type != IT_LITERAL)
{
if(item->type != IT_IDENTIFIER && item->type != IT_OPTIONAL)
@@ -504,7 +512,10 @@
/* eat any trailing literals */
while(item && item->type == IT_LITERAL)
{
-buf_append(&state.parse_fns, "\n// TODO: eat %s\n", item->name);
+ char *tok_name = unquote(item->name);
+ buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ free(tok_name);
item = item->next;
}
break;
@@ -523,11 +534,13 @@
buf_append(&state.parse_fns, "\n\t/* %s */\n", item->name);
if(item->type == IT_LITERAL)
{
-buf_append(&state.parse_fns, "// TODO: eat %s\n", item->name);
+ char *tok_name = unquote(item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ free(tok_name);
}
else
{
- buf_append(&state.parse_fns, "\tnext = next_token();\n");
+ buf_append(&state.parse_fns, "\tnext = peek_token();\n");
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", item->name);
if(item->type != IT_OPTIONAL)
@@ -544,6 +557,7 @@
break;
}
}
+buf_append(&state.parse_fns, "printf(\"</%s>\\n\");\n", name);
buf_append(&state.parse_fns, "}\n\n");
/* C code for the is_Xxx functions */
@@ -630,18 +644,6 @@
return;
}
-void
-print_tokens(struct str_list *t)
-{
- while(t)
- {
- printf("%%token %s\n", t->name);
- t = t->next;
- }
-
- return;
-}
-
char *
add_token(struct str_list **head, char *quoted)
{
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/mhegc.c 2007-08-31 07:21:40 UTC (rev 362)
@@ -32,6 +32,9 @@
parse_InterchangedObject(&state);
+ if(next_token())
+ parse_error("Unexpected text after InterchangedObject");
+
return EXIT_SUCCESS;
}
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/parser.c.header 2007-08-31 07:21:40 UTC (rev 362)
@@ -5,8 +5,6 @@
int yylineno = 1;
-int yylex(void);
-
void
yyerror(const char *str)
{
@@ -25,29 +23,65 @@
void parse_INTEGER(struct state *state)
{
+ if(next_token() != INTEGER)
+ yyerror("Expecting INTEGER");
+
+printf("<INTEGER value=%s/>\n", token_text());
+
+ return;
}
void parse_BOOLEAN(struct state *state)
{
+ if(next_token() != BOOLEAN)
+ yyerror("Expecting BOOLEAN");
+
+printf("<BOOLEAN value=%s/>\n", token_text());
+
+ return;
}
void parse_STRING(struct state *state)
{
+ if(next_token() != STRING)
+ yyerror("Expecting STRING");
+
+printf("<STRING value=%s/>\n", token_text());
+
+ return;
}
void parse_QPRINTABLE(struct state *state)
{
+ if(next_token() != QPRINTABLE)
+ yyerror("Expecting QPRINTABLE");
+
+printf("<QPRINTABLE value=%s/>\n", token_text());
+
+ return;
}
void parse_BASE64(struct state *state)
{
+ if(next_token() != BASE64)
+ yyerror("Expecting BASE64");
+
+printf("<BASE64 value=%s/>\n", token_text());
+
+ return;
}
void parse_Null(struct state *state)
{
+ if(next_token() != Null)
+ yyerror("Expecting Null");
+
+printf("<Null/>\n");
+
+ return;
}
Modified: redbutton-author/trunk/parser.h.footer
===================================================================
--- redbutton-author/trunk/parser.h.footer 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/parser.h.footer 2007-08-31 07:21:40 UTC (rev 362)
@@ -6,5 +6,4 @@
#define is_BASE64(TOK) (TOK == BASE64)
#define is_Null(TOK) (TOK == Null)
-#endif /* __NEW_PARSER_H__ */
-
+#endif /* __PARSER_H__ */
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/parser.h.header 2007-08-31 07:21:40 UTC (rev 362)
@@ -1,8 +1,16 @@
-#ifndef __NEW_PARSER_H__
-#define __NEW_PARSER_H__
+#ifndef __PARSER_H__
+#define __PARSER_H__
+#include <stdio.h>
#include <stdbool.h>
struct state { int dummy; };
typedef int token_t;
+token_t peek_token(void);
+void expect_token(token_t, char *);
+token_t next_token(void);
+char *token_text(void);
+
+void parse_error(const char *, ...);
+
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/parser.l.footer 2007-08-31 07:21:40 UTC (rev 362)
@@ -3,19 +3,57 @@
/* don't use #define in case they are macros too */
token_t
+peek_token(void)
+{
+ token_t tok = yylex();
+
+ /* return it to the input stream */
+ yyless(0);
+
+ return tok;
+}
+
+void
+expect_token(token_t tok, char *name)
+{
+ if(next_token() != tok)
+ parse_error("Unexpected token; expecting '%s'", name);
+
+ return;
+}
+
+token_t
next_token(void)
{
return yylex();
}
-void
-unget_token(token_t tok)
+char *
+token_text(void)
{
- unput(tok);
+ return yytext;
}
+void yyerror(const char *);
+
void
-parse_error(char *err)
+parse_error(const char *fmt, ...)
{
+ va_list ap;
+ char *err;
+
+ va_start(ap, fmt);
+ if(vasprintf(&err, fmt, ap) < 0)
+ {
+ fprintf(stderr, "Out of memory or illegal format string");
+ exit(EXIT_FAILURE);
+ }
+ va_end(ap);
+
yyerror(err);
+
+ free(err);
+
+ return;
}
+
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/parser.l.header 2007-08-31 07:21:40 UTC (rev 362)
@@ -1,4 +1,6 @@
%{
+#include <stdio.h>
+#include <stdarg.h>
#include "parser.h"
#include "tokens.h"
extern int yylineno;
Modified: redbutton-author/trunk/tokens.h.header
===================================================================
--- redbutton-author/trunk/tokens.h.header 2007-08-30 16:29:28 UTC (rev 361)
+++ redbutton-author/trunk/tokens.h.header 2007-08-31 07:21:40 UTC (rev 362)
@@ -1,3 +1,4 @@
+#define END_OF_SRC 0 /* must be 0 */
#define INVALID 1
#define INTEGER 2
#define BOOLEAN 3
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-31 08:38:48
|
Revision: 363
http://redbutton.svn.sourceforge.net/redbutton/?rev=363&view=rev
Author: skilvington
Date: 2007-08-31 01:38:43 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
parse enums too
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.l.footer
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-31 07:21:40 UTC (rev 362)
+++ redbutton-author/trunk/ccc.y 2007-08-31 08:38:43 UTC (rev 363)
@@ -53,8 +53,10 @@
struct buf lexer; /* lex output file */
struct str_list *tokens; /* "%token" section of the yacc output file */
struct buf parse_fns; /* parse_Xxx() C functions for the parser */
+ struct buf parse_enum_fns; /* parse_Xxx() functions for enum values */
struct buf is_fns; /* is_Xxx() C functions for the parser */
struct buf parse_hdr; /* parse_Xxx() prototypes for the parser */
+ struct buf parse_enum_hdr; /* parse_Xxx() prototypes for enum values */
struct buf is_hdr; /* is_Xxx() C prototypes for the parser */
} state;
@@ -221,27 +223,17 @@
buf_init(&state.lexer);
state.tokens = NULL;
buf_init(&state.parse_fns);
+ buf_init(&state.parse_enum_fns);
buf_init(&state.is_fns);
buf_init(&state.parse_hdr);
+ buf_init(&state.parse_enum_hdr);
buf_init(&state.is_hdr);
yyparse();
-
- /*
- * add parse_Xxx functions for the tokens
- * #define is_Xxx functions for the tokens
- */
+ /* #define is_Xxx functions for the tokens */
for(t=state.tokens; t; t=t->next)
- {
- buf_append(&state.parse_fns, "void parse_%s(struct state *state)\n{\n", t->name);
-buf_append(&state.parse_fns, "// TODO\n");
- buf_append(&state.parse_fns, "}\n\n", t->name);
- /* parse_Xxx prototype */
- buf_append(&state.parse_hdr, "void parse_%s(struct state *);\n", t->name);
- /* #define is_Xxx function */
buf_append(&state.is_hdr, "#define is_%s(TOK)\t(TOK == %s)\n", t->name, t->name);
- }
/* output lexer */
if(lexer_name != NULL)
@@ -269,6 +261,7 @@
file_append(parser_file, header);
/* output our stuff */
fprintf(parser_file, "%s", state.parse_fns.str);
+ fprintf(parser_file, "%s", state.parse_enum_fns.str);
fprintf(parser_file, "%s", state.is_fns.str);
/* output the footer if there is one */
snprintf(footer, sizeof(footer), "%s.footer", parser_name);
@@ -286,6 +279,7 @@
file_append(header_file, header);
/* output our stuff */
fprintf(header_file, "%s", state.parse_hdr.str);
+ fprintf(header_file, "%s", state.parse_enum_hdr.str);
fprintf(header_file, "%s", state.is_hdr.str);
/* output the footer if there is one */
snprintf(footer, sizeof(footer), "%s.footer", header_name);
@@ -467,6 +461,14 @@
char *tok_name = unquote(item->name);
buf_append(&state.parse_fns, "if(is_%s(next))\n", tok_name);
buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", tok_name);
+ /* create a parse_Xxx function for the enum value */
+ if(asn1type(name) != ASN1TYPE_ENUMERATED)
+ fatal("literal but not enum");
+ buf_append(&state.parse_enum_hdr, "void parse_%s(struct state *);\n", tok_name);
+ buf_append(&state.parse_enum_fns, "void parse_%s(struct state *state)\n{\n", tok_name);
+ buf_append(&state.parse_enum_fns, "\texpect_token(%s, %s);\n", tok_name, item->name);
+buf_append(&state.parse_enum_fns, "printf(\"<ENUM value=%s/>\\n\");\n", tok_name);
+ buf_append(&state.parse_enum_fns, "}\n\n");
free(tok_name);
}
else
@@ -569,10 +571,32 @@
if(nitems == 1
|| state.items->type == IT_LITERAL)
{
- /* check if the first item matches the token */
+ /* if it is an enum, check if any item matches the token */
+ bool is_enum = true;
+ for(item=state.items; item && is_enum; item=item->next)
+ is_enum = is_enum && (item->type == IT_LITERAL);
item = state.items;
- if(item->type == IT_LITERAL)
+ if(is_enum)
{
+ if(asn1type(name) != ASN1TYPE_ENUMERATED)
+ fatal("is_enum but not ENUMERATED");
+ buf_append(&state.is_fns, "\treturn ");
+ while(item)
+ {
+ char *tok_name = unquote(item->name);
+ buf_append(&state.is_fns, "is_%s(tok)", tok_name);
+ free(tok_name);
+ /* is it the last one */
+ if(item->next)
+ buf_append(&state.is_fns, "\n\t || ");
+ else
+ buf_append(&state.is_fns, ";\n");
+ item = item->next;
+ }
+ }
+ /* just check if the first item matches the token */
+ else if(item->type == IT_LITERAL)
+ {
char *tok_name = unquote(item->name);
buf_append(&state.is_fns, "\treturn is_%s(tok);\n", tok_name);
free(tok_name);
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-08-31 07:21:40 UTC (rev 362)
+++ redbutton-author/trunk/parser.c.header 2007-08-31 08:38:43 UTC (rev 363)
@@ -8,7 +8,8 @@
void
yyerror(const char *str)
{
- fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+// fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
+printf("Error: %s at line %d\n", str, yylineno);
}
int
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-08-31 07:21:40 UTC (rev 362)
+++ redbutton-author/trunk/parser.l.footer 2007-08-31 08:38:43 UTC (rev 363)
@@ -7,6 +7,7 @@
{
token_t tok = yylex();
+printf("peek: '%s'\n", yytext);
/* return it to the input stream */
yyless(0);
@@ -25,7 +26,10 @@
token_t
next_token(void)
{
- return yylex();
+// return yylex();
+token_t tok = yylex();
+printf("next: '%s'\n", yytext);
+return tok;
}
char *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-31 13:44:53
|
Revision: 365
http://redbutton.svn.sourceforge.net/redbutton/?rev=365&view=rev
Author: skilvington
Date: 2007-08-31 06:44:42 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
add -v (verbose) flag to mhegc
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
redbutton-author/trunk/parser.l.footer
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-08-31 11:18:02 UTC (rev 364)
+++ redbutton-author/trunk/ccc.y 2007-08-31 13:44:42 UTC (rev 365)
@@ -369,7 +369,8 @@
/* C code for the parse_Xxx functions */
buf_append(&state.parse_hdr, "void parse_%s(struct state *);\n", name);
buf_append(&state.parse_fns, "void parse_%s(struct state *state)\n{\n", name);
-buf_append(&state.parse_fns, "printf(\"<%s>\\n\");\n", name);
+ buf_append(&state.parse_fns, "\ttoken_t next;\n\n");
+ buf_append(&state.parse_fns, "\tverbose(\"<%s>\\n\");\n\n", name);
/* count how many items make it up */
nitems = 0;
/* skip literals at the start */
@@ -384,7 +385,6 @@
}
if(nitems == 1)
{
- buf_append(&state.parse_fns, "\ttoken_t next;\n\n");
item = state.items;
while(item && item->type == IT_LITERAL)
{
@@ -441,7 +441,7 @@
/* assert */
if(state.and_items)
fatal("CHOICE or ENUMERATED type, but and_items set");
- buf_append(&state.parse_fns, "\ttoken_t next = peek_token();\n\n");
+ buf_append(&state.parse_fns, "\tnext = peek_token();\n\n");
buf_append(&state.parse_fns, "\t/* CHOICE or ENUMERATED */\n");
item = state.items;
for(item=state.items; item; item=item->next)
@@ -467,8 +467,8 @@
buf_append(&state.parse_enum_hdr, "void parse_%s(struct state *);\n", tok_name);
buf_append(&state.parse_enum_fns, "void parse_%s(struct state *state)\n{\n", tok_name);
buf_append(&state.parse_enum_fns, "\texpect_token(%s, %s);\n", tok_name, item->name);
-buf_append(&state.parse_enum_fns, "printf(\"<ENUM value=%s/>\\n\");\n", tok_name);
- buf_append(&state.parse_enum_fns, "}\n\n");
+ buf_append(&state.parse_enum_fns, "\n\tverbose(\"<ENUM value=%s/>\\n\");\n", tok_name);
+ buf_append(&state.parse_enum_fns, "\n\treturn;\n}\n\n");
free(tok_name);
}
else
@@ -484,7 +484,6 @@
/* assert */
if(!state.and_items)
fatal("SET but and_items not set");
- buf_append(&state.parse_fns, "\ttoken_t next;\n\n");
item = state.items;
while(item && item->type == IT_LITERAL)
{
@@ -527,7 +526,6 @@
if(!state.and_items)
fatal("SEQUENCE but and_items not set");
buf_append(&state.parse_fns, "\t/* SEQUENCE */\n");
- buf_append(&state.parse_fns, "\ttoken_t next;\n");
item = state.items;
for(item=state.items; item; item=item->next)
{
@@ -537,7 +535,7 @@
if(item->type == IT_LITERAL)
{
char *tok_name = unquote(item->name);
- buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n", tok_name, item->name);
free(tok_name);
}
else
@@ -559,8 +557,8 @@
break;
}
}
-buf_append(&state.parse_fns, "printf(\"</%s>\\n\");\n", name);
- buf_append(&state.parse_fns, "}\n\n");
+ buf_append(&state.parse_fns, "\n\tverbose(\"</%s>\\n\");\n", name);
+ buf_append(&state.parse_fns, "\n\treturn;\n}\n\n");
/* C code for the is_Xxx functions */
buf_append(&state.is_hdr, "bool is_%s(token_t);\n", name);
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-08-31 11:18:02 UTC (rev 364)
+++ redbutton-author/trunk/mhegc.c 2007-08-31 13:44:42 UTC (rev 365)
@@ -20,16 +20,41 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include "parser.h"
+void usage(char *);
+
+static int _verbose = 0;
+
int
main(int argc, char *argv[])
{
+ char *prog_name = argv[0];
+ int arg;
struct state state;
+ while((arg = getopt(argc, argv, "v")) != EOF)
+ {
+ switch(arg)
+ {
+ case 'v':
+ _verbose ++;
+ break;
+
+ default:
+ usage(prog_name);
+ break;
+ }
+ }
+
+ if(optind != argc)
+ usage(prog_name);
+
parse_InterchangedObject(&state);
if(next_token())
@@ -38,3 +63,44 @@
return EXIT_SUCCESS;
}
+/*
+ * verbose functions send output to stderr so error messages get interleaved correctly
+ */
+
+void
+verbose(const char *fmt, ...)
+{
+ va_list ap;
+
+ if(_verbose)
+ {
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ }
+
+ return;
+}
+
+void
+vverbose(const char *fmt, ...)
+{
+ va_list ap;
+
+ if(_verbose > 1)
+ {
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ }
+
+ return;
+}
+
+void
+usage(char *prog_name)
+{
+ fprintf(stderr, "Usage: %s [-vv]\n", prog_name);
+
+ exit(EXIT_FAILURE);
+}
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-08-31 11:18:02 UTC (rev 364)
+++ redbutton-author/trunk/parser.c.header 2007-08-31 13:44:42 UTC (rev 365)
@@ -8,8 +8,7 @@
void
yyerror(const char *str)
{
-// fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
-printf("Error: %s at line %d\n", str, yylineno);
+ fprintf(stderr, "Error: %s at line %d\n", str, yylineno);
}
int
@@ -27,7 +26,7 @@
if(next_token() != INTEGER)
yyerror("Expecting INTEGER");
-printf("<INTEGER value=%s/>\n", token_text());
+ verbose("<INTEGER value=%s/>\n", token_text());
return;
}
@@ -37,7 +36,7 @@
if(next_token() != BOOLEAN)
yyerror("Expecting BOOLEAN");
-printf("<BOOLEAN value=%s/>\n", token_text());
+ verbose("<BOOLEAN value=%s/>\n", token_text());
return;
}
@@ -48,7 +47,7 @@
if(next_token() != STRING)
yyerror("Expecting STRING");
-printf("<STRING value=%s/>\n", token_text());
+ verbose("<STRING value=%s/>\n", token_text());
return;
}
@@ -59,7 +58,7 @@
if(next_token() != QPRINTABLE)
yyerror("Expecting QPRINTABLE");
-printf("<QPRINTABLE value=%s/>\n", token_text());
+ verbose("<QPRINTABLE value=%s/>\n", token_text());
return;
}
@@ -70,7 +69,7 @@
if(next_token() != BASE64)
yyerror("Expecting BASE64");
-printf("<BASE64 value=%s/>\n", token_text());
+ verbose("<BASE64 value=%s/>\n", token_text());
return;
}
@@ -81,8 +80,11 @@
if(next_token() != Null)
yyerror("Expecting Null");
-printf("<Null/>\n");
+ verbose("<Null/>\n");
return;
}
+/*
+ * auto-generated parser functions follow
+ */
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-08-31 11:18:02 UTC (rev 364)
+++ redbutton-author/trunk/parser.h.header 2007-08-31 13:44:42 UTC (rev 365)
@@ -14,3 +14,5 @@
void parse_error(const char *, ...);
+void verbose(const char *, ...);
+void vverbose(const char *, ...);
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-08-31 11:18:02 UTC (rev 364)
+++ redbutton-author/trunk/parser.l.footer 2007-08-31 13:44:42 UTC (rev 365)
@@ -7,7 +7,8 @@
{
token_t tok = yylex();
-printf("peek: '%s'\n", yytext);
+ vverbose("peek: '%s'\n", yytext);
+
/* return it to the input stream */
yyless(0);
@@ -26,10 +27,11 @@
token_t
next_token(void)
{
-// return yylex();
-token_t tok = yylex();
-printf("next: '%s'\n", yytext);
-return tok;
+ token_t tok = yylex();
+
+ vverbose("next: '%s'\n", yytext);
+
+ return tok;
}
char *
@@ -49,7 +51,7 @@
va_start(ap, fmt);
if(vasprintf(&err, fmt, ap) < 0)
{
- fprintf(stderr, "Out of memory or illegal format string");
+ fprintf(stderr, "Out of memory or illegal format string '%s'", fmt);
exit(EXIT_FAILURE);
}
va_end(ap);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-08-31 14:56:28
|
Revision: 368
http://redbutton.svn.sourceforge.net/redbutton/?rev=368&view=rev
Author: skilvington
Date: 2007-08-31 07:56:23 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
don't have to cat input files into mhegc anymore
Modified Paths:
--------------
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.h.header
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/mhegc.c 2007-08-31 14:56:23 UTC (rev 368)
@@ -52,7 +52,13 @@
}
}
- if(optind != argc)
+ /*
+ * a single param is the name of a source file
+ * default is to read from stdin
+ */
+ if(optind == argc - 1)
+ set_input_file(argv[optind]);
+ else if(optind != argc)
usage(prog_name);
parse_InterchangedObject(&state);
@@ -100,7 +106,7 @@
void
usage(char *prog_name)
{
- fprintf(stderr, "Usage: %s [-vv]\n", prog_name);
+ fprintf(stderr, "Usage: %s [-vv] [<input_file>]\n", prog_name);
exit(EXIT_FAILURE);
}
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/parser.h.header 2007-08-31 14:56:23 UTC (rev 368)
@@ -7,6 +7,8 @@
struct state { int dummy; };
typedef int token_t;
+void set_input_file(char *);
+
token_t peek_token(void);
void expect_token(token_t, char *);
token_t next_token(void);
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/parser.l.footer 2007-08-31 14:56:23 UTC (rev 368)
@@ -1,6 +1,18 @@
. return INVALID;
%%
+void
+set_input_file(char *src_name)
+{
+ if((yyin = fopen(src_name, "r")) == NULL)
+ {
+ fprintf(stderr, "Unable to read %s: %s\n", src_name, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ return;
+}
+
/* don't use #define in case they are macros too */
token_t
peek_token(void)
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-08-31 14:29:38 UTC (rev 367)
+++ redbutton-author/trunk/parser.l.header 2007-08-31 14:56:23 UTC (rev 368)
@@ -1,6 +1,8 @@
%{
#include <stdio.h>
#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
#include "parser.h"
#include "tokens.h"
extern int yylineno;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-10 16:10:11
|
Revision: 372
http://redbutton.svn.sourceforge.net/redbutton/?rev=372&view=rev
Author: skilvington
Date: 2007-09-10 09:10:10 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
build a tree of ASN1 objects
Modified Paths:
--------------
redbutton-author/trunk/ccc.y
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-09-10 15:31:01 UTC (rev 371)
+++ redbutton-author/trunk/ccc.y 2007-09-10 16:10:10 UTC (rev 372)
@@ -366,10 +366,10 @@
unsigned int enum_val;
/* prototype for the parse_Xxx function */
- buf_append(&state.parse_hdr, "void parse_%s(struct state *);\n", name);
+ buf_append(&state.parse_hdr, "void parse_%s(struct node *);\n", name);
/* C code for the parse_Xxx functions */
- buf_append(&state.parse_fns, "void parse_%s(struct state *state)\n{\n", name);
+ buf_append(&state.parse_fns, "void parse_%s(struct node *parent)\n{\n", name);
buf_append(&state.parse_fns, "\ttoken_t next;\n\n");
buf_append(&state.parse_fns, "\tverbose(\"<%s>\\n\");\n\n", name);
@@ -405,7 +405,7 @@
{
buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
- buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
buf_append(&state.parse_fns, "\telse\n");
buf_append(&state.parse_fns, "\t\tparse_error(\"Expecting %s\");\n", item->name);
}
@@ -413,14 +413,14 @@
{
buf_append(&state.parse_fns, "\t/* [%s] */\n", item->name);
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
- buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
}
else if(item->type == IT_ONEORMORE)
{
buf_append(&state.parse_fns, "\t/* %s+ */\n", item->name);
buf_append(&state.parse_fns, "\twhile(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t{\n");
- buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
buf_append(&state.parse_fns, "\t\tnext = peek_token();\n");
buf_append(&state.parse_fns, "\t}\n");
}
@@ -472,7 +472,7 @@
if(item->type == IT_IDENTIFIER)
{
buf_append(&state.parse_fns, "if(is_%s(next))\n", item->name);
- buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
}
else if(item->type == IT_LITERAL)
{
@@ -481,10 +481,10 @@
if(asn1type(name) != ASN1TYPE_ENUMERATED)
fatal("literal but not enum");
buf_append(&state.parse_fns, "if(is_%s(next))\n", tok_name);
- buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", tok_name);
+ buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", tok_name);
/* create a parse_Xxx function for the enum value */
- buf_append(&state.parse_enum_hdr, "void parse_%s(struct state *);\n", tok_name);
- buf_append(&state.parse_enum_fns, "void parse_%s(struct state *state)\n{\n", tok_name);
+ buf_append(&state.parse_enum_hdr, "void parse_%s(struct node *);\n", tok_name);
+ buf_append(&state.parse_enum_fns, "void parse_%s(struct node *parent)\n{\n", tok_name);
buf_append(&state.parse_enum_fns, "\texpect_token(%s, %s);\n", tok_name, item->name);
buf_append(&state.parse_enum_fns, "\n\tverbose(\"<ENUM name=\\\"\"%s\"\\\" value=%u/>\\n\");\n", item->name, enum_val);
buf_append(&state.parse_enum_fns, "\n\treturn;\n}\n\n");
@@ -526,7 +526,7 @@
fatal("SET but not Identifier or Optional");
buf_append(&state.parse_fns, "\t\t/* %s */\n", item->name);
buf_append(&state.parse_fns, "\t\tif(is_%s(next))\n\t\t{\n", item->name);
- buf_append(&state.parse_fns, "\t\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parse_fns, "\t\t\tparse_%s(parent);\n", item->name);
buf_append(&state.parse_fns, "\t\t\tcontinue;\n\t\t}\n");
item = item->next;
}
@@ -568,7 +568,7 @@
{
buf_append(&state.parse_fns, "\tnext = peek_token();\n");
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
- buf_append(&state.parse_fns, "\t\tparse_%s(state);\n", item->name);
+ buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
if(item->type != IT_OPTIONAL)
{
buf_append(&state.parse_fns, "\telse\n");
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-10 15:31:01 UTC (rev 371)
+++ redbutton-author/trunk/mhegc.c 2007-09-10 16:10:10 UTC (rev 372)
@@ -36,7 +36,7 @@
{
char *prog_name = argv[0];
int arg;
- struct state state;
+ struct node asn1obj;
while((arg = getopt(argc, argv, "v")) != EOF)
{
@@ -61,7 +61,7 @@
else if(optind != argc)
usage(prog_name);
- parse_InterchangedObject(&state);
+ parse_InterchangedObject(&asn1obj);
if(next_token())
parse_error("Unexpected text after InterchangedObject");
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-10 15:31:01 UTC (rev 371)
+++ redbutton-author/trunk/parser.c.header 2007-09-10 16:10:10 UTC (rev 372)
@@ -21,20 +21,20 @@
* parser functions for the predefined types
*/
-void parse_INTEGER(struct state *state)
+void parse_INTEGER(struct node *parent)
{
if(next_token() != INTEGER)
- yyerror("Expecting INTEGER");
+ parse_error("Unexpected token '%s'; expecting an integer", token_text());
verbose("<INTEGER value=%s/>\n", token_text());
return;
}
-void parse_BOOLEAN(struct state *state)
+void parse_BOOLEAN(struct node *parent)
{
if(next_token() != BOOLEAN)
- yyerror("Expecting BOOLEAN");
+ parse_error("Unexpected token '%s'; expecting 'true' or 'false'", token_text());
verbose("<BOOLEAN value=%s/>\n", token_text());
@@ -42,10 +42,10 @@
}
-void parse_STRING(struct state *state)
+void parse_STRING(struct node *parent)
{
if(next_token() != STRING)
- yyerror("Expecting STRING");
+ parse_error("Unexpected token '%s'; expecting \"STRING\"", token_text());
verbose("<STRING value=%s/>\n", token_text());
@@ -53,10 +53,10 @@
}
-void parse_QPRINTABLE(struct state *state)
+void parse_QPRINTABLE(struct node *parent)
{
if(next_token() != QPRINTABLE)
- yyerror("Expecting QPRINTABLE");
+ parse_error("Unexpected token '%s'; expecting 'QPRINTABLE'", token_text());
verbose("<QPRINTABLE value=%s/>\n", token_text());
@@ -64,10 +64,10 @@
}
-void parse_BASE64(struct state *state)
+void parse_BASE64(struct node *parent)
{
if(next_token() != BASE64)
- yyerror("Expecting BASE64");
+ parse_error("Unexpected token '%s'; expecting `BASE64`", token_text());
verbose("<BASE64 value=%s/>\n", token_text());
@@ -75,10 +75,10 @@
}
-void parse_Null(struct state *state)
+void parse_Null(struct node *parent)
{
if(next_token() != Null)
- yyerror("Expecting Null");
+ parse_error("Unexpected token '%s'; expecting 'Null'", token_text());
verbose("<Null/>\n");
@@ -88,3 +88,4 @@
/*
* auto-generated parser functions follow
*/
+
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-10 15:31:01 UTC (rev 371)
+++ redbutton-author/trunk/parser.h.header 2007-09-10 16:10:10 UTC (rev 372)
@@ -4,7 +4,21 @@
#include <stdio.h>
#include <stdbool.h>
-struct state { int dummy; };
+/* the parser builds a tree of ASN1 types */
+struct node
+{
+ /* DER type */
+ unsigned int asn1tag; /* ASN1 tag number */
+ unsigned int asn1class; /* UNIVERSAL/CONTEXT/etc */
+ /* DER value */
+ unsigned int length; /* length of the value data */
+ unsigned char *value; /* DER encoded value */
+ /* a tree of nodes */
+ struct node *children; /* NULL if not a constructed type */
+ struct node *siblings; /* linked list of children */
+};
+
+/* lexer token type */
typedef int token_t;
void set_input_file(char *);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-12 13:17:23
|
Revision: 376
http://redbutton.svn.sourceforge.net/redbutton/?rev=376&view=rev
Author: skilvington
Date: 2007-09-12 06:17:20 -0700 (Wed, 12 Sep 2007)
Log Message:
-----------
start to use the ASN1 tags
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-12 13:11:33 UTC (rev 375)
+++ redbutton-author/trunk/asn1tag.h 2007-09-12 13:17:20 UTC (rev 376)
@@ -25,7 +25,7 @@
#define ASN1TAG_RemoteProgram 10
#define ASN1TAG_InterchangedProgram 11
#define ASN1TAG_Palette 12
-#define ASN1TAG_Font 13
+#define ASN1TAG_FontClass 13
#define ASN1TAG_CursorShape 14
#define ASN1TAG_BooleanVariable 15
#define ASN1TAG_IntegerVariable 16
@@ -53,7 +53,7 @@
#define ASN1TAG_BackgroundColour 39
#define ASN1TAG_TextContentHook 40
#define ASN1TAG_TextColour 41
-#define ASN1TAG_Font 42
+#define ASN1TAG_FontBody 42
#define ASN1TAG_FontAttributes 43
#define ASN1TAG_InterchangedProgramContentHook 44
#define ASN1TAG_StreamContentHook 45
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-12 13:11:33 UTC (rev 375)
+++ redbutton-author/trunk/mhegc.c 2007-09-12 13:17:20 UTC (rev 376)
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
+#include <strings.h>
#include "parser.h"
@@ -61,6 +62,8 @@
else if(optind != argc)
usage(prog_name);
+ bzero(&asn1obj, sizeof(struct node));
+ asn1obj.asn1tag = ASN1TAG_SYNTHETIC;
parse_InterchangedObject(&asn1obj);
if(next_token())
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-12 13:11:33 UTC (rev 375)
+++ redbutton-author/trunk/parser.h.header 2007-09-12 13:17:20 UTC (rev 376)
@@ -4,6 +4,8 @@
#include <stdio.h>
#include <stdbool.h>
+#include "asn1tag.h"
+
/* the parser builds a tree of ASN1 types */
struct node
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-13 11:45:57
|
Revision: 377
http://redbutton.svn.sourceforge.net/redbutton/?rev=377&view=rev
Author: skilvington
Date: 2007-09-13 04:45:48 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
we will need to store the ASN1 tag class after all
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-12 13:17:20 UTC (rev 376)
+++ redbutton-author/trunk/asn1tag.h 2007-09-13 11:45:48 UTC (rev 377)
@@ -5,6 +5,12 @@
#ifndef __ASN1TAG_H__
#define __ASN1TAG_H__
+/* tag classes */
+#define ASN1CLASS_UNIVERSAL 0x00
+#define ASN1CLASS_APPLICATION 0x40
+#define ASN1CLASS_CONTEXT 0x80
+#define ASN1CLASS_PRIVATE 0xc0
+
/*
* a synthetic object created as a result of the grammar definition
* eg TextBody etc
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-12 13:17:20 UTC (rev 376)
+++ redbutton-author/trunk/parser.c.header 2007-09-13 11:45:48 UTC (rev 377)
@@ -2,7 +2,12 @@
#include "parser.h"
#include "tokens.h"
+#include "utils.h"
+/*
+ * lexer functions we need to provide
+ */
+
int yylineno = 1;
void
@@ -18,6 +23,39 @@
}
/*
+ * parser helper functions
+ */
+
+struct node *
+add_child(struct node *parent, unsigned int asn1tag, unsigned int asn1class)
+{
+ struct node *child = safe_malloc(sizeof(struct node));
+
+ child->asn1tag = asn1tag;
+ child->asn1class = asn1class;
+ child->length = 0;
+ child->value = NULL;
+ child->children = NULL;
+ child->siblings = NULL;
+
+ /* is it the first */
+ if(parent->children == NULL)
+ {
+ parent->children = child;
+ }
+ else
+ {
+ /* add it to the end of the siblings list */
+ struct node *sib = parent->children;
+ while(sib->siblings != NULL)
+ sib = sib->siblings;
+ sib->siblings = child;
+ }
+
+ return child;
+}
+
+/*
* parser functions for the predefined types
*/
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-12 13:17:20 UTC (rev 376)
+++ redbutton-author/trunk/parser.h.header 2007-09-13 11:45:48 UTC (rev 377)
@@ -11,6 +11,7 @@
{
/* DER type */
unsigned int asn1tag; /* ASN1 tag number */
+ unsigned int asn1class; /* only UNIVERSAL or CONTEXT */
/* DER value */
unsigned int length; /* length of the value data */
unsigned char *value; /* DER encoded value */
@@ -19,9 +20,13 @@
struct node *siblings; /* linked list of children */
};
+/* add a child to a node */
+struct node *add_child(struct node *, unsigned int, unsigned int);
+
/* lexer token type */
typedef int token_t;
+/* lexer functions */
void set_input_file(char *);
token_t peek_token(void);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-13 13:16:06
|
Revision: 378
http://redbutton.svn.sourceforge.net/redbutton/?rev=378&view=rev
Author: skilvington
Date: 2007-09-13 06:16:03 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
build part of the ASN1 object tree
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-13 11:45:48 UTC (rev 377)
+++ redbutton-author/trunk/asn1tag.h 2007-09-13 13:16:03 UTC (rev 378)
@@ -16,43 +16,72 @@
* eg TextBody etc
* don't output this object, just output its children
*/
-#define ASN1TAG_SYNTHETIC 99999
+#define ASN1TAG_SYNTHETIC 10000
+/* the tag for CHOICE types is determined by which choice we choose */
+#define ASN1TAG_CHOICE 10001
+/* ENUMERATED types are encoded as INTEGERs */
+#define ASN1TAG_ENUMERATED 10002
+/* abstract types */
+#define ASN1TAG_Group ASN1TAG_SYNTHETIC
+#define ASN1TAG_Ingredient ASN1TAG_SYNTHETIC
+#define ASN1TAG_Program ASN1TAG_SYNTHETIC
+#define ASN1TAG_Variable ASN1TAG_SYNTHETIC
+#define ASN1TAG_Visible ASN1TAG_SYNTHETIC
+#define ASN1TAG_Interactible ASN1TAG_SYNTHETIC
+#define ASN1TAG_Button ASN1TAG_SYNTHETIC
+
+/* tokens synthesised by the grammar */
+#define ASN1TAG_TokenGroupBody ASN1TAG_SYNTHETIC
+#define ASN1TAG_LineArtBody ASN1TAG_SYNTHETIC
+#define ASN1TAG_TextBody ASN1TAG_SYNTHETIC
+#define ASN1TAG_PushButtonBody ASN1TAG_SYNTHETIC
+
+/* TODO: need to look at these - have different values in different places */
+#define ASN1TAG_FIXME 99999
+#define ASN1TAG_ReferencedContent ASN1TAG_FIXME
+#define ASN1TAG_XYPosition ASN1TAG_FIXME
+#define ASN1TAG_Point ASN1TAG_FIXME
+/* TODO: as above, but only used once */
+#define ASN1TAG_Rational ASN1TAG_FIXME
+#define ASN1TAG_ExternalReference ASN1TAG_FIXME
+#define ASN1TAG_NewReferencedContent ASN1TAG_FIXME
+
/* ASN1 tags */
-#define ASN1TAG_Application 0
-#define ASN1TAG_Scene 1
+#define ASN1TAG_ApplicationClass 0
+#define ASN1TAG_SceneClass 1
#define ASN1TAG_StandardIdentifier 2
#define ASN1TAG_StandardVersion 3
#define ASN1TAG_ObjectInformation 4
#define ASN1TAG_OnStartUp 5
#define ASN1TAG_OnCloseDown 6
#define ASN1TAG_OriginalGroupCachePriority 7
-#define ASN1TAG_ResidentProgram 9
-#define ASN1TAG_RemoteProgram 10
-#define ASN1TAG_InterchangedProgram 11
-#define ASN1TAG_Palette 12
+#define ASN1TAG_ResidentProgramClass 9
+#define ASN1TAG_RemoteProgramClass 10
+#define ASN1TAG_InterchangedProgramClass 11
+#define ASN1TAG_PaletteClass 12
#define ASN1TAG_FontClass 13
-#define ASN1TAG_CursorShape 14
-#define ASN1TAG_BooleanVariable 15
-#define ASN1TAG_IntegerVariable 16
-#define ASN1TAG_OctetStringVariable 17
-#define ASN1TAG_ObjectRefVariable 18
-#define ASN1TAG_ContentRefVariable 19
-#define ASN1TAG_Link 20
-#define ASN1TAG_Stream 21
-#define ASN1TAG_Bitmap 22
-#define ASN1TAG_LineArt 23
-#define ASN1TAG_DynamicLineArt 24
-#define ASN1TAG_Rectangle 25
-#define ASN1TAG_Hotspot 26
-#define ASN1TAG_SwitchButton 27
-#define ASN1TAG_PushButton 28
-#define ASN1TAG_Text 29
-#define ASN1TAG_EntryField 30
-#define ASN1TAG_HyperText 31
-#define ASN1TAG_Slider 32
-#define ASN1TAG_TokenGroup 33
-#define ASN1TAG_ListGroup 34
+#define ASN1TAG_CursorShapeClass 14
+#define ASN1TAG_BooleanVariableClass 15
+#define ASN1TAG_IntegerVariableClass 16
+#define ASN1TAG_OctetStringVariableClass 17
+#define ASN1TAG_ObjectRefVariableClass 18
+#define ASN1TAG_ContentRefVariableClass 19
+#define ASN1TAG_LinkClass 20
+#define ASN1TAG_StreamClass 21
+#define ASN1TAG_BitmapClass 22
+#define ASN1TAG_LineArtClass 23
+#define ASN1TAG_DynamicLineArtClass 24
+#define ASN1TAG_RectangleClass 25
+#define ASN1TAG_HotspotClass 26
+#define ASN1TAG_SwitchButtonClass 27
+#define ASN1TAG_PushButtonClass 28
+#define ASN1TAG_TextClass 29
+#define ASN1TAG_EntryFieldClass 30
+#define ASN1TAG_HyperTextClass 31
+#define ASN1TAG_SliderClass 32
+#define ASN1TAG_TokenGroupClass 33
+#define ASN1TAG_ListGroupClass 34
#define ASN1TAG_OnSpawnCloseDown 35
#define ASN1TAG_OnRestart 36
#define ASN1TAG_CharacterSet 38
@@ -72,6 +101,7 @@
#define ASN1TAG_SceneCoordinateSystem 52
#define ASN1TAG_AspectRatio 53
#define ASN1TAG_MovingCursor 54
+#define ASN1TAG_NextScene 55
#define ASN1TAG_InitiallyActive 56
#define ASN1TAG_ContentHook 57
#define ASN1TAG_OriginalContent 58
@@ -86,9 +116,13 @@
#define ASN1TAG_OriginalValue 67
#define ASN1TAG_ObjectReference 68
#define ASN1TAG_ContentReference 69
+// TODO 70
+#define ASN1TAG_TokenGroupItem 71
+// TODO 72
+// TODO 73
#define ASN1TAG_WrapAround 74
#define ASN1TAG_MultipleSelection 75
-#define ASN1TAG_OriginalBoxSize 76
+#define ASN1TAG_BoxSize 76
#define ASN1TAG_OriginalPosition 77
#define ASN1TAG_OriginalPaletteRef 78
#define ASN1TAG_Tiling 79
@@ -103,10 +137,12 @@
#define ASN1TAG_LineOrientation 89
#define ASN1TAG_StartCorner 90
#define ASN1TAG_TextWrapping 91
+// TODO 92
#define ASN1TAG_Storage 93
-#define ASN1TAG_Audio 95
-#define ASN1TAG_Video 96
-#define ASN1TAG_Rtgraphics 97
+// TODO 94
+#define ASN1TAG_AudioClass 95
+#define ASN1TAG_VideoClass 96
+#define ASN1TAG_RTGraphicsClass 97
#define ASN1TAG_ComponentTag 98
#define ASN1TAG_OriginalVolume 99
#define ASN1TAG_Termination 100
@@ -245,9 +281,10 @@
#define ASN1TAG_NewFontReference 233
#define ASN1TAG_NewContentSize 234
#define ASN1TAG_NewContentCachePriority 235
+// TODO 236
#define ASN1TAG_SetBackgroundColour 237
#define ASN1TAG_SetCellPosition 238
-#define ASN1TAG_SetInputRegister 239
+#define ASN1TAG_SetInputReg 239
#define ASN1TAG_SetTextColour 240
#define ASN1TAG_SetFontAttributes 241
#define ASN1TAG_SetVideoDecodeOffset 242
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-09-13 11:45:48 UTC (rev 377)
+++ redbutton-author/trunk/ccc.y 2007-09-13 13:16:03 UTC (rev 378)
@@ -457,6 +457,12 @@
/* assert */
if(state.and_items)
fatal("CHOICE or ENUMERATED type, but and_items set");
+ /* add a child ASN1 object */
+ if(asn1type(name) == ASN1TYPE_CHOICE)
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_CHOICE, 0);\n\n");
+ else
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_ENUMERATED, 0);\n\n");
+ /* peek at the next token */
buf_append(&state.parse_fns, "\tnext = peek_token();\n\n");
buf_append(&state.parse_fns, "\t/* CHOICE or ENUMERATED */\n");
/* enum values all start at 1 and are listed in order in the grammar */
@@ -505,6 +511,8 @@
/* assert */
if(!state.and_items)
fatal("SET but and_items not set");
+ /* add a child ASN1 object */
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
/* eat any literals at the start */
item = state.items;
while(item && item->type == IT_LITERAL)
@@ -549,6 +557,8 @@
/* assert */
if(!state.and_items)
fatal("SEQUENCE but and_items not set");
+ /* add a child ASN1 object */
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
buf_append(&state.parse_fns, "\t/* SEQUENCE */\n");
item = state.items;
for(item=state.items; item; item=item->next)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-13 16:12:28
|
Revision: 379
http://redbutton.svn.sourceforge.net/redbutton/?rev=379&view=rev
Author: skilvington
Date: 2007-09-13 09:12:21 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
build more ASN1 types
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-13 13:16:03 UTC (rev 378)
+++ redbutton-author/trunk/asn1tag.h 2007-09-13 16:12:21 UTC (rev 379)
@@ -30,6 +30,7 @@
#define ASN1TAG_Visible ASN1TAG_SYNTHETIC
#define ASN1TAG_Interactible ASN1TAG_SYNTHETIC
#define ASN1TAG_Button ASN1TAG_SYNTHETIC
+#define ASN1TAG_TokenManager ASN1TAG_SYNTHETIC
/* tokens synthesised by the grammar */
#define ASN1TAG_TokenGroupBody ASN1TAG_SYNTHETIC
@@ -37,8 +38,10 @@
#define ASN1TAG_TextBody ASN1TAG_SYNTHETIC
#define ASN1TAG_PushButtonBody ASN1TAG_SYNTHETIC
+
+/* start TODO */
+#define ASN1TAG_FIXME 99999
/* TODO: need to look at these - have different values in different places */
-#define ASN1TAG_FIXME 99999
#define ASN1TAG_ReferencedContent ASN1TAG_FIXME
#define ASN1TAG_XYPosition ASN1TAG_FIXME
#define ASN1TAG_Point ASN1TAG_FIXME
@@ -46,6 +49,18 @@
#define ASN1TAG_Rational ASN1TAG_FIXME
#define ASN1TAG_ExternalReference ASN1TAG_FIXME
#define ASN1TAG_NewReferencedContent ASN1TAG_FIXME
+#define ASN1TAG_NextScene ASN1TAG_FIXME
+#define ASN1TAG_TokenGroupItem ASN1TAG_FIXME
+/* TODO: an INTEGER ie class=UNIVERSAL, tag=2 */
+#define ASN1TAG_Movement ASN1TAG_FIXME
+/* TODO: sequences */
+#define ASN1TAG_ActionSlots ASN1TAG_FIXME
+#define ASN1TAG_InVariables ASN1TAG_FIXME
+#define ASN1TAG_OutVariables ASN1TAG_FIXME
+#define ASN1TAG_ActionClass ASN1TAG_FIXME
+#define ASN1TAG_Parameters ASN1TAG_FIXME
+#define ASN1TAG_PointList ASN1TAG_FIXME
+/* end TODO */
/* ASN1 tags */
#define ASN1TAG_ApplicationClass 0
@@ -56,6 +71,7 @@
#define ASN1TAG_OnStartUp 5
#define ASN1TAG_OnCloseDown 6
#define ASN1TAG_OriginalGroupCachePriority 7
+#define ASN1TAG_Items 8
#define ASN1TAG_ResidentProgramClass 9
#define ASN1TAG_RemoteProgramClass 10
#define ASN1TAG_InterchangedProgramClass 11
@@ -84,6 +100,7 @@
#define ASN1TAG_ListGroupClass 34
#define ASN1TAG_OnSpawnCloseDown 35
#define ASN1TAG_OnRestart 36
+#define ASN1TAG_DefaultAttributes 37
#define ASN1TAG_CharacterSet 38
#define ASN1TAG_BackgroundColour 39
#define ASN1TAG_TextContentHook 40
@@ -101,7 +118,7 @@
#define ASN1TAG_SceneCoordinateSystem 52
#define ASN1TAG_AspectRatio 53
#define ASN1TAG_MovingCursor 54
-#define ASN1TAG_NextScene 55
+#define ASN1TAG_NextScenes 55
#define ASN1TAG_InitiallyActive 56
#define ASN1TAG_ContentHook 57
#define ASN1TAG_OriginalContent 58
@@ -116,10 +133,10 @@
#define ASN1TAG_OriginalValue 67
#define ASN1TAG_ObjectReference 68
#define ASN1TAG_ContentReference 69
-// TODO 70
-#define ASN1TAG_TokenGroupItem 71
-// TODO 72
-// TODO 73
+#define ASN1TAG_MovementTable 70
+#define ASN1TAG_TokenGroupItems 71
+#define ASN1TAG_NoTokenActionSlots 72
+#define ASN1TAG_Positions 73
#define ASN1TAG_WrapAround 74
#define ASN1TAG_MultipleSelection 75
#define ASN1TAG_BoxSize 76
@@ -137,7 +154,7 @@
#define ASN1TAG_LineOrientation 89
#define ASN1TAG_StartCorner 90
#define ASN1TAG_TextWrapping 91
-// TODO 92
+#define ASN1TAG_Multiplex 92
#define ASN1TAG_Storage 93
// TODO 94
#define ASN1TAG_AudioClass 95
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-09-13 13:16:03 UTC (rev 378)
+++ redbutton-author/trunk/ccc.y 2007-09-13 16:12:21 UTC (rev 379)
@@ -403,6 +403,11 @@
buf_append(&state.parse_fns, "\tnext = peek_token();\n\n");
if(item->type == IT_IDENTIFIER)
{
+#if 0
+ /* add a child ASN1 object */
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ /* read the item */
+#endif
buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
@@ -411,12 +416,18 @@
}
else if(item->type == IT_OPTIONAL)
{
+ /* add a child ASN1 object */
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ /* read the item */
buf_append(&state.parse_fns, "\t/* [%s] */\n", item->name);
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
}
else if(item->type == IT_ONEORMORE)
{
+ /* add a child ASN1 object */
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ /* read the item */
buf_append(&state.parse_fns, "\t/* %s+ */\n", item->name);
buf_append(&state.parse_fns, "\twhile(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t{\n");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-14 15:06:34
|
Revision: 380
http://redbutton.svn.sourceforge.net/redbutton/?rev=380&view=rev
Author: skilvington
Date: 2007-09-14 08:06:29 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
combine the tag and the class into a single value for the parser
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-13 16:12:21 UTC (rev 379)
+++ redbutton-author/trunk/asn1tag.h 2007-09-14 15:06:29 UTC (rev 380)
@@ -23,43 +23,43 @@
#define ASN1TAG_ENUMERATED 10002
/* abstract types */
-#define ASN1TAG_Group ASN1TAG_SYNTHETIC
-#define ASN1TAG_Ingredient ASN1TAG_SYNTHETIC
-#define ASN1TAG_Program ASN1TAG_SYNTHETIC
-#define ASN1TAG_Variable ASN1TAG_SYNTHETIC
-#define ASN1TAG_Visible ASN1TAG_SYNTHETIC
-#define ASN1TAG_Interactible ASN1TAG_SYNTHETIC
-#define ASN1TAG_Button ASN1TAG_SYNTHETIC
-#define ASN1TAG_TokenManager ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Root ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Group ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Ingredient ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Program ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Variable ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Visible ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Interactible ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Button ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TokenManager ASN1TAG_SYNTHETIC
/* tokens synthesised by the grammar */
-#define ASN1TAG_TokenGroupBody ASN1TAG_SYNTHETIC
-#define ASN1TAG_LineArtBody ASN1TAG_SYNTHETIC
-#define ASN1TAG_TextBody ASN1TAG_SYNTHETIC
-#define ASN1TAG_PushButtonBody ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TokenGroupBody ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LineArtBody ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TextBody ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_PushButtonBody ASN1TAG_SYNTHETIC
-
/* start TODO */
#define ASN1TAG_FIXME 99999
/* TODO: need to look at these - have different values in different places */
-#define ASN1TAG_ReferencedContent ASN1TAG_FIXME
-#define ASN1TAG_XYPosition ASN1TAG_FIXME
-#define ASN1TAG_Point ASN1TAG_FIXME
+#define ASN1TAGCLASS_ReferencedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_XYPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_Point ASN1TAG_FIXME
/* TODO: as above, but only used once */
-#define ASN1TAG_Rational ASN1TAG_FIXME
-#define ASN1TAG_ExternalReference ASN1TAG_FIXME
-#define ASN1TAG_NewReferencedContent ASN1TAG_FIXME
-#define ASN1TAG_NextScene ASN1TAG_FIXME
-#define ASN1TAG_TokenGroupItem ASN1TAG_FIXME
+#define ASN1TAGCLASS_Rational ASN1TAG_FIXME
+#define ASN1TAGCLASS_ExternalReference ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_NextScene ASN1TAG_FIXME
+#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_FIXME
/* TODO: an INTEGER ie class=UNIVERSAL, tag=2 */
-#define ASN1TAG_Movement ASN1TAG_FIXME
+#define ASN1TAGCLASS_Movement ASN1TAG_FIXME
/* TODO: sequences */
-#define ASN1TAG_ActionSlots ASN1TAG_FIXME
-#define ASN1TAG_InVariables ASN1TAG_FIXME
-#define ASN1TAG_OutVariables ASN1TAG_FIXME
-#define ASN1TAG_ActionClass ASN1TAG_FIXME
-#define ASN1TAG_Parameters ASN1TAG_FIXME
-#define ASN1TAG_PointList ASN1TAG_FIXME
+#define ASN1TAGCLASS_ActionSlots ASN1TAG_FIXME
+#define ASN1TAGCLASS_InVariables ASN1TAG_FIXME
+#define ASN1TAGCLASS_OutVariables ASN1TAG_FIXME
+#define ASN1TAGCLASS_ActionClass ASN1TAG_FIXME
+#define ASN1TAGCLASS_Parameters ASN1TAG_FIXME
+#define ASN1TAGCLASS_PointList ASN1TAG_FIXME
/* end TODO */
/* ASN1 tags */
@@ -156,7 +156,7 @@
#define ASN1TAG_TextWrapping 91
#define ASN1TAG_Multiplex 92
#define ASN1TAG_Storage 93
-// TODO 94
+#define ASN1TAG_Looping 94
#define ASN1TAG_AudioClass 95
#define ASN1TAG_VideoClass 96
#define ASN1TAG_RTGraphicsClass 97
@@ -298,7 +298,7 @@
#define ASN1TAG_NewFontReference 233
#define ASN1TAG_NewContentSize 234
#define ASN1TAG_NewContentCachePriority 235
-// TODO 236
+#define ASN1TAG_IndirectReference 236
#define ASN1TAG_SetBackgroundColour 237
#define ASN1TAG_SetCellPosition 238
#define ASN1TAG_SetInputReg 239
@@ -312,5 +312,255 @@
#define ASN1TAG_GetBitmapDecodeOffset 247
#define ASN1TAG_SetSliderParameters 248
+/* tag and class in a single value */
+#define ASN1TAGCLASS_ApplicationClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ApplicationClass)
+#define ASN1TAGCLASS_SceneClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SceneClass)
+#define ASN1TAGCLASS_StandardIdentifier ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_StandardIdentifier)
+#define ASN1TAGCLASS_StandardVersion ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_StandardVersion)
+#define ASN1TAGCLASS_ObjectInformation ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ObjectInformation)
+#define ASN1TAGCLASS_OnStartUp ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OnStartUp)
+#define ASN1TAGCLASS_OnCloseDown ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OnCloseDown)
+#define ASN1TAGCLASS_OriginalGroupCachePriority ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalGroupCachePriority)
+#define ASN1TAGCLASS_Items ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Items)
+#define ASN1TAGCLASS_ResidentProgramClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ResidentProgramClass)
+#define ASN1TAGCLASS_RemoteProgramClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_RemoteProgramClass)
+#define ASN1TAGCLASS_InterchangedProgramClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InterchangedProgramClass)
+#define ASN1TAGCLASS_PaletteClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_PaletteClass)
+#define ASN1TAGCLASS_FontClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_FontClass)
+#define ASN1TAGCLASS_CursorShapeClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_CursorShapeClass)
+#define ASN1TAGCLASS_BooleanVariableClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BooleanVariableClass)
+#define ASN1TAGCLASS_IntegerVariableClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_IntegerVariableClass)
+#define ASN1TAGCLASS_OctetStringVariableClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OctetStringVariableClass)
+#define ASN1TAGCLASS_ObjectRefVariableClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ObjectRefVariableClass)
+#define ASN1TAGCLASS_ContentRefVariableClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentRefVariableClass)
+#define ASN1TAGCLASS_LinkClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_LinkClass)
+#define ASN1TAGCLASS_StreamClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_StreamClass)
+#define ASN1TAGCLASS_BitmapClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BitmapClass)
+#define ASN1TAGCLASS_LineArtClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_LineArtClass)
+#define ASN1TAGCLASS_DynamicLineArtClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DynamicLineArtClass)
+#define ASN1TAGCLASS_RectangleClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_RectangleClass)
+#define ASN1TAGCLASS_HotspotClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_HotspotClass)
+#define ASN1TAGCLASS_SwitchButtonClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SwitchButtonClass)
+#define ASN1TAGCLASS_PushButtonClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_PushButtonClass)
+#define ASN1TAGCLASS_TextClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TextClass)
+#define ASN1TAGCLASS_EntryFieldClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_EntryFieldClass)
+#define ASN1TAGCLASS_HyperTextClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_HyperTextClass)
+#define ASN1TAGCLASS_SliderClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SliderClass)
+#define ASN1TAGCLASS_TokenGroupClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TokenGroupClass)
+#define ASN1TAGCLASS_ListGroupClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ListGroupClass)
+#define ASN1TAGCLASS_OnSpawnCloseDown ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OnSpawnCloseDown)
+#define ASN1TAGCLASS_OnRestart ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OnRestart)
+#define ASN1TAGCLASS_DefaultAttributes ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DefaultAttributes)
+#define ASN1TAGCLASS_CharacterSet ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_CharacterSet)
+#define ASN1TAGCLASS_BackgroundColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BackgroundColour)
+#define ASN1TAGCLASS_TextContentHook ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TextContentHook)
+#define ASN1TAGCLASS_TextColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TextColour)
+#define ASN1TAGCLASS_FontBody ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_FontBody)
+#define ASN1TAGCLASS_FontAttributes ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_FontAttributes)
+#define ASN1TAGCLASS_InterchangedProgramContentHook ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InterchangedProgramContentHook)
+#define ASN1TAGCLASS_StreamContentHook ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_StreamContentHook)
+#define ASN1TAGCLASS_BitmapContentHook ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BitmapContentHook)
+#define ASN1TAGCLASS_LineArtContentHook ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_LineArtContentHook)
+#define ASN1TAGCLASS_ButtonRefColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ButtonRefColour)
+#define ASN1TAGCLASS_HighlightRefColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_HighlightRefColour)
+#define ASN1TAGCLASS_SliderRefColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SliderRefColour)
+#define ASN1TAGCLASS_InputEventRegister ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InputEventRegister)
+#define ASN1TAGCLASS_SceneCoordinateSystem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SceneCoordinateSystem)
+#define ASN1TAGCLASS_AspectRatio ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_AspectRatio)
+#define ASN1TAGCLASS_MovingCursor ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MovingCursor)
+#define ASN1TAGCLASS_NextScenes ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NextScenes)
+#define ASN1TAGCLASS_InitiallyActive ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InitiallyActive)
+#define ASN1TAGCLASS_ContentHook ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentHook)
+#define ASN1TAGCLASS_OriginalContent ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalContent)
+#define ASN1TAGCLASS_Shared ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Shared)
+#define ASN1TAGCLASS_ContentSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentSize)
+#define ASN1TAGCLASS_ContentCachePriority ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentCachePriority)
+#define ASN1TAGCLASS_LinkCondition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_LinkCondition)
+#define ASN1TAGCLASS_LinkEffect ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_LinkEffect)
+#define ASN1TAGCLASS_Name ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Name)
+#define ASN1TAGCLASS_InitiallyAvailable ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InitiallyAvailable)
+#define ASN1TAGCLASS_ProgramConnectionTag ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ProgramConnectionTag)
+#define ASN1TAGCLASS_OriginalValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalValue)
+#define ASN1TAGCLASS_ObjectReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ObjectReference)
+#define ASN1TAGCLASS_ContentReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ContentReference)
+#define ASN1TAGCLASS_MovementTable ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MovementTable)
+#define ASN1TAGCLASS_TokenGroupItems ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TokenGroupItems)
+#define ASN1TAGCLASS_NoTokenActionSlots ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NoTokenActionSlots)
+#define ASN1TAGCLASS_Positions ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Positions)
+#define ASN1TAGCLASS_WrapAround ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_WrapAround)
+#define ASN1TAGCLASS_MultipleSelection ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MultipleSelection)
+#define ASN1TAGCLASS_BoxSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BoxSize)
+#define ASN1TAGCLASS_OriginalPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalPosition)
+#define ASN1TAGCLASS_OriginalPaletteRef ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalPaletteRef)
+#define ASN1TAGCLASS_Tiling ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Tiling)
+#define ASN1TAGCLASS_OriginalTransparency ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalTransparency)
+#define ASN1TAGCLASS_BorderedBoundingBox ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BorderedBoundingBox)
+#define ASN1TAGCLASS_OriginalLineWidth ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalLineWidth)
+#define ASN1TAGCLASS_OriginalRefLineColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalRefLineColour)
+#define ASN1TAGCLASS_OriginalRefFillColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalRefFillColour)
+#define ASN1TAGCLASS_OriginalFont ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalFont)
+#define ASN1TAGCLASS_HorizontalJustification ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_HorizontalJustification)
+#define ASN1TAGCLASS_VerticalJustification ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_VerticalJustification)
+#define ASN1TAGCLASS_LineOrientation ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_LineOrientation)
+#define ASN1TAGCLASS_StartCorner ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_StartCorner)
+#define ASN1TAGCLASS_TextWrapping ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TextWrapping)
+#define ASN1TAGCLASS_Multiplex ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Multiplex)
+#define ASN1TAGCLASS_Storage ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Storage)
+#define ASN1TAGCLASS_Looping ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Looping)
+#define ASN1TAGCLASS_AudioClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_AudioClass)
+#define ASN1TAGCLASS_VideoClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_VideoClass)
+#define ASN1TAGCLASS_RTGraphicsClass ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_RTGraphicsClass)
+#define ASN1TAGCLASS_ComponentTag ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ComponentTag)
+#define ASN1TAGCLASS_OriginalVolume ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalVolume)
+#define ASN1TAGCLASS_Termination ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Termination)
+#define ASN1TAGCLASS_EngineResp ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_EngineResp)
+#define ASN1TAGCLASS_Orientation ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Orientation)
+#define ASN1TAGCLASS_MaxValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MaxValue)
+#define ASN1TAGCLASS_MinValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MinValue)
+#define ASN1TAGCLASS_InitialValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InitialValue)
+#define ASN1TAGCLASS_InitialPortion ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InitialPortion)
+#define ASN1TAGCLASS_StepSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_StepSize)
+#define ASN1TAGCLASS_SliderStyle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SliderStyle)
+#define ASN1TAGCLASS_InputType ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_InputType)
+#define ASN1TAGCLASS_CharList ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_CharList)
+#define ASN1TAGCLASS_ObscuredInput ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ObscuredInput)
+#define ASN1TAGCLASS_MaxLength ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MaxLength)
+#define ASN1TAGCLASS_OriginalLabel ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalLabel)
+#define ASN1TAGCLASS_ButtonStyle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ButtonStyle)
+#define ASN1TAGCLASS_Activate ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Activate)
+#define ASN1TAGCLASS_Add ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Add)
+#define ASN1TAGCLASS_AddItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_AddItem)
+#define ASN1TAGCLASS_Append ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Append)
+#define ASN1TAGCLASS_BringToFront ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BringToFront)
+#define ASN1TAGCLASS_Call ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Call)
+#define ASN1TAGCLASS_CallActionSlot ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_CallActionSlot)
+#define ASN1TAGCLASS_Clear ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Clear)
+#define ASN1TAGCLASS_Clone ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Clone)
+#define ASN1TAGCLASS_CloseConnection ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_CloseConnection)
+#define ASN1TAGCLASS_Deactivate ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Deactivate)
+#define ASN1TAGCLASS_DelItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DelItem)
+#define ASN1TAGCLASS_Deselect ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Deselect)
+#define ASN1TAGCLASS_DeselectItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DeselectItem)
+#define ASN1TAGCLASS_Divide ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Divide)
+#define ASN1TAGCLASS_DrawArc ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DrawArc)
+#define ASN1TAGCLASS_DrawLine ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DrawLine)
+#define ASN1TAGCLASS_DrawOval ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DrawOval)
+#define ASN1TAGCLASS_DrawPolygon ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DrawPolygon)
+#define ASN1TAGCLASS_DrawPolyline ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DrawPolyline)
+#define ASN1TAGCLASS_DrawRectangle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DrawRectangle)
+#define ASN1TAGCLASS_DrawSector ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_DrawSector)
+#define ASN1TAGCLASS_Fork ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Fork)
+#define ASN1TAGCLASS_GetAvailabilityStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetAvailabilityStatus)
+#define ASN1TAGCLASS_GetBoxSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetBoxSize)
+#define ASN1TAGCLASS_GetCellItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetCellItem)
+#define ASN1TAGCLASS_GetCursorPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetCursorPosition)
+#define ASN1TAGCLASS_GetEngineSupport ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetEngineSupport)
+#define ASN1TAGCLASS_GetEntryPoint ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetEntryPoint)
+#define ASN1TAGCLASS_GetFillColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetFillColour)
+#define ASN1TAGCLASS_GetFirstItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetFirstItem)
+#define ASN1TAGCLASS_GetHighlightStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetHighlightStatus)
+#define ASN1TAGCLASS_GetInteractionStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetInteractionStatus)
+#define ASN1TAGCLASS_GetItemStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetItemStatus)
+#define ASN1TAGCLASS_GetLabel ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetLabel)
+#define ASN1TAGCLASS_GetLastAnchorFired ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetLastAnchorFired)
+#define ASN1TAGCLASS_GetLineColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetLineColour)
+#define ASN1TAGCLASS_GetLineStyle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetLineStyle)
+#define ASN1TAGCLASS_GetLineWidth ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetLineWidth)
+#define ASN1TAGCLASS_GetListItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetListItem)
+#define ASN1TAGCLASS_GetListSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetListSize)
+#define ASN1TAGCLASS_GetOverwriteMode ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetOverwriteMode)
+#define ASN1TAGCLASS_GetPortion ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetPortion)
+#define ASN1TAGCLASS_GetPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetPosition)
+#define ASN1TAGCLASS_GetRunningStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetRunningStatus)
+#define ASN1TAGCLASS_GetSelectionStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetSelectionStatus)
+#define ASN1TAGCLASS_GetSliderValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetSliderValue)
+#define ASN1TAGCLASS_GetTextContent ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetTextContent)
+#define ASN1TAGCLASS_GetTextData ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetTextData)
+#define ASN1TAGCLASS_GetTokenPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetTokenPosition)
+#define ASN1TAGCLASS_GetVolume ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetVolume)
+#define ASN1TAGCLASS_Launch ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Launch)
+#define ASN1TAGCLASS_LockScreen ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_LockScreen)
+#define ASN1TAGCLASS_Modulo ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Modulo)
+#define ASN1TAGCLASS_Move ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Move)
+#define ASN1TAGCLASS_MoveTo ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MoveTo)
+#define ASN1TAGCLASS_Multiply ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Multiply)
+#define ASN1TAGCLASS_OpenConnection ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OpenConnection)
+#define ASN1TAGCLASS_Preload ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Preload)
+#define ASN1TAGCLASS_PutBefore ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_PutBefore)
+#define ASN1TAGCLASS_PutBehind ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_PutBehind)
+#define ASN1TAGCLASS_Quit ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Quit)
+#define ASN1TAGCLASS_ReadPersistent ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ReadPersistent)
+#define ASN1TAGCLASS_Run ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Run)
+#define ASN1TAGCLASS_ScaleBitmap ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ScaleBitmap)
+#define ASN1TAGCLASS_ScaleVideo ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ScaleVideo)
+#define ASN1TAGCLASS_ScrollItems ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ScrollItems)
+#define ASN1TAGCLASS_Select ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Select)
+#define ASN1TAGCLASS_SelectItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SelectItem)
+#define ASN1TAGCLASS_SendEvent ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SendEvent)
+#define ASN1TAGCLASS_SendToBack ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SendToBack)
+#define ASN1TAGCLASS_SetBoxSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetBoxSize)
+#define ASN1TAGCLASS_SetCachePriority ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetCachePriority)
+#define ASN1TAGCLASS_SetCounterEndPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetCounterEndPosition)
+#define ASN1TAGCLASS_SetCounterPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetCounterPosition)
+#define ASN1TAGCLASS_SetCounterTrigger ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetCounterTrigger)
+#define ASN1TAGCLASS_SetCursorPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetCursorPosition)
+#define ASN1TAGCLASS_SetCursorShape ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetCursorShape)
+#define ASN1TAGCLASS_SetData ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetData)
+#define ASN1TAGCLASS_SetEntryPoint ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetEntryPoint)
+#define ASN1TAGCLASS_SetFillColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetFillColour)
+#define ASN1TAGCLASS_SetFirstItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetFirstItem)
+#define ASN1TAGCLASS_SetFontRef ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetFontRef)
+#define ASN1TAGCLASS_SetHighlightStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetHighlightStatus)
+#define ASN1TAGCLASS_SetInteractionStatus ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetInteractionStatus)
+#define ASN1TAGCLASS_SetLabel ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetLabel)
+#define ASN1TAGCLASS_SetLineColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetLineColour)
+#define ASN1TAGCLASS_SetLineStyle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetLineStyle)
+#define ASN1TAGCLASS_SetLineWidth ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetLineWidth)
+#define ASN1TAGCLASS_SetOverwriteMode ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetOverwriteMode)
+#define ASN1TAGCLASS_SetPaletteRef ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetPaletteRef)
+#define ASN1TAGCLASS_SetPortion ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetPortion)
+#define ASN1TAGCLASS_SetPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetPosition)
+#define ASN1TAGCLASS_SetSliderValue ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetSliderValue)
+#define ASN1TAGCLASS_SetSpeed ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetSpeed)
+#define ASN1TAGCLASS_SetTimer ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetTimer)
+#define ASN1TAGCLASS_SetTransparency ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetTransparency)
+#define ASN1TAGCLASS_SetVariable ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetVariable)
+#define ASN1TAGCLASS_SetVolume ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetVolume)
+#define ASN1TAGCLASS_Spawn ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Spawn)
+#define ASN1TAGCLASS_Step ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Step)
+#define ASN1TAGCLASS_Stop ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Stop)
+#define ASN1TAGCLASS_StorePersistent ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_StorePersistent)
+#define ASN1TAGCLASS_Subtract ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Subtract)
+#define ASN1TAGCLASS_TestVariable ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TestVariable)
+#define ASN1TAGCLASS_Toggle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Toggle)
+#define ASN1TAGCLASS_ToggleItem ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_ToggleItem)
+#define ASN1TAGCLASS_TransitionTo ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_TransitionTo)
+#define ASN1TAGCLASS_Unload ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Unload)
+#define ASN1TAGCLASS_UnlockScreen ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_UnlockScreen)
+#define ASN1TAGCLASS_NewGenericBoolean ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericBoolean)
+#define ASN1TAGCLASS_NewGenericInteger ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericInteger)
+#define ASN1TAGCLASS_NewGenericOctetstring ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericOctetstring)
+#define ASN1TAGCLASS_NewGenericObjectReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericObjectReference)
+#define ASN1TAGCLASS_NewGenericContentReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewGenericContentReference)
+#define ASN1TAGCLASS_NewColourIndex ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewColourIndex)
+#define ASN1TAGCLASS_NewAbsoluteColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewAbsoluteColour)
+#define ASN1TAGCLASS_NewFontName ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewFontName)
+#define ASN1TAGCLASS_NewFontReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewFontReference)
+#define ASN1TAGCLASS_NewContentSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewContentSize)
+#define ASN1TAGCLASS_NewContentCachePriority ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_NewContentCachePriority)
+#define ASN1TAGCLASS_IndirectReference ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_IndirectReference)
+#define ASN1TAGCLASS_SetBackgroundColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetBackgroundColour)
+#define ASN1TAGCLASS_SetCellPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetCellPosition)
+#define ASN1TAGCLASS_SetInputReg ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetInputReg)
+#define ASN1TAGCLASS_SetTextColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetTextColour)
+#define ASN1TAGCLASS_SetFontAttributes ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetFontAttributes)
+#define ASN1TAGCLASS_SetVideoDecodeOffset ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetVideoDecodeOffset)
+#define ASN1TAGCLASS_GetVideoDecodeOffset ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetVideoDecodeOffset)
+#define ASN1TAGCLASS_GetFocusPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetFocusPosition)
+#define ASN1TAGCLASS_SetFocusPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetFocusPosition)
+#define ASN1TAGCLASS_SetBitmapDecodeOffset ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetBitmapDecodeOffset)
+#define ASN1TAGCLASS_GetBitmapDecodeOffset ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetBitmapDecodeOffset)
+#define ASN1TAGCLASS_SetSliderParameters ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetSliderParameters)
+
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-09-13 16:12:21 UTC (rev 379)
+++ redbutton-author/trunk/ccc.y 2007-09-14 15:06:29 UTC (rev 380)
@@ -405,7 +405,7 @@
{
#if 0
/* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
/* read the item */
#endif
buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
@@ -417,7 +417,7 @@
else if(item->type == IT_OPTIONAL)
{
/* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
/* read the item */
buf_append(&state.parse_fns, "\t/* [%s] */\n", item->name);
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
@@ -426,7 +426,7 @@
else if(item->type == IT_ONEORMORE)
{
/* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
/* read the item */
buf_append(&state.parse_fns, "\t/* %s+ */\n", item->name);
buf_append(&state.parse_fns, "\twhile(is_%s(next))\n", item->name);
@@ -470,9 +470,9 @@
fatal("CHOICE or ENUMERATED type, but and_items set");
/* add a child ASN1 object */
if(asn1type(name) == ASN1TYPE_CHOICE)
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_CHOICE, 0);\n\n");
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_CHOICE);\n\n");
else
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_ENUMERATED, 0);\n\n");
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_ENUMERATED);\n\n");
/* peek at the next token */
buf_append(&state.parse_fns, "\tnext = peek_token();\n\n");
buf_append(&state.parse_fns, "\t/* CHOICE or ENUMERATED */\n");
@@ -523,7 +523,7 @@
if(!state.and_items)
fatal("SET but and_items not set");
/* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
/* eat any literals at the start */
item = state.items;
while(item && item->type == IT_LITERAL)
@@ -569,7 +569,7 @@
if(!state.and_items)
fatal("SEQUENCE but and_items not set");
/* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAG_%s, ASN1CLASS_CONTEXT);\n\n", name);
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
buf_append(&state.parse_fns, "\t/* SEQUENCE */\n");
item = state.items;
for(item=state.items; item; item=item->next)
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-13 16:12:21 UTC (rev 379)
+++ redbutton-author/trunk/parser.c.header 2007-09-14 15:06:29 UTC (rev 380)
@@ -27,12 +27,13 @@
*/
struct node *
-add_child(struct node *parent, unsigned int asn1tag, unsigned int asn1class)
+add_child(struct node *parent, uint32_t asn1tagclass)
{
struct node *child = safe_malloc(sizeof(struct node));
- child->asn1tag = asn1tag;
- child->asn1class = asn1class;
+ /* class is in the top 8 bits, tag is the bottom 24 bits */
+ child->asn1tag = asn1tagclass & 0xffffff;
+ child->asn1class = (asn1tagclass >> 24) & 0xff;
child->length = 0;
child->value = NULL;
child->children = NULL;
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-13 16:12:21 UTC (rev...
[truncated message content] |
|
From: <ski...@us...> - 2007-09-14 16:12:24
|
Revision: 381
http://redbutton.svn.sourceforge.net/redbutton/?rev=381&view=rev
Author: skilvington
Date: 2007-09-14 09:12:22 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
build the whole ASN1 object tree
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/ccc.y
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
Added Paths:
-----------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/der_encode.h
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-09-14 15:06:29 UTC (rev 380)
+++ redbutton-author/trunk/Makefile 2007-09-14 16:12:22 UTC (rev 381)
@@ -14,6 +14,8 @@
OBJS= mhegc.o \
lex.parser.o \
parser.o \
+ der_encode.o \
+ asn1tag.o \
utils.o
TARDIR=`basename ${PWD}`
Added: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c (rev 0)
+++ redbutton-author/trunk/asn1tag.c 2007-09-14 16:12:22 UTC (rev 381)
@@ -0,0 +1,17 @@
+/*
+ * asn1tag.c
+ */
+
+#include "asn1tag.h"
+
+char *
+asn1class_name(unsigned int c)
+{
+ if(c == ASN1CLASS_UNIVERSAL) return "UNIVERSAL";
+ if(c == ASN1CLASS_APPLICATION) return "APPLICATION";
+ if(c == ASN1CLASS_CONTEXT) return "CONTEXT";
+ if(c == ASN1CLASS_PRIVATE) return "PRIVATE";
+
+ return "ILLEGAL-ASN1-CLASS-NUMBER";
+}
+
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-14 15:06:29 UTC (rev 380)
+++ redbutton-author/trunk/asn1tag.h 2007-09-14 16:12:22 UTC (rev 381)
@@ -11,6 +11,8 @@
#define ASN1CLASS_CONTEXT 0x80
#define ASN1CLASS_PRIVATE 0xc0
+char *asn1class_name(unsigned int);
+
/*
* a synthetic object created as a result of the grammar definition
* eg TextBody etc
@@ -34,35 +36,13 @@
#define ASN1TAGCLASS_TokenManager ASN1TAG_SYNTHETIC
/* tokens synthesised by the grammar */
+#define ASN1TAGCLASS_ObjectIdentifier ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_TokenGroupBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_LineArtBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_TextBody ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_PushButtonBody ASN1TAG_SYNTHETIC
-/* start TODO */
-#define ASN1TAG_FIXME 99999
-/* TODO: need to look at these - have different values in different places */
-#define ASN1TAGCLASS_ReferencedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_XYPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_Point ASN1TAG_FIXME
-/* TODO: as above, but only used once */
-#define ASN1TAGCLASS_Rational ASN1TAG_FIXME
-#define ASN1TAGCLASS_ExternalReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_NextScene ASN1TAG_FIXME
-#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_FIXME
-/* TODO: an INTEGER ie class=UNIVERSAL, tag=2 */
-#define ASN1TAGCLASS_Movement ASN1TAG_FIXME
-/* TODO: sequences */
-#define ASN1TAGCLASS_ActionSlots ASN1TAG_FIXME
-#define ASN1TAGCLASS_InVariables ASN1TAG_FIXME
-#define ASN1TAGCLASS_OutVariables ASN1TAG_FIXME
-#define ASN1TAGCLASS_ActionClass ASN1TAG_FIXME
-#define ASN1TAGCLASS_Parameters ASN1TAG_FIXME
-#define ASN1TAGCLASS_PointList ASN1TAG_FIXME
-/* end TODO */
-
-/* ASN1 tags */
+/* ASN1 CONTEXT tag values */
#define ASN1TAG_ApplicationClass 0
#define ASN1TAG_SceneClass 1
#define ASN1TAG_StandardIdentifier 2
@@ -562,5 +542,183 @@
#define ASN1TAGCLASS_GetBitmapDecodeOffset ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_GetBitmapDecodeOffset)
#define ASN1TAGCLASS_SetSliderParameters ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_SetSliderParameters)
+/* ASN1 UNIVERSAL tag values */
+#define ASN1TAG_BOOLEAN 1
+#define ASN1TAG_INTEGER 2
+#define ASN1TAG_OctetString 4
+/* and with the class included */
+#define ASN1TAGCLASS_BOOLEAN ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_BOOLEAN)
+#define ASN1TAGCLASS_INTEGER ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_INTEGER)
+#define ASN1TAGCLASS_OctetString ((ASN1CLASS_UNIVERSAL << 24) | ASN1TAG_OctetString)
+
+/* UNIVERSAL ASN1 types in the grammar */
+#define ASN1TAGCLASS_JointIsoItuIdentifier ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_MHEGStandardIdentifier ASN1TAGCLASS_INTEGER
+
+/* start TODO */
+#define ASN1TAG_FIXME 99999
+#define ASN1TAGCLASS_Font ASN1TAG_FIXME
+#define ASN1TAGCLASS_DirectFont ASN1TAG_FIXME
+#define ASN1TAGCLASS_IndirectFont ASN1TAG_FIXME
+#define ASN1TAGCLASS_XScene ASN1TAG_FIXME
+#define ASN1TAGCLASS_YScene ASN1TAG_FIXME
+#define ASN1TAGCLASS_Width ASN1TAG_FIXME
+#define ASN1TAGCLASS_Height ASN1TAG_FIXME
+#define ASN1TAGCLASS_SceneRef ASN1TAG_FIXME
+#define ASN1TAGCLASS_SceneWeight ASN1TAG_FIXME
+#define ASN1TAGCLASS_IncludedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_EventSource ASN1TAG_FIXME
+#define ASN1TAGCLASS_EventType ASN1TAG_FIXME
+#define ASN1TAGCLASS_EventData ASN1TAG_FIXME
+#define ASN1TAGCLASS_ObjectReferenceValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_Presentable ASN1TAG_FIXME
+#define ASN1TAGCLASS_TargetElement ASN1TAG_FIXME
+#define ASN1TAGCLASS_AVisible ASN1TAG_FIXME
+#define ASN1TAGCLASS_Position ASN1TAG_FIXME
+#define ASN1TAGCLASS_OriginalBoxSize ASN1TAG_FIXME
+#define ASN1TAGCLASS_XLength ASN1TAG_FIXME
+#define ASN1TAGCLASS_YLength ASN1TAG_FIXME
+#define ASN1TAGCLASS_OriginalLineStyle ASN1TAG_FIXME
+#define ASN1TAGCLASS_AbsoluteTime ASN1TAG_FIXME
+#define ASN1TAGCLASS_Address ASN1TAG_FIXME
+#define ASN1TAGCLASS_Answer ASN1TAG_FIXME
+#define ASN1TAGCLASS_AppendValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_ArcAngle ASN1TAG_FIXME
+#define ASN1TAGCLASS_AvailabilityStatusVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_CallSucceeded ASN1TAG_FIXME
+#define ASN1TAGCLASS_CellIndex ASN1TAG_FIXME
+#define ASN1TAGCLASS_CloneRefVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_ConnectionTag ASN1TAG_FIXME
+#define ASN1TAGCLASS_Denominator ASN1TAG_FIXME
+#define ASN1TAGCLASS_EllipseHeight ASN1TAG_FIXME
+#define ASN1TAGCLASS_EllipseWidth ASN1TAG_FIXME
+#define ASN1TAGCLASS_EmulatedEventSource ASN1TAG_FIXME
+#define ASN1TAGCLASS_EmulatedEventType ASN1TAG_FIXME
+#define ASN1TAGCLASS_EntryPointVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_ForkSucceeded ASN1TAG_FIXME
+#define ASN1TAGCLASS_Feature ASN1TAG_FIXME
+#define ASN1TAGCLASS_FillColourVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_FirstItemVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_HighlightStatusVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_Index ASN1TAG_FIXME
+#define ASN1TAGCLASS_InFileName ASN1TAG_FIXME
+#define ASN1TAGCLASS_InteractionStatusVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_ItemIndex ASN1TAG_FIXME
+#define ASN1TAGCLASS_ItemRefVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_ItemStatusVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_ItemsToScroll ASN1TAG_FIXME
+#define ASN1TAGCLASS_LabelVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_LastAnchorFiredVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_LineColourVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_LineStyleVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_LineWidthVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_MovementIdentifier ASN1TAG_FIXME
+#define ASN1TAGCLASS_NbOfSteps ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewCachePriority ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewCounterEndPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewCounterPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewCounterValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewCursorShape ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewEntryPoint ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewFirstItem ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewGenericOctetString ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewHighlightStatus ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewIncludedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewInteractionStatus ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewLabel ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewLineStyle ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewLineWidth ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewOverwriteMode ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewPaletteRef ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewPortion ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewSliderValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewSpeed ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewTransparency ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewVolume ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewXPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewYPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_Numerator ASN1TAG_FIXME
+#define ASN1TAGCLASS_OpenSucceeded ASN1TAG_FIXME
+#define ASN1TAGCLASS_Operator ASN1TAG_FIXME
+#define ASN1TAGCLASS_OutFileName ASN1TAG_FIXME
+#define ASN1TAGCLASS_OverwriteModeVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_PortionVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_Protocol ASN1TAG_FIXME
+#define ASN1TAGCLASS_ReadSucceeded ASN1TAG_FIXME
+#define ASN1TAGCLASS_ReferenceVisible ASN1TAG_FIXME
+#define ASN1TAGCLASS_RunningStatusVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_SelectionStatusVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_SizeVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_SliderValueVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_StartAngle ASN1TAG_FIXME
+#define ASN1TAGCLASS_StoreSucceeded ASN1TAG_FIXME
+#define ASN1TAGCLASS_Target ASN1TAG_FIXME
+#define ASN1TAGCLASS_TextContentVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_TextDataVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_TimerID ASN1TAG_FIXME
+#define ASN1TAGCLASS_TimerValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_TokenPositionVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_TransitionEffect ASN1TAG_FIXME
+#define ASN1TAGCLASS_TriggerIdentifier ASN1TAG_FIXME
+#define ASN1TAGCLASS_Value ASN1TAG_FIXME
+#define ASN1TAGCLASS_VisibleReference ASN1TAG_FIXME
+#define ASN1TAGCLASS_VolumeVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_X ASN1TAG_FIXME
+#define ASN1TAGCLASS_X1 ASN1TAG_FIXME
+#define ASN1TAGCLASS_X2 ASN1TAG_FIXME
+#define ASN1TAGCLASS_XBoxSizeVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_XCursor ASN1TAG_FIXME
+#define ASN1TAGCLASS_XNewBoxSize ASN1TAG_FIXME
+#define ASN1TAGCLASS_XOut ASN1TAG_FIXME
+#define ASN1TAGCLASS_XPositionVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_XScale ASN1TAG_FIXME
+#define ASN1TAGCLASS_Y ASN1TAG_FIXME
+#define ASN1TAGCLASS_Y1 ASN1TAG_FIXME
+#define ASN1TAGCLASS_Y2 ASN1TAG_FIXME
+#define ASN1TAGCLASS_YBoxSizeVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_YCursor ASN1TAG_FIXME
+#define ASN1TAGCLASS_YNewBoxSize ASN1TAG_FIXME
+#define ASN1TAGCLASS_YOut ASN1TAG_FIXME
+#define ASN1TAGCLASS_YPositionVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_YScale ASN1TAG_FIXME
+#define ASN1TAGCLASS_XOffsetVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_YOffsetVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewXOffset ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewYOffset ASN1TAG_FIXME
+#define ASN1TAGCLASS_FocusPositionVar ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewFocusPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewMinValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewMaxValue ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewStepSize ASN1TAG_FIXME
+#define ASN1TAGCLASS_InternalReference ASN1TAG_FIXME
+#define ASN1TAGCLASS_GroupIdentifier ASN1TAG_FIXME
+#define ASN1TAGCLASS_ObjectNumber ASN1TAG_FIXME
+#define ASN1TAGCLASS_DirectReference ASN1TAG_FIXME
+#define ASN1TAGCLASS_ColourIndex ASN1TAG_FIXME
+#define ASN1TAGCLASS_AbsoluteColour ASN1TAG_FIXME
+#define ASN1TAGCLASS_XPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_YPosition ASN1TAG_FIXME
+/* TODO: need to look at these - have different values in different places */
+#define ASN1TAGCLASS_ReferencedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_XYPosition ASN1TAG_FIXME
+#define ASN1TAGCLASS_Point ASN1TAG_FIXME
+/* TODO: as above, but only used once */
+#define ASN1TAGCLASS_Rational ASN1TAG_FIXME
+#define ASN1TAGCLASS_ExternalReference ASN1TAG_FIXME
+#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_NextScene ASN1TAG_FIXME
+#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_FIXME
+/* TODO: an INTEGER ie class=UNIVERSAL, tag=2 */
+#define ASN1TAGCLASS_Movement ASN1TAG_FIXME
+/* TODO: sequences */
+#define ASN1TAGCLASS_ActionSlots ASN1TAG_FIXME
+#define ASN1TAGCLASS_InVariables ASN1TAG_FIXME
+#define ASN1TAGCLASS_OutVariables ASN1TAG_FIXME
+#define ASN1TAGCLASS_ActionClass ASN1TAG_FIXME
+#define ASN1TAGCLASS_Parameters ASN1TAG_FIXME
+#define ASN1TAGCLASS_PointList ASN1TAG_FIXME
+/* end TODO */
+
#endif /* __ASN1TAG_H__ */
Modified: redbutton-author/trunk/ccc.y
===================================================================
--- redbutton-author/trunk/ccc.y 2007-09-14 15:06:29 UTC (rev 380)
+++ redbutton-author/trunk/ccc.y 2007-09-14 16:12:22 UTC (rev 381)
@@ -389,6 +389,8 @@
/* a single item (not including literals) */
if(nitems == 1)
{
+ /* add a child ASN1 object */
+ buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
/* eat literals at the start */
item = state.items;
while(item && item->type == IT_LITERAL)
@@ -403,11 +405,6 @@
buf_append(&state.parse_fns, "\tnext = peek_token();\n\n");
if(item->type == IT_IDENTIFIER)
{
-#if 0
- /* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
- /* read the item */
-#endif
buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
@@ -416,18 +413,12 @@
}
else if(item->type == IT_OPTIONAL)
{
- /* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
- /* read the item */
buf_append(&state.parse_fns, "\t/* [%s] */\n", item->name);
buf_append(&state.parse_fns, "\tif(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t\tparse_%s(parent);\n", item->name);
}
else if(item->type == IT_ONEORMORE)
{
- /* add a child ASN1 object */
- buf_append(&state.parse_fns, "\tparent = add_child(parent, ASN1TAGCLASS_%s);\n\n", name);
- /* read the item */
buf_append(&state.parse_fns, "\t/* %s+ */\n", item->name);
buf_append(&state.parse_fns, "\twhile(is_%s(next))\n", item->name);
buf_append(&state.parse_fns, "\t{\n");
@@ -504,6 +495,7 @@
buf_append(&state.parse_enum_fns, "void parse_%s(struct node *parent)\n{\n", tok_name);
buf_append(&state.parse_enum_fns, "\texpect_token(%s, %s);\n", tok_name, item->name);
buf_append(&state.parse_enum_fns, "\n\tverbose(\"<ENUM name=\\\"\"%s\"\\\" value=%u/>\\n\");\n", item->name, enum_val);
+ buf_append(&state.parse_enum_fns, "\n\tder_encode_INTEGER(&parent->value, &parent->length, %u);\n", enum_val);
buf_append(&state.parse_enum_fns, "\n\treturn;\n}\n\n");
free(tok_name);
enum_val ++;
@@ -557,8 +549,8 @@
while(item && item->type == IT_LITERAL)
{
char *tok_name = unquote(item->name);
- buf_append(&state.parse_fns, "\t/* %s */\n", item->name);
- buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n\n", tok_name, item->name);
+ buf_append(&state.parse_fns, "\n\t/* %s */\n", item->name);
+ buf_append(&state.parse_fns, "\texpect_token(%s, %s);\n", tok_name, item->name);
free(tok_name);
item = item->next;
}
Added: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c (rev 0)
+++ redbutton-author/trunk/der_encode.c 2007-09-14 16:12:22 UTC (rev 381)
@@ -0,0 +1,38 @@
+/*
+ * der_encode.c
+ */
+
+#include <stdbool.h>
+
+#include "utils.h"
+
+void
+der_encode_BOOLEAN(unsigned char **out, unsigned int *len, bool val)
+{
+ /* assert */
+ if(*out != NULL || *len != 0)
+ fatal("der_encode_BOOLEAN: length already %u", *len);
+
+ return;
+}
+
+void
+der_encode_INTEGER(unsigned char **out, unsigned int *len, int val)
+{
+ /* assert */
+ if(*out != NULL || *len != 0)
+ fatal("der_encode_INTEGER: length already %u", *len);
+
+ return;
+}
+
+void
+der_encode_OctetString(unsigned char **out, unsigned int *len, const char *str)
+{
+ /* assert */
+ if(*out != NULL || *len != 0)
+ fatal("der_encode_OctetString: length already %u", *len);
+
+ return;
+}
+
Added: redbutton-author/trunk/der_encode.h
===================================================================
--- redbutton-author/trunk/der_encode.h (rev 0)
+++ redbutton-author/trunk/der_encode.h 2007-09-14 16:12:22 UTC (rev 381)
@@ -0,0 +1,15 @@
+/*
+ * der_encode.h
+ */
+
+#ifndef __DER_ENCODE_H__
+#define __DER_ENCODE_H__
+
+#include <stdbool.h>
+
+void der_encode_BOOLEAN(unsigned char **, unsigned int *, bool);
+void der_encode_INTEGER(unsigned char **, unsigned int *, int);
+void der_encode_OctetString(unsigned char **, unsigned int *, const char *);
+
+#endif /* __DER_ENCODE_H__ */
+
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-14 15:06:29 UTC (rev 380)
+++ redbutton-author/trunk/mhegc.c 2007-09-14 16:12:22 UTC (rev 381)
@@ -27,7 +27,12 @@
#include <strings.h>
#include "parser.h"
+#include "asn1tag.h"
+#include "utils.h"
+void print_node(struct node *, unsigned int);
+void print_indent(unsigned int);
+
void usage(char *);
static int _verbose = 0;
@@ -69,6 +74,16 @@
if(next_token())
parse_error("Unexpected text after InterchangedObject");
+ /* assert */
+ if(asn1obj.siblings != NULL)
+ fatal("Top level object has siblings");
+
+ if(_verbose)
+ {
+ verbose("\nASN1 object tree:\n");
+ print_node(&asn1obj, 0);
+ }
+
return EXIT_SUCCESS;
}
@@ -77,6 +92,39 @@
*/
void
+print_node(struct node *n, unsigned int indent)
+{
+ struct node *kid;
+
+ print_indent(indent);
+ fprintf(stderr, "[%s %d]\n", asn1class_name(n->asn1class), n->asn1tag);
+
+ if(n->children)
+ {
+ print_indent(indent);
+ fprintf(stderr, "{\n");
+ for(kid=n->children; kid; kid=kid->siblings)
+ print_node(kid, indent + 1);
+ print_indent(indent);
+ fprintf(stderr, "}\n");
+ }
+
+ return;
+}
+
+void
+print_indent(unsigned int indent)
+{
+ while(indent > 0)
+ {
+ fprintf(stderr, " ");
+ indent --;
+ }
+
+ return;
+}
+
+void
verbose(const char *fmt, ...)
{
va_list ap;
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-14 15:06:29 UTC (rev 380)
+++ redbutton-author/trunk/parser.c.header 2007-09-14 16:12:22 UTC (rev 381)
@@ -1,7 +1,9 @@
#include <stdio.h>
+#include <string.h>
#include "parser.h"
#include "tokens.h"
+#include "der_encode.h"
#include "utils.h"
/*
@@ -60,27 +62,31 @@
* parser functions for the predefined types
*/
-void parse_INTEGER(struct node *parent)
+void parse_BOOLEAN(struct node *parent)
{
- if(next_token() != INTEGER)
- parse_error("Unexpected token '%s'; expecting an integer", token_text());
+ if(next_token() != BOOLEAN)
+ parse_error("Unexpected token '%s'; expecting 'true' or 'false'", token_text());
- verbose("<INTEGER value=%s/>\n", token_text());
+ verbose("<BOOLEAN value=%s/>\n", token_text());
+ der_encode_BOOLEAN(&parent->value, &parent->length, strcmp(token_text(), "false"));
+
return;
}
-void parse_BOOLEAN(struct node *parent)
+
+void parse_INTEGER(struct node *parent)
{
- if(next_token() != BOOLEAN)
- parse_error("Unexpected token '%s'; expecting 'true' or 'false'", token_text());
+ if(next_token() != INTEGER)
+ parse_error("Unexpected token '%s'; expecting an integer", token_text());
- verbose("<BOOLEAN value=%s/>\n", token_text());
+ verbose("<INTEGER value=%s/>\n", token_text());
+ der_encode_INTEGER(&parent->value, &parent->length, strtol(token_text(), NULL, 0));
+
return;
}
-
void parse_STRING(struct node *parent)
{
if(next_token() != STRING)
@@ -88,6 +94,8 @@
verbose("<STRING value=%s/>\n", token_text());
+ der_encode_OctetString(&parent->value, &parent->length, token_text());
+
return;
}
@@ -99,6 +107,8 @@
verbose("<QPRINTABLE value=%s/>\n", token_text());
+ der_encode_OctetString(&parent->value, &parent->length, token_text());
+
return;
}
@@ -110,6 +120,8 @@
verbose("<BASE64 value=%s/>\n", token_text());
+ der_encode_OctetString(&parent->value, &parent->length, token_text());
+
return;
}
@@ -121,6 +133,10 @@
verbose("<Null/>\n");
+ /* assert */
+ if(parent->length != 0)
+ fatal("Null: length=%u", parent->length);
+
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-17 09:09:54
|
Revision: 386
http://redbutton.svn.sourceforge.net/redbutton/?rev=386&view=rev
Author: skilvington
Date: 2007-09-17 02:09:47 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
ignore // comments
Modified Paths:
--------------
redbutton-author/trunk/parser.l.footer
redbutton-author/trunk/parser.l.header
redbutton-author/trunk/tokens.h.header
Modified: redbutton-author/trunk/parser.l.footer
===================================================================
--- redbutton-author/trunk/parser.l.footer 2007-09-16 20:24:33 UTC (rev 385)
+++ redbutton-author/trunk/parser.l.footer 2007-09-17 09:09:47 UTC (rev 386)
@@ -19,6 +19,12 @@
{
token_t tok = yylex();
+ while(tok == COMMENT)
+ {
+ vverbose("peek: skip comment '%s'\n", yytext);
+ tok = yylex();
+ }
+
vverbose("peek: '%s'\n", yytext);
/* return it to the input stream */
@@ -41,6 +47,12 @@
{
token_t tok = yylex();
+ while(tok == COMMENT)
+ {
+ vverbose("next: skip comment '%s'\n", yytext);
+ tok = yylex();
+ }
+
vverbose("next: '%s'\n", yytext);
return tok;
Modified: redbutton-author/trunk/parser.l.header
===================================================================
--- redbutton-author/trunk/parser.l.header 2007-09-16 20:24:33 UTC (rev 385)
+++ redbutton-author/trunk/parser.l.header 2007-09-17 09:09:47 UTC (rev 386)
@@ -8,6 +8,7 @@
extern int yylineno;
%}
%%
+\/\/[^\n\r\f]* return COMMENT;
([-0-9][0-9]*)|(0x[0-9a-f]+) return INTEGER;
true|false return BOOLEAN;
\"((\\\")|[^"])*\" return STRING;
Modified: redbutton-author/trunk/tokens.h.header
===================================================================
--- redbutton-author/trunk/tokens.h.header 2007-09-16 20:24:33 UTC (rev 385)
+++ redbutton-author/trunk/tokens.h.header 2007-09-17 09:09:47 UTC (rev 386)
@@ -1,8 +1,9 @@
#define END_OF_SRC 0 /* must be 0 */
-#define INVALID 1
-#define INTEGER 2
-#define BOOLEAN 3
-#define STRING 4
-#define QPRINTABLE 5
-#define BASE64 6
-#define Null 7
+#define COMMENT 1
+#define INVALID 2
+#define INTEGER 3
+#define BOOLEAN 4
+#define STRING 5
+#define QPRINTABLE 6
+#define BASE64 7
+#define Null 8
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-17 09:14:03
|
Revision: 387
http://redbutton.svn.sourceforge.net/redbutton/?rev=387&view=rev
Author: skilvington
Date: 2007-09-17 02:14:00 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
import hello world example from http://www.digvid.info/mheg5/hello_world.php
Added Paths:
-----------
redbutton-author/trunk/helloworld/
redbutton-author/trunk/helloworld/hello.mhg.txt
redbutton-author/trunk/helloworld/startup.txt
Added: redbutton-author/trunk/helloworld/hello.mhg.txt
===================================================================
--- redbutton-author/trunk/helloworld/hello.mhg.txt (rev 0)
+++ redbutton-author/trunk/helloworld/hello.mhg.txt 2007-09-17 09:14:00 UTC (rev 387)
@@ -0,0 +1,44 @@
+// MHEG5 Hello World scene
+//
+// http://www.digvid.info/mheg5/hello_world.php
+//
+
+{:Scene
+ ( "~/hello.mhg" 0 )
+ :Items
+ (
+ // Declare a background Rectangle that covers the screen.
+ {:Rectangle
+ 1
+ :OrigBoxSize 720 576 // Size of rectangle
+ :OrigPosition 0 0 // Position at top left
+ :OrigRefLineColour '=ff=ff=ff=00' // White
+ :OrigRefFillColour '=ff=ff=ff=00' // White
+ }
+
+ // Place a Text box on the screen
+ {:Text
+ 2
+ :OrigContent "Hello World!" // Text to display
+ :OrigBoxSize 300 50 // Size of text box
+ :OrigPosition 200 100 // X,Y position
+ :FontAttributes "plain.36.42.0" // Use large characters
+ :TextColour '=ff=00=00=00' // Red
+ }
+
+ // Define a Link that triggers when the user presses the Blue key to
+ // Quit the application.
+ {:Link
+ 3
+ :EventSource 0 // Source is this scene
+ :EventType UserInput // Event type that we are looking for
+ :EventData 103 // 103 for the blue key
+ :LinkEffect (
+ :Quit ( ( '~/startup' 0 ) )
+ )
+ }
+ )
+
+ :InputEventReg 3
+ :SceneCS 720 576
+}
Added: redbutton-author/trunk/helloworld/startup.txt
===================================================================
--- redbutton-author/trunk/helloworld/startup.txt (rev 0)
+++ redbutton-author/trunk/helloworld/startup.txt 2007-09-17 09:14:00 UTC (rev 387)
@@ -0,0 +1,25 @@
+// MHEG5 Hello World app
+//
+// http://www.digvid.info/mheg5/hello_world.php
+//
+
+{:Application
+ ( '/startup' 0 ) // Application content reference
+ :Items (
+ {:Link
+ 1
+ :EventSource 0 // Check this application...
+ :EventType IsRunning // ... for the IsRunning event
+ :LinkEffect (
+ // Load the scene
+ :TransitionTo (( '~/hello.mhg' 0 ) )
+ )
+ }
+ )
+ :BackgroundColour '=FF=FF=FF=00' // White
+ :TextCHook 10 // Default text content hook
+ :TextColour '=00=00=00=00' // Black
+ :Font "rec://font/uk1" // Font to use for text rendering
+ :FontAttributes "plain.26.32.0" // Default font attributes
+ :BitmapCHook 4 // Default bitmap content hook
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-17 16:23:20
|
Revision: 388
http://redbutton.svn.sourceforge.net/redbutton/?rev=388&view=rev
Author: skilvington
Date: 2007-09-17 09:23:18 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
generate all the ASN1 tag and class values
Modified Paths:
--------------
redbutton-author/trunk/Makefile
redbutton-author/trunk/asn1tag.h
Modified: redbutton-author/trunk/Makefile
===================================================================
--- redbutton-author/trunk/Makefile 2007-09-17 09:14:00 UTC (rev 387)
+++ redbutton-author/trunk/Makefile 2007-09-17 16:23:18 UTC (rev 388)
@@ -28,7 +28,7 @@
${YACC} -b ccc -d ccc.y
${CC} ${CFLAGS} ${DEFS} -o ccc lex.ccc.c ccc.tab.c asn1type.o
-lex.parser.c parser.c parser.h: parser.l.* parser.c.* parser.h.* tokens.h.* grammar ccc
+lex.parser.c parser.c parser.h: parser.l.* parser.c.* parser.h.* tokens.h.* grammar asn1tag.h ccc
cat grammar | ./ccc -l parser.l -p parser.c -h parser.h -t tokens.h
${LEX} -i -t parser.l > lex.parser.c
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-17 09:14:00 UTC (rev 387)
+++ redbutton-author/trunk/asn1tag.h 2007-09-17 16:23:18 UTC (rev 388)
@@ -30,6 +30,7 @@
/* abstract types */
#define ASN1TAGCLASS_Root ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Group ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Presentable ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Ingredient ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Program ASN1TAG_SYNTHETIC
#define ASN1TAGCLASS_Variable ASN1TAG_SYNTHETIC
@@ -122,13 +123,14 @@
#define ASN1TAG_Positions 73
#define ASN1TAG_WrapAround 74
#define ASN1TAG_MultipleSelection 75
-#define ASN1TAG_BoxSize 76
+#define ASN1TAG_OriginalBoxSize 76
#define ASN1TAG_OriginalPosition 77
#define ASN1TAG_OriginalPaletteRef 78
#define ASN1TAG_Tiling 79
#define ASN1TAG_OriginalTransparency 80
#define ASN1TAG_BorderedBoundingBox 81
#define ASN1TAG_OriginalLineWidth 82
+#define ASN1TAG_OriginalLineStyle 83
#define ASN1TAG_OriginalRefLineColour 84
#define ASN1TAG_OriginalRefFillColour 85
#define ASN1TAG_OriginalFont 86
@@ -372,13 +374,14 @@
#define ASN1TAGCLASS_Positions ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Positions)
#define ASN1TAGCLASS_WrapAround ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_WrapAround)
#define ASN1TAGCLASS_MultipleSelection ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_MultipleSelection)
-#define ASN1TAGCLASS_BoxSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BoxSize)
+#define ASN1TAGCLASS_OriginalBoxSize ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalBoxSize)
#define ASN1TAGCLASS_OriginalPosition ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalPosition)
#define ASN1TAGCLASS_OriginalPaletteRef ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalPaletteRef)
#define ASN1TAGCLASS_Tiling ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_Tiling)
#define ASN1TAGCLASS_OriginalTransparency ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalTransparency)
#define ASN1TAGCLASS_BorderedBoundingBox ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_BorderedBoundingBox)
#define ASN1TAGCLASS_OriginalLineWidth ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalLineWidth)
+#define ASN1TAGCLASS_OriginalLineStyle ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalLineStyle)
#define ASN1TAGCLASS_OriginalRefLineColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalRefLineColour)
#define ASN1TAGCLASS_OriginalRefFillColour ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalRefFillColour)
#define ASN1TAGCLASS_OriginalFont ((ASN1CLASS_CONTEXT << 24) | ASN1TAG_OriginalFont)
@@ -559,166 +562,158 @@
#define ASN1TAGCLASS_MHEGStandardIdentifier ASN1TAGCLASS_INTEGER
#define ASN1TAGCLASS_DirectFont ASN1TAGCLASS_OctetString
#define ASN1TAGCLASS_IndirectFont ASN1TAG_SYNTHETIC
-
-/* start TODO */
-#define ASN1TAG_FIXME 99999
-#define ASN1TAGCLASS_XScene ASN1TAG_FIXME
-#define ASN1TAGCLASS_YScene ASN1TAG_FIXME
-#define ASN1TAGCLASS_Width ASN1TAG_FIXME
-#define ASN1TAGCLASS_Height ASN1TAG_FIXME
-#define ASN1TAGCLASS_SceneRef ASN1TAG_FIXME
-#define ASN1TAGCLASS_SceneWeight ASN1TAG_FIXME
-#define ASN1TAGCLASS_IncludedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_EventSource ASN1TAG_FIXME
-#define ASN1TAGCLASS_EventType ASN1TAG_FIXME
-#define ASN1TAGCLASS_EventData ASN1TAG_FIXME
-#define ASN1TAGCLASS_ObjectReferenceValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_Presentable ASN1TAG_FIXME
-#define ASN1TAGCLASS_TargetElement ASN1TAG_FIXME
-#define ASN1TAGCLASS_AVisible ASN1TAG_FIXME
-#define ASN1TAGCLASS_Position ASN1TAG_FIXME
-#define ASN1TAGCLASS_OriginalBoxSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_XLength ASN1TAG_FIXME
-#define ASN1TAGCLASS_YLength ASN1TAG_FIXME
-#define ASN1TAGCLASS_OriginalLineStyle ASN1TAG_FIXME
-#define ASN1TAGCLASS_AbsoluteTime ASN1TAG_FIXME
-#define ASN1TAGCLASS_Address ASN1TAG_FIXME
-#define ASN1TAGCLASS_Answer ASN1TAG_FIXME
-#define ASN1TAGCLASS_AppendValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_ArcAngle ASN1TAG_FIXME
-#define ASN1TAGCLASS_AvailabilityStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_CallSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_CellIndex ASN1TAG_FIXME
-#define ASN1TAGCLASS_CloneRefVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ConnectionTag ASN1TAG_FIXME
-#define ASN1TAGCLASS_Denominator ASN1TAG_FIXME
-#define ASN1TAGCLASS_EllipseHeight ASN1TAG_FIXME
-#define ASN1TAGCLASS_EllipseWidth ASN1TAG_FIXME
-#define ASN1TAGCLASS_EmulatedEventSource ASN1TAG_FIXME
-#define ASN1TAGCLASS_EmulatedEventType ASN1TAG_FIXME
-#define ASN1TAGCLASS_EntryPointVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ForkSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_Feature ASN1TAG_FIXME
-#define ASN1TAGCLASS_FillColourVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_FirstItemVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_HighlightStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_Index ASN1TAG_FIXME
-#define ASN1TAGCLASS_InFileName ASN1TAG_FIXME
-#define ASN1TAGCLASS_InteractionStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemIndex ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemRefVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_ItemsToScroll ASN1TAG_FIXME
-#define ASN1TAGCLASS_LabelVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LastAnchorFiredVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LineColourVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LineStyleVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_LineWidthVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_MovementIdentifier ASN1TAG_FIXME
-#define ASN1TAGCLASS_NbOfSteps ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCachePriority ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCounterEndPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCounterPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCounterValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewCursorShape ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewEntryPoint ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewFirstItem ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewGenericOctetString ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewHighlightStatus ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewIncludedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewInteractionStatus ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewLabel ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewLineStyle ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewLineWidth ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewOverwriteMode ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewPaletteRef ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewPortion ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewSliderValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewSpeed ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewTransparency ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewVolume ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewXPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewYPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_Numerator ASN1TAG_FIXME
-#define ASN1TAGCLASS_OpenSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_Operator ASN1TAG_FIXME
-#define ASN1TAGCLASS_OutFileName ASN1TAG_FIXME
-#define ASN1TAGCLASS_OverwriteModeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_PortionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_Protocol ASN1TAG_FIXME
-#define ASN1TAGCLASS_ReadSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_ReferenceVisible ASN1TAG_FIXME
-#define ASN1TAGCLASS_RunningStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_SelectionStatusVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_SizeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_SliderValueVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_StartAngle ASN1TAG_FIXME
-#define ASN1TAGCLASS_StoreSucceeded ASN1TAG_FIXME
-#define ASN1TAGCLASS_Target ASN1TAG_FIXME
-#define ASN1TAGCLASS_TextContentVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_TextDataVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_TimerID ASN1TAG_FIXME
-#define ASN1TAGCLASS_TimerValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_TokenPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_TransitionEffect ASN1TAG_FIXME
-#define ASN1TAGCLASS_TriggerIdentifier ASN1TAG_FIXME
-#define ASN1TAGCLASS_Value ASN1TAG_FIXME
-#define ASN1TAGCLASS_VisibleReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_VolumeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_X ASN1TAG_FIXME
-#define ASN1TAGCLASS_X1 ASN1TAG_FIXME
-#define ASN1TAGCLASS_X2 ASN1TAG_FIXME
-#define ASN1TAGCLASS_XBoxSizeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_XCursor ASN1TAG_FIXME
-#define ASN1TAGCLASS_XNewBoxSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_XOut ASN1TAG_FIXME
-#define ASN1TAGCLASS_XPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_XScale ASN1TAG_FIXME
-#define ASN1TAGCLASS_Y ASN1TAG_FIXME
-#define ASN1TAGCLASS_Y1 ASN1TAG_FIXME
-#define ASN1TAGCLASS_Y2 ASN1TAG_FIXME
-#define ASN1TAGCLASS_YBoxSizeVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_YCursor ASN1TAG_FIXME
-#define ASN1TAGCLASS_YNewBoxSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_YOut ASN1TAG_FIXME
-#define ASN1TAGCLASS_YPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_YScale ASN1TAG_FIXME
-#define ASN1TAGCLASS_XOffsetVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_YOffsetVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewXOffset ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewYOffset ASN1TAG_FIXME
-#define ASN1TAGCLASS_FocusPositionVar ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewFocusPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewMinValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewMaxValue ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewStepSize ASN1TAG_FIXME
-#define ASN1TAGCLASS_InternalReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_GroupIdentifier ASN1TAG_FIXME
-#define ASN1TAGCLASS_ObjectNumber ASN1TAG_FIXME
-#define ASN1TAGCLASS_DirectReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_ColourIndex ASN1TAG_FIXME
-#define ASN1TAGCLASS_AbsoluteColour ASN1TAG_FIXME
-#define ASN1TAGCLASS_XPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_YPosition ASN1TAG_FIXME
-#define ASN1TAGCLASS_ReferencedContent ASN1TAG_FIXME
+#define ASN1TAGCLASS_XScene ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_YScene ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_Width ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_Height ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_SceneRef ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_SceneWeight ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_IncludedContent ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_EventSource ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EventType ASN1TAG_ENUMERATED
+#define ASN1TAGCLASS_EventData ASN1TAG_CHOICE
+#define ASN1TAGCLASS_ObjectReferenceValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ContentReferenceValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TargetElement ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_AVisible ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Position ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_BoxSize ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_XLength ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_YLength ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_AbsoluteTime ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Address ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Answer ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_AppendValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ArcAngle ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_AvailabilityStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_CallSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_CellIndex ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_CloneRefVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ConnectionTag ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Denominator ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EllipseHeight ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EllipseWidth ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EmulatedEventSource ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_EmulatedEventType ASN1TAG_ENUMERATED
+#define ASN1TAGCLASS_EntryPointVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ForkSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Feature ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_FillColourVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_FirstItemVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_HighlightStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Index ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_InFileName ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_InteractionStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemIndex ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemRefVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ItemsToScroll ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LabelVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LastAnchorFiredVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LineColourVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LineStyleVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_LineWidthVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_MovementIdentifier ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NbOfSteps ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCachePriority ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCounterEndPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCounterPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCounterValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewCursorShape ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewEntryPoint ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewFirstItem ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewGenericOctetString ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewHighlightStatus ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewIncludedContent ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewInteractionStatus ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewLabel ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewLineStyle ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewLineWidth ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewOverwriteMode ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewPaletteRef ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewPortion ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewSliderValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewSpeed ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewTransparency ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewVolume ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewXPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewYPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Numerator ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_OpenSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Operator ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_OutFileName ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_OverwriteModeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_PortionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Protocol ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ReadSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ReferenceVisible ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_RunningStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_SelectionStatusVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_SizeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_SliderValueVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_StartAngle ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_StoreSucceeded ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Target ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TextContentVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TextDataVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TimerID ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TimerValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TokenPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TransitionEffect ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_TriggerIdentifier ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Value ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_VisibleReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_VolumeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_X ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_X1 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_X2 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XBoxSizeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XCursor ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XNewBoxSize ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XOut ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XScale ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Y ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Y1 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_Y2 ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YBoxSizeVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YCursor ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YNewBoxSize ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YOut ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YScale ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_XOffsetVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_YOffsetVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewXOffset ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewYOffset ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_FocusPositionVar ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewFocusPosition ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewMinValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewMaxValue ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_NewStepSize ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_InternalReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_GroupIdentifier ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_ObjectNumber ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_DirectReference ASN1TAG_SYNTHETIC
+#define ASN1TAGCLASS_ColourIndex ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_AbsoluteColour ASN1TAGCLASS_OctetString
+#define ASN1TAGCLASS_XPosition ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_YPosition ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_ReferencedContent ASN1TAG_SEQUENCE
#define ASN1TAGCLASS_XYPosition ASN1TAG_SEQUENCE
-#define ASN1TAGCLASS_Point ASN1TAG_FIXME
-#define ASN1TAGCLASS_Rational ASN1TAG_FIXME
-#define ASN1TAGCLASS_ExternalReference ASN1TAG_FIXME
-#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_FIXME
-#define ASN1TAGCLASS_NextScene ASN1TAG_FIXME
-#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_FIXME
-/* TODO: an INTEGER ie class=UNIVERSAL, tag=2 */
-#define ASN1TAGCLASS_Movement ASN1TAG_FIXME
-/* TODO: sequences */
-#define ASN1TAGCLASS_ActionSlots ASN1TAG_FIXME
-#define ASN1TAGCLASS_InVariables ASN1TAG_FIXME
-#define ASN1TAGCLASS_OutVariables ASN1TAG_FIXME
-#define ASN1TAGCLASS_ActionClass ASN1TAG_FIXME
-#define ASN1TAGCLASS_Parameters ASN1TAG_FIXME
-#define ASN1TAGCLASS_PointList ASN1TAG_FIXME
-/* end TODO */
+#define ASN1TAGCLASS_Point ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_Rational ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_ExternalReference ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_NewReferencedContent ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_NextScene ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_TokenGroupItem ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_Movement ASN1TAGCLASS_INTEGER
+#define ASN1TAGCLASS_ActionSlots ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_InVariables ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_OutVariables ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_ActionClass ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_Parameters ASN1TAG_SEQUENCE
+#define ASN1TAGCLASS_PointList ASN1TAG_SEQUENCE
#endif /* __ASN1TAG_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 11:22:10
|
Revision: 389
http://redbutton.svn.sourceforge.net/redbutton/?rev=389&view=rev
Author: skilvington
Date: 2007-09-18 04:22:00 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
only show synthetic nodes in -vv mode
Modified Paths:
--------------
redbutton-author/trunk/asn1tag.c
redbutton-author/trunk/asn1tag.h
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/parser.c.header
redbutton-author/trunk/parser.h.header
Modified: redbutton-author/trunk/asn1tag.c
===================================================================
--- redbutton-author/trunk/asn1tag.c 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/asn1tag.c 2007-09-18 11:22:00 UTC (rev 389)
@@ -15,3 +15,9 @@
return "ILLEGAL-ASN1-CLASS-NUMBER";
}
+bool
+is_synthetic(unsigned int asn1tag)
+{
+/* TODO: only need one value for synthetic types (ie no need for separate ASN1TAG_CHOICE etc) */
+ return (asn1tag >= ASN1TAG_SYNTHETIC);
+}
Modified: redbutton-author/trunk/asn1tag.h
===================================================================
--- redbutton-author/trunk/asn1tag.h 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/asn1tag.h 2007-09-18 11:22:00 UTC (rev 389)
@@ -5,6 +5,8 @@
#ifndef __ASN1TAG_H__
#define __ASN1TAG_H__
+#include <stdbool.h>
+
/* tag classes */
#define ASN1CLASS_UNIVERSAL 0x00
#define ASN1CLASS_APPLICATION 0x40
@@ -12,6 +14,7 @@
#define ASN1CLASS_PRIVATE 0xc0
char *asn1class_name(unsigned int);
+bool is_synthetic(unsigned int);
/*
* a synthetic object created as a result of the grammar definition
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/mhegc.c 2007-09-18 11:22:00 UTC (rev 389)
@@ -67,6 +67,11 @@
else if(optind != argc)
usage(prog_name);
+ if(optind == argc - 1)
+ verbose("Parsing '%s':\n", argv[optind]);
+ else
+ verbose("Parsing stdin:\n");
+
bzero(&asn1obj, sizeof(struct node));
asn1obj.asn1tag = ASN1TAG_SYNTHETIC;
parse_InterchangedObject(&asn1obj);
@@ -94,17 +99,37 @@
void
print_node(struct node *n, unsigned int indent)
{
+ bool show_node;
+ bool show_kids;
struct node *kid;
- print_indent(indent);
- fprintf(stderr, "[%s %d]\n", asn1class_name(n->asn1class), n->asn1tag);
+ /* only show synthetic nodes if -vv was given on the cmd line */
+ show_node = (!is_synthetic(n->asn1tag) || _verbose > 1);
- if(n->children)
+ /* only show non-synthetic children, unless -vv was given */
+ show_kids = (has_real_children(n) || _verbose > 1);
+
+ if(show_node)
{
print_indent(indent);
- fprintf(stderr, "{\n");
+ fprintf(stderr, "[%s %d]\n", asn1class_name(n->asn1class), n->asn1tag);
+ if(show_kids)
+ {
+ print_indent(indent);
+ fprintf(stderr, "{\n");
+ indent ++;
+ }
+ }
+
+ if(show_kids)
+ {
for(kid=n->children; kid; kid=kid->siblings)
- print_node(kid, indent + 1);
+ print_node(kid, indent);
+ }
+
+ if(show_node && show_kids)
+ {
+ indent --;
print_indent(indent);
fprintf(stderr, "}\n");
}
Modified: redbutton-author/trunk/parser.c.header
===================================================================
--- redbutton-author/trunk/parser.c.header 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/parser.c.header 2007-09-18 11:22:00 UTC (rev 389)
@@ -59,6 +59,24 @@
}
/*
+ * return true if any of the node's descendants are not synthetic
+ */
+
+bool
+has_real_children(struct node *n)
+{
+ struct node *kid;
+
+ for(kid=n->children; kid; kid=kid->siblings)
+ {
+ if(has_real_children(kid) || !is_synthetic(kid->asn1tag))
+ return true;
+ }
+
+ return false;
+}
+
+/*
* parser functions for the predefined types
*/
Modified: redbutton-author/trunk/parser.h.header
===================================================================
--- redbutton-author/trunk/parser.h.header 2007-09-17 16:23:18 UTC (rev 388)
+++ redbutton-author/trunk/parser.h.header 2007-09-18 11:22:00 UTC (rev 389)
@@ -24,6 +24,9 @@
/* add a child to a node */
struct node *add_child(struct node *, uint32_t);
+/* return true if any of the node's descendants are not synthetic */
+bool has_real_children(struct node *);
+
/* lexer token type */
typedef int token_t;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 11:57:46
|
Revision: 390
http://redbutton.svn.sourceforge.net/redbutton/?rev=390&view=rev
Author: skilvington
Date: 2007-09-18 04:57:45 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
dump the value of ASN1 objects in -v/-vv mode
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/mhegc.c
redbutton-author/trunk/utils.c
redbutton-author/trunk/utils.h
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 11:57:45 UTC (rev 390)
@@ -3,6 +3,7 @@
*/
#include <stdbool.h>
+#include <string.h>
#include "utils.h"
@@ -33,6 +34,12 @@
if(*out != NULL || *len != 0)
fatal("der_encode_OctetString: length already %u", *len);
+ /* convert the STRING, QPRINTABLE or BASE64 data to an OctetString */
+/* TODO: fixme */
+*len = strlen(str) + 1;
+*out=safe_malloc(*len);
+strcpy(*out,str);
+
return;
}
Modified: redbutton-author/trunk/mhegc.c
===================================================================
--- redbutton-author/trunk/mhegc.c 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/mhegc.c 2007-09-18 11:57:45 UTC (rev 390)
@@ -121,12 +121,12 @@
}
}
- if(show_kids)
- {
- for(kid=n->children; kid; kid=kid->siblings)
- print_node(kid, indent);
- }
+ if(n->length > 0)
+ hexdump(stderr, n->value, n->length);
+ for(kid=n->children; kid; kid=kid->siblings)
+ print_node(kid, indent);
+
if(show_node && show_kids)
{
indent --;
Modified: redbutton-author/trunk/utils.c
===================================================================
--- redbutton-author/trunk/utils.c 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/utils.c 2007-09-18 11:57:45 UTC (rev 390)
@@ -104,7 +104,7 @@
#define HEXDUMP_WIDTH 16
void
-hexdump(unsigned char *data, size_t nbytes)
+hexdump(FILE *out, unsigned char *data, size_t nbytes)
{
size_t nout;
int i;
@@ -114,16 +114,16 @@
{
/* byte offset at start of line */
if((nout % HEXDUMP_WIDTH) == 0)
- printf("0x%.8x ", nout);
+ fprintf(out, "0x%.8x ", nout);
/* the byte value in hex */
- printf("%.2x ", data[nout]);
+ fprintf(out, "%.2x ", data[nout]);
/* the ascii equivalent at the end of the line */
if((nout % HEXDUMP_WIDTH) == (HEXDUMP_WIDTH - 1))
{
- printf(" ");
+ fprintf(out, " ");
for(i=HEXDUMP_WIDTH-1; i>=0; i--)
- printf("%c", isprint(data[nout - i]) ? data[nout - i] : '.');
- printf("\n");
+ fprintf(out, "%c", isprint(data[nout - i]) ? data[nout - i] : '.');
+ fprintf(out, "\n");
}
nout ++;
}
@@ -133,13 +133,13 @@
{
/* pad to the start of the ascii equivalent */
for(i=(nout % HEXDUMP_WIDTH); i<HEXDUMP_WIDTH; i++)
- printf(" ");
- printf(" ");
+ fprintf(out, " ");
+ fprintf(out, " ");
/* print the ascii equivalent */
nout --;
for(i=(nout % HEXDUMP_WIDTH); i>=0; i--)
- printf("%c", isprint(data[nout - i]) ? data[nout - i] : '.');
- printf("\n");
+ fprintf(out, "%c", isprint(data[nout - i]) ? data[nout - i] : '.');
+ fprintf(out, "\n");
}
return;
Modified: redbutton-author/trunk/utils.h
===================================================================
--- redbutton-author/trunk/utils.h 2007-09-18 11:22:00 UTC (rev 389)
+++ redbutton-author/trunk/utils.h 2007-09-18 11:57:45 UTC (rev 390)
@@ -25,12 +25,13 @@
#include <stdlib.h>
#include <stdarg.h>
+#include <stdio.h>
void *safe_malloc(size_t);
void *safe_realloc(void *, size_t);
void safe_free(void *);
-void hexdump(unsigned char *, size_t);
+void hexdump(FILE *, unsigned char *, size_t);
void error(char *, ...);
void fatal(char *, ...);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 12:12:12
|
Revision: 391
http://redbutton.svn.sourceforge.net/redbutton/?rev=391&view=rev
Author: skilvington
Date: 2007-09-18 05:12:11 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
convert STRINGs to OctetStrings
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/der_encode.h
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 11:57:45 UTC (rev 390)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 12:12:11 UTC (rev 391)
@@ -5,6 +5,7 @@
#include <stdbool.h>
#include <string.h>
+#include "der_encode.h"
#include "utils.h"
void
@@ -35,11 +36,77 @@
fatal("der_encode_OctetString: length already %u", *len);
/* convert the STRING, QPRINTABLE or BASE64 data to an OctetString */
-/* TODO: fixme */
-*len = strlen(str) + 1;
-*out=safe_malloc(*len);
-strcpy(*out,str);
+ if(*str == '"')
+ convert_STRING(out, len, str);
+ else if(*str == '\'')
+ convert_QPRINTABLE(out, len, str);
+ else if(*str == '`')
+ convert_BASE64(out, len, str);
+ else
+ fatal("der_encode_OctetString: str[0]=0x%02x", *str);
return;
}
+/*
+ * string is enclosed in "
+ * " and \ within the string are encoded as \" and \\
+ */
+
+void
+convert_STRING(unsigned char **out, unsigned int *len, const char *str)
+{
+ unsigned char *p;
+
+ /* max size it could be */
+ *out = safe_malloc(strlen(str));
+
+ /* skip the initial " */
+ str ++;
+ p = *out;
+ while(*str != '"')
+ {
+ if(*str != '\\')
+ {
+ *p = *str;
+ p ++;
+ str ++;
+ }
+ else if(*(str + 1) == '"')
+ {
+ *p = '"';
+ p ++;
+ str += 2;
+ }
+ else if(*(str + 1) == '\\')
+ {
+ *p = '\\';
+ p ++;
+ str += 2;
+ }
+ else
+ {
+ fatal("Invalid escape sequence in STRING: %s", str - 1);
+ }
+ }
+
+ /* check we got to the closing quote */
+ if(*(str + 1) != '\0')
+ fatal("Unquoted \" in STRING: %s", str - 1);
+
+ /* return the length (note: no \0 terminator) */
+ *len = (p - *out);
+
+ return;
+}
+
+void
+convert_QPRINTABLE(unsigned char **out, unsigned int *len, const char *str)
+{
+}
+
+void
+convert_BASE64(unsigned char **out, unsigned int *len, const char *str)
+{
+}
+
Modified: redbutton-author/trunk/der_encode.h
===================================================================
--- redbutton-author/trunk/der_encode.h 2007-09-18 11:57:45 UTC (rev 390)
+++ redbutton-author/trunk/der_encode.h 2007-09-18 12:12:11 UTC (rev 391)
@@ -11,5 +11,9 @@
void der_encode_INTEGER(unsigned char **, unsigned int *, int);
void der_encode_OctetString(unsigned char **, unsigned int *, const char *);
+void convert_STRING(unsigned char **, unsigned int *, const char *);
+void convert_QPRINTABLE(unsigned char **, unsigned int *, const char *);
+void convert_BASE64(unsigned char **, unsigned int *, const char *);
+
#endif /* __DER_ENCODE_H__ */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ski...@us...> - 2007-09-18 12:36:41
|
Revision: 393
http://redbutton.svn.sourceforge.net/redbutton/?rev=393&view=rev
Author: skilvington
Date: 2007-09-18 05:36:39 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
convert QPRINTABLEs to OctetStrings
Modified Paths:
--------------
redbutton-author/trunk/der_encode.c
redbutton-author/trunk/der_encode.h
redbutton-author/trunk/utils.c
redbutton-author/trunk/utils.h
Modified: redbutton-author/trunk/der_encode.c
===================================================================
--- redbutton-author/trunk/der_encode.c 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/der_encode.c 2007-09-18 12:36:39 UTC (rev 393)
@@ -4,6 +4,7 @@
#include <stdbool.h>
#include <string.h>
+#include <ctype.h>
#include "der_encode.h"
#include "utils.h"
@@ -29,7 +30,7 @@
}
void
-der_encode_OctetString(unsigned char **out, unsigned int *len, const char *str)
+der_encode_OctetString(unsigned char **out, unsigned int *len, const unsigned char *str)
{
/* assert */
if(*out != NULL || *len != 0)
@@ -55,9 +56,9 @@
*/
void
-convert_STRING(unsigned char **out, unsigned int *len, const char *str)
+convert_STRING(unsigned char **out, unsigned int *len, const unsigned char *str)
{
- unsigned char *whole_str = str;
+ const unsigned char *whole_str = str;
unsigned char *p;
/* max size it could be */
@@ -92,6 +93,7 @@
}
else
{
+ /* TODO: show the line number */
fatal("Invalid escape sequence in STRING: %s", whole_str);
}
}
@@ -106,13 +108,58 @@
return;
}
+/*
+ * string is enclosed in '
+ * encoded as specified in RFC 1521 (MIME)
+ * in addition, ' is encoded as =27
+ * and line breaks do not need to be converted to CRLF
+ */
+
void
-convert_QPRINTABLE(unsigned char **out, unsigned int *len, const char *str)
+convert_QPRINTABLE(unsigned char **out, unsigned int *len, const unsigned char *str)
{
+ const unsigned char *whole_str = str;
+ unsigned char *p;
+
+ /* max size it could be */
+ *out = safe_malloc(strlen(str));
+
+ /* skip the initial ' */
+ str ++;
+ p = *out;
+ while(*str != '\'')
+ {
+ if(*str != '=')
+ {
+ *p = *str;
+ p ++;
+ str ++;
+ }
+ else if(isxdigit(*(str + 1)) && isxdigit(*(str + 2)))
+ {
+ *p = char2hex(*(str + 1)) << 4 | char2hex(*(str + 2));
+ p ++;
+ str += 3;
+ }
+ else
+ {
+ /* TODO: show the line number */
+ fatal("Invalid escape sequence in QPRINTABLE: %s", whole_str);
+ }
+ }
+
+ /* check we got to the closing quote */
+ if(*(str + 1) != '\0')
+ fatal("Unquoted ' in QPRINTABLE: %s", whole_str);
+
+ /* return the length (note: no \0 terminator) */
+ *len = (p - *out);
+
+ return;
}
void
-convert_BASE64(unsigned char **out, unsigned int *len, const char *str)
+convert_BASE64(unsigned char **out, unsigned int *len, const unsigned char *str)
{
}
Modified: redbutton-author/trunk/der_encode.h
===================================================================
--- redbutton-author/trunk/der_encode.h 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/der_encode.h 2007-09-18 12:36:39 UTC (rev 393)
@@ -9,11 +9,11 @@
void der_encode_BOOLEAN(unsigned char **, unsigned int *, bool);
void der_encode_INTEGER(unsigned char **, unsigned int *, int);
-void der_encode_OctetString(unsigned char **, unsigned int *, const char *);
+void der_encode_OctetString(unsigned char **, unsigned int *, const unsigned char *);
-void convert_STRING(unsigned char **, unsigned int *, const char *);
-void convert_QPRINTABLE(unsigned char **, unsigned int *, const char *);
-void convert_BASE64(unsigned char **, unsigned int *, const char *);
+void convert_STRING(unsigned char **, unsigned int *, const unsigned char *);
+void convert_QPRINTABLE(unsigned char **, unsigned int *, const unsigned char *);
+void convert_BASE64(unsigned char **, unsigned int *, const unsigned char *);
#endif /* __DER_ENCODE_H__ */
Modified: redbutton-author/trunk/utils.c
===================================================================
--- redbutton-author/trunk/utils.c 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/utils.c 2007-09-18 12:36:39 UTC (rev 393)
@@ -28,6 +28,21 @@
#include "utils.h"
/*
+ * returns 15 for 'f' etc
+ */
+
+unsigned int
+char2hex(unsigned char c)
+{
+ if(!isxdigit(c))
+ return 0;
+ else if(c >= '0' && c <= '9')
+ return c - '0';
+ else
+ return 10 + (tolower(c) - 'a');
+}
+
+/*
* I don't want to double the size of my code just to deal with malloc failures
* if you've run out of memory you're fscked anyway, me trying to recover is not gonna help...
*/
Modified: redbutton-author/trunk/utils.h
===================================================================
--- redbutton-author/trunk/utils.h 2007-09-18 12:18:13 UTC (rev 392)
+++ redbutton-author/trunk/utils.h 2007-09-18 12:36:39 UTC (rev 393)
@@ -27,6 +27,8 @@
#include <stdarg.h>
#include <stdio.h>
+unsigned int char2hex(unsigned char);
+
void *safe_malloc(size_t);
void *safe_realloc(void *, size_t);
void safe_free(void *);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|