more line counting fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@8763 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0f147b997e
commit
961d9a4e08
3 changed files with 57 additions and 36 deletions
|
|
@ -41,6 +41,7 @@ static int yylen = 0;
|
||||||
int cparse_line = 1;
|
int cparse_line = 1;
|
||||||
char *cparse_file;
|
char *cparse_file;
|
||||||
int cparse_start_line = 0;
|
int cparse_start_line = 0;
|
||||||
|
|
||||||
static int comment_start;
|
static int comment_start;
|
||||||
static int scan_init = 0;
|
static int scan_init = 0;
|
||||||
static int num_brace = 0;
|
static int num_brace = 0;
|
||||||
|
|
@ -49,7 +50,7 @@ static int last_id = 0;
|
||||||
static int rename_active = 0;
|
static int rename_active = 0;
|
||||||
static int swigtemplate_active = 0;
|
static int swigtemplate_active = 0;
|
||||||
int cparse_cplusplus = 0;
|
int cparse_cplusplus = 0;
|
||||||
|
static int expanding_macro = 0;
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_cparse_cplusplus()
|
* Swig_cparse_cplusplus()
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
@ -66,6 +67,22 @@ Swig_cparse_cplusplus(int v) {
|
||||||
* @filename,line,id@ emitted by the SWIG preprocessor. They
|
* @filename,line,id@ emitted by the SWIG preprocessor. They
|
||||||
* are primarily used for macro line number reporting
|
* are primarily used for macro line number reporting
|
||||||
* ---------------------------------------------------------------------- */
|
* ---------------------------------------------------------------------- */
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
/* we just use the locator to mark when active/deactive the linecounting */
|
||||||
|
|
||||||
|
static void
|
||||||
|
scanner_locator(String *loc) {
|
||||||
|
if (Equal(loc,"@SWIG@")) {
|
||||||
|
/* End locator. */
|
||||||
|
expanding_macro = 0;
|
||||||
|
} else {
|
||||||
|
/* Begin locator. */
|
||||||
|
expanding_macro = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
typedef struct Locator {
|
typedef struct Locator {
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
@ -133,6 +150,7 @@ scanner_locator(String *loc) {
|
||||||
Delete(fn);
|
Delete(fn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**************************************************************
|
/**************************************************************
|
||||||
* scanner_init()
|
* scanner_init()
|
||||||
|
|
@ -216,7 +234,7 @@ char nextchar() {
|
||||||
yytext[yylen] = c;
|
yytext[yylen] = c;
|
||||||
yylen++;
|
yylen++;
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
cparse_line++;
|
if (!expanding_macro) cparse_line++;
|
||||||
}
|
}
|
||||||
return(c);
|
return(c);
|
||||||
}
|
}
|
||||||
|
|
@ -228,7 +246,7 @@ void retract(int n) {
|
||||||
if (yylen >= 0) {
|
if (yylen >= 0) {
|
||||||
Ungetc(yytext[yylen],LEX_in);
|
Ungetc(yytext[yylen],LEX_in);
|
||||||
if (yytext[yylen] == '\n') {
|
if (yytext[yylen] == '\n') {
|
||||||
cparse_line--;
|
if (!expanding_macro) cparse_line--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -304,7 +322,7 @@ skip_balanced(int startchar, int endchar) {
|
||||||
case 0:
|
case 0:
|
||||||
if (c == startchar) num_levels++;
|
if (c == startchar) num_levels++;
|
||||||
else if (c == endchar) num_levels--;
|
else if (c == endchar) num_levels--;
|
||||||
else if (c == '/') state = 10;
|
else if (c == '/') state = 10;
|
||||||
else if (c == '\"') state = 20;
|
else if (c == '\"') state = 20;
|
||||||
else if (c == '\'') state = 30;
|
else if (c == '\'') state = 30;
|
||||||
break;
|
break;
|
||||||
|
|
@ -363,9 +381,14 @@ skip_balanced(int startchar, int endchar) {
|
||||||
void skip_decl(void) {
|
void skip_decl(void) {
|
||||||
char c;
|
char c;
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
int start_line = cparse_line;
|
||||||
|
|
||||||
while (!done) {
|
while (!done) {
|
||||||
if ((c = nextchar()) == 0) {
|
if ((c = nextchar()) == 0) {
|
||||||
Swig_error(cparse_file,cparse_line - 2,"Missing semicolon. Reached end of input.\n");
|
if (!Swig_error_count()) {
|
||||||
|
Swig_error(cparse_file,start_line - 1,"Missing semicolon. Reached end of input.\n");
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c == '{') {
|
if (c == '{') {
|
||||||
|
|
@ -379,7 +402,9 @@ void skip_decl(void) {
|
||||||
if (!done) {
|
if (!done) {
|
||||||
while (num_brace > last_brace) {
|
while (num_brace > last_brace) {
|
||||||
if ((c = nextchar()) == 0) {
|
if ((c = nextchar()) == 0) {
|
||||||
Swig_error(cparse_file,cparse_line - 2,"Missing '}'. Reached end of input.\n");
|
if (!Swig_error_count()) {
|
||||||
|
Swig_error(cparse_file,start_line - 1,"Missing '}'. Reached end of input.\n");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c == '{') num_brace++;
|
if (c == '{') num_brace++;
|
||||||
|
|
@ -662,20 +687,17 @@ int yylook(void) {
|
||||||
Putc(c,comment);
|
Putc(c,comment);
|
||||||
state = 13;
|
state = 13;
|
||||||
} else if (c == '/') {
|
} else if (c == '/') {
|
||||||
|
|
||||||
/* Look for locator markers */
|
/* Look for locator markers */
|
||||||
if (0) {
|
char *loc = Char(comment);
|
||||||
char *loc = Char(comment);
|
if (loc && (strncmp(loc,"@SWIG",4) == 0)&& (*(loc+Len(comment)-1) == '@')) {
|
||||||
if (Len(comment)) {
|
/* Locator */
|
||||||
if ((*loc == '@') && (*(loc+Len(comment)-1) == '@')) {
|
scanner_locator(comment);
|
||||||
/* Locator */
|
Clear(comment);
|
||||||
scanner_locator(comment);
|
state = 0;
|
||||||
}
|
} else {
|
||||||
}
|
yylen = 0;
|
||||||
|
state = 0;
|
||||||
}
|
}
|
||||||
/* yycomment(Char(comment),comment_start,column_start); */
|
|
||||||
yylen = 0;
|
|
||||||
state = 0;
|
|
||||||
} else {
|
} else {
|
||||||
Putc('*',comment);
|
Putc('*',comment);
|
||||||
Putc(c,comment);
|
Putc(c,comment);
|
||||||
|
|
|
||||||
|
|
@ -1530,12 +1530,7 @@ declaration : swig_directive { $$ = $1; }
|
||||||
| error {
|
| error {
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
if (!Swig_error_count()) {
|
if (!Swig_error_count()) {
|
||||||
static int last_error_line = -1;
|
Swig_error(cparse_file, cparse_line,"Syntax error in input(1).\n");
|
||||||
if (last_error_line != cparse_line) {
|
|
||||||
Swig_error(cparse_file, cparse_line,"Syntax error in input(1).\n");
|
|
||||||
last_error_line = cparse_line;
|
|
||||||
skip_decl();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Out of class constructor/destructor declarations */
|
/* Out of class constructor/destructor declarations */
|
||||||
|
|
@ -3087,7 +3082,9 @@ c_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n");
|
if (!Swig_error_count()) {
|
||||||
|
Swig_error(cparse_file,cparse_line,"Syntax error in input(2).\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
@ -3904,14 +3901,11 @@ cpp_members : cpp_member cpp_members {
|
||||||
}
|
}
|
||||||
| empty { $$ = 0;}
|
| empty { $$ = 0;}
|
||||||
| error {
|
| error {
|
||||||
|
int start_line = cparse_line;
|
||||||
skip_decl();
|
skip_decl();
|
||||||
{
|
if (!Swig_error_count()) {
|
||||||
static int last_error_line = -1;
|
Swig_error(cparse_file,start_line,"Syntax error in input(3).\n");
|
||||||
if (last_error_line != cparse_line) {
|
}
|
||||||
Swig_error(cparse_file, cparse_line,"Syntax error in input(3).\n");
|
|
||||||
last_error_line = cparse_line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} cpp_members {
|
} cpp_members {
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -881,13 +881,18 @@ expand_macro(String *name, List *args)
|
||||||
copy_location(macro,e);
|
copy_location(macro,e);
|
||||||
g = Preprocessor_parse(e);
|
g = Preprocessor_parse(e);
|
||||||
|
|
||||||
/* Drop the macro in place, but with a marker around it */
|
|
||||||
#if 0
|
#if 0
|
||||||
|
/* Drop the macro in place, but with a marker around it */
|
||||||
Printf(f,"/*@%s,%d,%s@*/%s/*@@*/", Getfile(macro), Getline(macro), name, g);
|
Printf(f,"/*@%s,%d,%s@*/%s/*@@*/", Getfile(macro), Getline(macro), name, g);
|
||||||
#else
|
#else
|
||||||
Append(f,g);
|
/* Use simplified around markers to properly count lines in cscanner.c */
|
||||||
|
if (strstr(Char(g),"\n")) {
|
||||||
|
Printf(f,"/*@SWIG:%s@*/%s/*@SWIG@*/", name, g);
|
||||||
|
} else {
|
||||||
|
StringAppend(f,g);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Printf(f," }\n"); */
|
|
||||||
Delete(g);
|
Delete(g);
|
||||||
Delete(e);
|
Delete(e);
|
||||||
e = f;
|
e = f;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue