Comments added
authorkaashoek <none@none>
Wed, 25 Nov 1987 14:41:10 +0000 (14:41 +0000)
committerkaashoek <none@none>
Wed, 25 Nov 1987 14:41:10 +0000 (14:41 +0000)
util/ceg/EM_parser/common/action.c

index cecbd1d..628f7c6 100644 (file)
@@ -1,14 +1,26 @@
 #include "decl.h"
 #include <alloc.h>
-
-int quantum = 0, nr_instr, block_saved, first_action, last_action;
 extern char *malloc(), *realloc(), *Salloc();
-char **as_instructions;
+
+/* This file contains some routines needed in "pars.g" to handle the  action-
+ * grammarrule. The assembler-instructions are handeld in blocks rather than
+ * one at a time. So these routines provide saving and removing of assembler-
+ * instructions.
+ */
+
+char **as_instructions;            /* The buffer(?) where the instructions are saved */
+
+int quantum = 0,           /* Max. nr. of instructions in as_instructions[] */
+    nr_instr,              /* Number of saved instructions */
+    first_action,          /* Is this block of assembler-instr. the first after
+                            * a '==>' or '::=' ?
+                            */
+    last_action;           /* Is this block followed by a '.' ? */
+
 
 init_as_block()
 {
        nr_instr = 0;
-       block_saved = TRUE;
 
        if ( quantum == 0) {
                quantum = 16;
@@ -19,6 +31,9 @@ init_as_block()
 
 save_as( instr)
 char *instr;
+
+/* Save a copy of 'instr'
+ */
 {
        if ( nr_instr == quantum) {
                quantum *= 2;
@@ -33,13 +48,11 @@ do_block_assemble()
 {
        int i;
 
-       if ( block_saved) {
+       if ( nr_instr > 0) {
                block_assemble( as_instructions, nr_instr,
                                first_action, last_action);
 
                for ( i=0; i<nr_instr; i++)
                        free( as_instructions[i]);
-               
-               block_saved = FALSE;
        }
 }