-/* $Id: section.h,v 1.6 2001/09/16 04:49:46 peter Exp $
+/* $Id: section.h,v 1.7 2001/09/16 18:53:47 peter Exp $
* Section header file
*
* Copyright (C) 2001 Peter Johnson
typedef struct section_s {
STAILQ_ENTRY(section_s) link;
- enum { SECTION, ABSOLUTE } type;
+ enum { SECTION_DEFAULT, SECTION_GENERAL, SECTION_ABSOLUTE } type;
char *name;
unsigned int id;
union {
- /* SECTION data */
- /* ABSOLUTE data */
+ /* SECTION_DEFAULT data */
+ /* SECTION_GENERAL data */
+ /* SECTION_ABSOLUTE data */
unsigned long start;
} data;
-/* $Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $
+/* $Id: bison.y.in,v 1.29 2001/09/16 18:53:47 peter Exp $
* Main bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
#include "symrec.h"
#include "bytecode.h"
+#include "section.h"
-RCSID("$Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $");
+RCSID("$Id: bison.y.in,v 1.29 2001/09/16 18:53:47 peter Exp $");
#define YYDEBUG 1
static unsigned long ConvertCharConstToInt(char *);
void nasm_parser_error(char *);
+extern section *nasm_parser_cur_section;
+
+static bytecode *new_bc;
+
%}
%union {
%%
input: /* empty */
- | input line { OutputError(); OutputWarning(); line_number++; }
+ | input line {
+ OutputError();
+ OutputWarning();
+ if ($2.type != BC_EMPTY) {
+ new_bc = malloc(sizeof(bytecode));
+ if(!new_bc)
+ Fatal(FATAL_NOMEM);
+ memcpy(new_bc, &$2, sizeof(bytecode));
+ STAILQ_INSERT_TAIL(&nasm_parser_cur_section->bc, new_bc, link);
+ }
+ line_number++;
+ }
;
line: '\n' { $$.type = BC_EMPTY; }
- | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
+ | exp '\n'
| directive '\n' { $$.type = BC_EMPTY; }
| error '\n' {
Error(_("label or instruction expected at start of line"));
-/* $Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $
+/* $Id: nasm-bison.y,v 1.29 2001/09/16 18:53:47 peter Exp $
* Main bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
#include "symrec.h"
#include "bytecode.h"
+#include "section.h"
-RCSID("$Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $");
+RCSID("$Id: nasm-bison.y,v 1.29 2001/09/16 18:53:47 peter Exp $");
#define YYDEBUG 1
static unsigned long ConvertCharConstToInt(char *);
void nasm_parser_error(char *);
+extern section *nasm_parser_cur_section;
+
+static bytecode *new_bc;
+
%}
%union {
%%
input: /* empty */
- | input line { OutputError(); OutputWarning(); line_number++; }
+ | input line {
+ OutputError();
+ OutputWarning();
+ if ($2.type != BC_EMPTY) {
+ new_bc = malloc(sizeof(bytecode));
+ if(!new_bc)
+ Fatal(FATAL_NOMEM);
+ memcpy(new_bc, &$2, sizeof(bytecode));
+ STAILQ_INSERT_TAIL(&nasm_parser_cur_section->bc, new_bc, link);
+ }
+ line_number++;
+ }
;
line: '\n' { $$.type = BC_EMPTY; }
- | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
+ | exp '\n'
| directive '\n' { $$.type = BC_EMPTY; }
| error '\n' {
Error(_("label or instruction expected at start of line"));
-/* $Id: nasm-parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $
+/* $Id: nasm-parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
+#include "errwarn.h"
+
#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-RCSID("$Id: nasm-parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $");
+RCSID("$Id: nasm-parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
int (*nasm_parser_yyinput) (char *buf, int max_size);
+sectionhead nasm_parser_sections;
+section *nasm_parser_cur_section;
+
static sectionhead *
nasm_parser_doparse(parser *p, objfmt *of, FILE *f)
{
nasm_parser_in = f;
nasm_parser_yyinput = p->current_pp->input;
+ /* Initialize linked list */
+ STAILQ_INIT(&nasm_parser_sections);
+
+ /* Add an initial "default" section to the list */
+ nasm_parser_cur_section = calloc(1, sizeof(section));
+ if (!nasm_parser_cur_section)
+ Fatal(FATAL_NOMEM);
+ STAILQ_INSERT_TAIL(&nasm_parser_sections, nasm_parser_cur_section, link);
+
+ /* Initialize default section */
+ nasm_parser_cur_section->type = SECTION_DEFAULT;
+ STAILQ_INIT(&nasm_parser_cur_section->bc);
+
/* only temporary */
- nasm_parser_debug = 1;
+ nasm_parser_debug = 0;
nasm_parser_parse();
- return NULL;
+ return &nasm_parser_sections;
}
/* Define valid preprocessors to use with this parser */
-/* $Id: parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $
+/* $Id: parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
+#include "errwarn.h"
+
#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-RCSID("$Id: parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $");
+RCSID("$Id: parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
int (*nasm_parser_yyinput) (char *buf, int max_size);
+sectionhead nasm_parser_sections;
+section *nasm_parser_cur_section;
+
static sectionhead *
nasm_parser_doparse(parser *p, objfmt *of, FILE *f)
{
nasm_parser_in = f;
nasm_parser_yyinput = p->current_pp->input;
+ /* Initialize linked list */
+ STAILQ_INIT(&nasm_parser_sections);
+
+ /* Add an initial "default" section to the list */
+ nasm_parser_cur_section = calloc(1, sizeof(section));
+ if (!nasm_parser_cur_section)
+ Fatal(FATAL_NOMEM);
+ STAILQ_INSERT_TAIL(&nasm_parser_sections, nasm_parser_cur_section, link);
+
+ /* Initialize default section */
+ nasm_parser_cur_section->type = SECTION_DEFAULT;
+ STAILQ_INIT(&nasm_parser_cur_section->bc);
+
/* only temporary */
- nasm_parser_debug = 1;
+ nasm_parser_debug = 0;
nasm_parser_parse();
- return NULL;
+ return &nasm_parser_sections;
}
/* Define valid preprocessors to use with this parser */
-/* $Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $
+/* $Id: bison.y.in,v 1.29 2001/09/16 18:53:47 peter Exp $
* Main bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
#include "symrec.h"
#include "bytecode.h"
+#include "section.h"
-RCSID("$Id: bison.y.in,v 1.28 2001/08/30 03:45:26 peter Exp $");
+RCSID("$Id: bison.y.in,v 1.29 2001/09/16 18:53:47 peter Exp $");
#define YYDEBUG 1
static unsigned long ConvertCharConstToInt(char *);
void nasm_parser_error(char *);
+extern section *nasm_parser_cur_section;
+
+static bytecode *new_bc;
+
%}
%union {
%%
input: /* empty */
- | input line { OutputError(); OutputWarning(); line_number++; }
+ | input line {
+ OutputError();
+ OutputWarning();
+ if ($2.type != BC_EMPTY) {
+ new_bc = malloc(sizeof(bytecode));
+ if(!new_bc)
+ Fatal(FATAL_NOMEM);
+ memcpy(new_bc, &$2, sizeof(bytecode));
+ STAILQ_INSERT_TAIL(&nasm_parser_cur_section->bc, new_bc, link);
+ }
+ line_number++;
+ }
;
line: '\n' { $$.type = BC_EMPTY; }
- | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
+ | exp '\n'
| directive '\n' { $$.type = BC_EMPTY; }
| error '\n' {
Error(_("label or instruction expected at start of line"));
-/* $Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $
+/* $Id: nasm-bison.y,v 1.29 2001/09/16 18:53:47 peter Exp $
* Main bison parser
*
* Copyright (C) 2001 Peter Johnson, Michael Urman
#include "symrec.h"
#include "bytecode.h"
+#include "section.h"
-RCSID("$Id: nasm-bison.y,v 1.28 2001/08/30 03:45:26 peter Exp $");
+RCSID("$Id: nasm-bison.y,v 1.29 2001/09/16 18:53:47 peter Exp $");
#define YYDEBUG 1
static unsigned long ConvertCharConstToInt(char *);
void nasm_parser_error(char *);
+extern section *nasm_parser_cur_section;
+
+static bytecode *new_bc;
+
%}
%union {
%%
input: /* empty */
- | input line { OutputError(); OutputWarning(); line_number++; }
+ | input line {
+ OutputError();
+ OutputWarning();
+ if ($2.type != BC_EMPTY) {
+ new_bc = malloc(sizeof(bytecode));
+ if(!new_bc)
+ Fatal(FATAL_NOMEM);
+ memcpy(new_bc, &$2, sizeof(bytecode));
+ STAILQ_INSERT_TAIL(&nasm_parser_cur_section->bc, new_bc, link);
+ }
+ line_number++;
+ }
;
line: '\n' { $$.type = BC_EMPTY; }
- | exp '\n' { DebugPrintBC(&$1); $$ = $1; }
+ | exp '\n'
| directive '\n' { $$.type = BC_EMPTY; }
| error '\n' {
Error(_("label or instruction expected at start of line"));
-/* $Id: nasm-parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $
+/* $Id: nasm-parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
+#include "errwarn.h"
+
#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-RCSID("$Id: nasm-parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $");
+RCSID("$Id: nasm-parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
int (*nasm_parser_yyinput) (char *buf, int max_size);
+sectionhead nasm_parser_sections;
+section *nasm_parser_cur_section;
+
static sectionhead *
nasm_parser_doparse(parser *p, objfmt *of, FILE *f)
{
nasm_parser_in = f;
nasm_parser_yyinput = p->current_pp->input;
+ /* Initialize linked list */
+ STAILQ_INIT(&nasm_parser_sections);
+
+ /* Add an initial "default" section to the list */
+ nasm_parser_cur_section = calloc(1, sizeof(section));
+ if (!nasm_parser_cur_section)
+ Fatal(FATAL_NOMEM);
+ STAILQ_INSERT_TAIL(&nasm_parser_sections, nasm_parser_cur_section, link);
+
+ /* Initialize default section */
+ nasm_parser_cur_section->type = SECTION_DEFAULT;
+ STAILQ_INIT(&nasm_parser_cur_section->bc);
+
/* only temporary */
- nasm_parser_debug = 1;
+ nasm_parser_debug = 0;
nasm_parser_parse();
- return NULL;
+ return &nasm_parser_sections;
}
/* Define valid preprocessors to use with this parser */
-/* $Id: parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $
+/* $Id: parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $
* NASM-compatible parser
*
* Copyright (C) 2001 Peter Johnson
#include <stdio.h>
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+#endif
+
+#include "errwarn.h"
+
#include "bytecode.h"
#include "section.h"
#include "objfmt.h"
#include "preproc.h"
#include "parser.h"
-RCSID("$Id: parser.c,v 1.8 2001/09/16 04:49:46 peter Exp $");
+RCSID("$Id: parser.c,v 1.9 2001/09/16 18:53:47 peter Exp $");
extern FILE *nasm_parser_in;
extern int nasm_parser_debug;
int (*nasm_parser_yyinput) (char *buf, int max_size);
+sectionhead nasm_parser_sections;
+section *nasm_parser_cur_section;
+
static sectionhead *
nasm_parser_doparse(parser *p, objfmt *of, FILE *f)
{
nasm_parser_in = f;
nasm_parser_yyinput = p->current_pp->input;
+ /* Initialize linked list */
+ STAILQ_INIT(&nasm_parser_sections);
+
+ /* Add an initial "default" section to the list */
+ nasm_parser_cur_section = calloc(1, sizeof(section));
+ if (!nasm_parser_cur_section)
+ Fatal(FATAL_NOMEM);
+ STAILQ_INSERT_TAIL(&nasm_parser_sections, nasm_parser_cur_section, link);
+
+ /* Initialize default section */
+ nasm_parser_cur_section->type = SECTION_DEFAULT;
+ STAILQ_INIT(&nasm_parser_cur_section->bc);
+
/* only temporary */
- nasm_parser_debug = 1;
+ nasm_parser_debug = 0;
nasm_parser_parse();
- return NULL;
+ return &nasm_parser_sections;
}
/* Define valid preprocessors to use with this parser */
-/* $Id: section.h,v 1.6 2001/09/16 04:49:46 peter Exp $
+/* $Id: section.h,v 1.7 2001/09/16 18:53:47 peter Exp $
* Section header file
*
* Copyright (C) 2001 Peter Johnson
typedef struct section_s {
STAILQ_ENTRY(section_s) link;
- enum { SECTION, ABSOLUTE } type;
+ enum { SECTION_DEFAULT, SECTION_GENERAL, SECTION_ABSOLUTE } type;
char *name;
unsigned int id;
union {
- /* SECTION data */
- /* ABSOLUTE data */
+ /* SECTION_DEFAULT data */
+ /* SECTION_GENERAL data */
+ /* SECTION_ABSOLUTE data */
unsigned long start;
} data;