API cleanup. Scanner interface

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9635 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2007-01-12 01:44:16 +00:00
commit 6ffd26cc1e
7 changed files with 762 additions and 179 deletions

View file

@ -27,7 +27,7 @@ static int imported_depth = 0; /* Depth of %imported files */
static int single_include = 1; /* Only include each file once */
static Hash *included_files = 0;
static List *dependencies = 0;
static SwigScanner *id_scan = 0;
static Scanner *id_scan = 0;
static int error_as_warning = 0; /* Understand the cpp #error directive as a special #warning */
/* Test a character to see if it starts an identifier */
@ -185,7 +185,7 @@ void Preprocessor_init(void) {
Preprocessor_expr_init(); /* Initialize the expression evaluator */
included_files = NewHash();
id_scan = NewSwigScanner();;
id_scan = NewScanner();;
}
@ -225,7 +225,7 @@ void Preprocessor_delete(void) {
Delete(cpp);
Delete(included_files);
Preprocessor_expr_delete();
DelSwigScanner(id_scan);
DelScanner(id_scan);
Delete(dependencies);
@ -1150,15 +1150,15 @@ DOH *Preprocessor_replace(DOH *s) {
static int checkpp_id(DOH *s) {
int c;
int hastok = 0;
SwigScanner *scan = id_scan;
Scanner *scan = id_scan;
Seek(s, 0, SEEK_SET);
SwigScanner_clear(scan);
Scanner_clear(scan);
s = Copy(s);
Seek(s, SEEK_SET, 0);
SwigScanner_push(scan, s);
while ((c = SwigScanner_token(scan))) {
Scanner_push(scan, s);
while ((c = Scanner_token(scan))) {
hastok = 1;
if ((c == SWIG_TOKEN_ID) || (c == SWIG_TOKEN_LBRACE) || (c == SWIG_TOKEN_RBRACE))
return 1;

View file

@ -13,7 +13,7 @@ char cvsroot_expr_c[] = "$Id$";
#include "swig.h"
#include "preprocessor.h"
static SwigScanner *scan = 0;
static Scanner *scan = 0;
typedef struct {
int op;
@ -222,12 +222,12 @@ void Preprocessor_expr_init(void) {
if (!expr_init)
init_precedence();
if (!scan)
scan = NewSwigScanner();
scan = NewScanner();
}
void Preprocessor_expr_delete(void) {
SwigScanner_clear(scan);
DelSwigScanner(scan);
Scanner_clear(scan);
DelScanner(scan);
}
@ -235,11 +235,11 @@ void Preprocessor_expr_delete(void) {
* Tokenizer
* ----------------------------------------------------------------------------- */
static int expr_token(SwigScanner * s) {
static int expr_token(Scanner * s) {
int t;
while (1) {
t = SwigScanner_token(s);
if (!((t == SWIG_TOKEN_BACKSLASH) || (t == SWIG_TOKEN_ENDLINE)))
t = Scanner_token(s);
if (!((t == SWIG_TOKEN_BACKSLASH) || (t == SWIG_TOKEN_ENDLINE) || (t == SWIG_TOKEN_COMMENT)))
break;
}
return t;
@ -262,8 +262,8 @@ int Preprocessor_expr(DOH *s, int *error) {
Seek(s, 0, SEEK_SET);
/* Printf(stdout,"evaluating : '%s'\n", s); */
*error = 0;
SwigScanner_clear(scan);
SwigScanner_push(scan, s);
Scanner_clear(scan);
Scanner_push(scan, s);
/* Put initial state onto the stack */
stack[sp].op = EXPR_TOP;
@ -282,10 +282,10 @@ int Preprocessor_expr(DOH *s, int *error) {
}
if ((token == SWIG_TOKEN_INT) || (token == SWIG_TOKEN_UINT) || (token == SWIG_TOKEN_LONG) || (token == SWIG_TOKEN_ULONG)) {
/* A number. Reduce EXPR_TOP to an EXPR_VALUE */
char *c = Char(SwigScanner_text(scan));
char *c = Char(Scanner_text(scan));
stack[sp].value = (long) strtol(c, 0, 0);
stack[sp].svalue = 0;
/* stack[sp].value = (long) atol(Char(SwigScanner_text(scan))); */
/* stack[sp].value = (long) atol(Char(Scanner_text(scan))); */
stack[sp].op = EXPR_VALUE;
} else if (token == SWIG_TOKEN_PLUS) {
} else if ((token == SWIG_TOKEN_MINUS) || (token == SWIG_TOKEN_LNOT) || (token == SWIG_TOKEN_NOT)) {
@ -302,7 +302,7 @@ int Preprocessor_expr(DOH *s, int *error) {
stack[sp].svalue = 0;
} else if (token == SWIG_TOKEN_ENDLINE) {
} else if ((token == SWIG_TOKEN_STRING)) {
stack[sp].svalue = NewString(SwigScanner_text(scan));
stack[sp].svalue = NewString(Scanner_text(scan));
stack[sp].op = EXPR_VALUE;
} else if ((token == SWIG_TOKEN_ID)) {
stack[sp].value = 0;