git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@134 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-01-20 20:04:39 +00:00
commit bf8138630f

View file

@ -75,12 +75,14 @@ static int remap[SWIG_MAXTOKENS];
static int cscan_init = 0; static int cscan_init = 0;
static int cplusplus_mode = 0; static int cplusplus_mode = 0;
static int objc_mode = 0; static int objc_mode = 0;
static int strict_type = 1; static int strict_type = 0;
static SwigScanner *cscanner = 0; static SwigScanner *cscanner = 0;
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* void lparse_init() * lparse_init()
*
* Initialize the parser
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static void static void
@ -97,35 +99,69 @@ lparse_init() {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* LParse_push(DOH *str) - Initialize the scanner * LParse_push()
*
* Push some text into the scanner.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
void void
LParse_push(DOH *str) LParse_push(DOH *str) {
{
assert(str); assert(str);
lparse_init(); lparse_init();
SwigScanner_push(cscanner, str); SwigScanner_push(cscanner, str);
} }
DOH *LParse_file() { /* -----------------------------------------------------------------------------
* LParse_file()
*
* Return the current filename
* ----------------------------------------------------------------------------- */
DOH *
LParse_file() {
return SwigScanner_get_file(cscanner); return SwigScanner_get_file(cscanner);
} }
int LParse_line() { /* -----------------------------------------------------------------------------
* LParse_line()
*
* Return the current line number
* ----------------------------------------------------------------------------- */
int
LParse_line() {
return SwigScanner_get_line(cscanner); return SwigScanner_get_line(cscanner);
} }
void LParse_set_location(DOH *file, int line) { /* -----------------------------------------------------------------------------
* LParse_set_location()
*
* Set the file and line number of the scanner.
* ----------------------------------------------------------------------------- */
void
LParse_set_location(DOH *file, int line) {
SwigScanner_set_location(cscanner,file,line); SwigScanner_set_location(cscanner,file,line);
} }
void LParse_strict_type(int i) { /* -----------------------------------------------------------------------------
* LParse_strict_type()
*
* Set the value of the strict type handling flag.
* ----------------------------------------------------------------------------- */
int
LParse_strict_type(int i) {
int old = strict_type;
strict_type = i; strict_type = i;
return old;
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* LParse_cplusplus(int i) - Enable C++ scanning * LParse_cplusplus()
*
* Enable or disable C++ keywords.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
int int
LParse_cplusplus(int i) { LParse_cplusplus(int i) {
int old = cplusplus_mode; int old = cplusplus_mode;
@ -134,7 +170,9 @@ LParse_cplusplus(int i) {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* LParse_objc(int i) - Enable Objective-C scanning * LParse_objc()
*
* Enable or disable objective-C keywords.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
int int
LParse_objc(int i) { LParse_objc(int i) {
@ -143,20 +181,31 @@ LParse_objc(int i) {
return old; return old;
} }
/* -----------------------------------------------------------------------------
* LParse_error(DOH *file, int line, char *fmt, ...)
* ----------------------------------------------------------------------------- */
static DOH *macro_name = 0; static DOH *macro_name = 0;
static DOH *macro_file = 0; static DOH *macro_file = 0;
static int macro_line = 0; static int macro_line = 0;
void LParse_macro_location(DOH *name, DOH *file, int line) { /* -----------------------------------------------------------------------------
* LParse_macro_location()
*
* Set the location of a macro when parsing macro text.
* ----------------------------------------------------------------------------- */
void
LParse_macro_location(DOH *name, DOH *file, int line) {
macro_name = name; macro_name = name;
macro_file = file; macro_file = file;
macro_line = line; macro_line = line;
} }
void LParse_error(DOH *file, int line, char *fmt, ...) {
/* -----------------------------------------------------------------------------
* LParse_error()
*
* Report an error.
* ----------------------------------------------------------------------------- */
void
LParse_error(DOH *file, int line, char *fmt, ...) {
va_list ap; va_list ap;
va_start(ap,fmt); va_start(ap,fmt);
if (!file) { if (!file) {
@ -177,11 +226,13 @@ void LParse_error(DOH *file, int line, char *fmt, ...) {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* LParse_skip_balanced() - Skip over some text * LParse_skip_balanced()
*
* Skip over text enclosed in balanced characters (), [], <>, etc...
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
DOH * DOH *
LParse_skip_balanced(int startchar, int endchar) LParse_skip_balanced(int startchar, int endchar) {
{
DOH *file; DOH *file;
int line; int line;
file = SwigScanner_get_file(cscanner); file = SwigScanner_get_file(cscanner);
@ -192,8 +243,11 @@ LParse_skip_balanced(int startchar, int endchar)
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* LParse_skip_semi() - Skip to the next semicolon * LParse_skip_semi()
*
* Skip to the next semi-colon
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
void void
LParse_skip_semi() { LParse_skip_semi() {
int t, line; int t, line;
@ -208,6 +262,12 @@ LParse_skip_semi() {
LParse_error(file,line,"Missing semicolon. Reached the end of input.\n"); LParse_error(file,line,"Missing semicolon. Reached the end of input.\n");
} }
/* -----------------------------------------------------------------------------
* LParse_skip_decl()
*
* Skip the current declaration (terminated by either a semicolon or }
* ----------------------------------------------------------------------------- */
void void
LParse_skip_decl() { LParse_skip_decl() {
int t, line, level = 0; int t, line, level = 0;
@ -232,7 +292,9 @@ LParse_skip_decl() {
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* int lparse_yylex() - Entry point called by the parser * yylex1()
*
* Get next token.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static int static int
yylex1(void) { yylex1(void) {
@ -377,7 +439,14 @@ yylex1(void) {
return(l1); return(l1);
} }
int lparse_yylex() { /* -----------------------------------------------------------------------------
* lparse_yylex()
*
* main entry point for the parser
* ----------------------------------------------------------------------------- */
int
lparse_yylex() {
int t; int t;
t = yylex1(); t = yylex1();
/* printf("%d\n",t); */ /* printf("%d\n",t); */