[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[MAIN] output-user-code.patch
From: |
marc-alexandre autret |
Subject: |
[MAIN] output-user-code.patch |
Date: |
Wed, 29 Aug 2001 16:24:25 +0000 (GMT) |
This patch handles the %%user_code
directive which is the location
in bison.simple of the C code
given in the last part of the
grammar file.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.193
diff -u -r1.193 ChangeLog
--- ChangeLog 2001/08/28 20:55:58 1.193
+++ ChangeLog 2001/08/29 14:06:39
@@ -1,3 +1,11 @@
+2001-08-29 Marc Autret <address@hidden>
+
+ * src/bison.simple: Add %%user_code directive at the end.
+ * src/reader.c (read_additionnal_code): New.
+ (reader): Use it.
+ * src/output.c (output_program): Remove.
+ (output): Update.
+
2001-08-28 Marc Autret <address@hidden>
* src/output.c (output_actions): Clean up.
Index: src/bison.simple
===================================================================
RCS file: /cvsroot/bison/bison/src/bison.simple,v
retrieving revision 1.58
diff -u -r1.58 bison.simple
--- src/bison.simple 2001/08/28 18:35:33 1.58
+++ src/bison.simple 2001/08/29 14:06:54
@@ -976,3 +976,6 @@
}
return 1;
}
+
+%%user_code
+
Index: src/output.c
===================================================================
RCS file: /cvsroot/bison/bison/src/output.c,v
retrieving revision 1.46
diff -u -r1.46 output.c
--- src/output.c 2001/08/28 20:55:58 1.46
+++ src/output.c 2001/08/29 14:07:04
@@ -1018,16 +1018,6 @@
}
static void
-output_program (void)
-{
- int c;
-
- while ((c = getc (finput)) != EOF)
- obstack_1grow (&table_obstack, c);
-}
-
-
-static void
free_itemsets (void)
{
core *cp, *cptmp;
@@ -1122,7 +1112,6 @@
/* Copy definitions in directive. */
macro_insert ("definitions", obstack_finish (&attrs_obstack));
output_parser ();
- output_program ();
obstack_free (¯o_obstack, 0);
obstack_free (&output_obstack, 0);
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.77
diff -u -r1.77 reader.c
--- src/reader.c 2001/08/28 20:48:17 1.77
+++ src/reader.c 2001/08/29 14:07:23
@@ -1667,6 +1667,25 @@
ntokens = nsyms - nvars;
}
+
+/* At the end of the grammar file, some C source code must
+ be stored. It is going to be associated to the user_code
+ directive. */
+static void
+read_additionnal_code (void)
+{
+ char c;
+ struct obstack uc_obstack;
+
+ obstack_init (&uc_obstack);
+
+ while ((c = getc (finput)) != EOF)
+ obstack_1grow (&uc_obstack, c);
+
+ obstack_1grow (&uc_obstack, 0);
+ macro_insert ("user_code", obstack_finish (&uc_obstack));
+}
+
/*--------------------------------------------------------------.
| For named tokens, but not literal ones, define the name. The |
@@ -2016,6 +2035,8 @@
/* Read in the grammar, build grammar in list form. Write out
guards and actions. */
readgram ();
+ /* Some C code is given at the end of the grammar file. */
+ read_additionnal_code ();
/* Now we know whether we need the line-number stack. If we do,
write its type into the .tab.h file. */
#if 0
--
Autret Marc (address@hidden)
Eleve Ingenieur en Informatique.