Skip to content

Commit

Permalink
Merge pull request #4221 from MichaelPFrey/2022-04-15-include-use-new…
Browse files Browse the repository at this point in the history
…line

Warning when a \n is found in use<> or include<>.
  • Loading branch information
t-paul committed Apr 18, 2022
2 parents b25862f + fcb9095 commit b9fff2b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/core/lexer.l
Expand Up @@ -149,7 +149,11 @@ LOCATION_NEXT(parserlloc);

include[ \t\r\n]*"<" { BEGIN(cond_include); filepath = filename = ""; LOCATION_COUNT_LINES(parserlloc, yytext); }
<cond_include>{
[\n\r] { LOCATION_ADD_LINES(parserlloc, yyleng); }
[\n\r] {
LOCATION_ADD_LINES(parserlloc, yyleng);
// see merge request #4221
LOG(message_group::Warning,LOCATION(parserlloc),"","new lines in 'include<>'-statement is not defined - behavior may change in the future");
}
[^\t\r\n>]*"/" { filepath = yytext; }
[^\t\r\n>/]+ { filename = yytext; }
">" { BEGIN(INITIAL); includefile(LOCATION(parserlloc)); }
Expand All @@ -159,7 +163,11 @@ include[ \t\r\n]*"<" { BEGIN(cond_include); filepath = filename = ""; LOCATION_C

use[ \t\r\n]*"<" { BEGIN(cond_use); LOCATION_COUNT_LINES(parserlloc, yytext); }
<cond_use>{
[\n\r] { LOCATION_ADD_LINES(parserlloc, yyleng); }
[\n\r] {
LOCATION_ADD_LINES(parserlloc, yyleng);
// see merge request #4221
LOG(message_group::Warning,LOCATION(parserlloc),"","new lines 'use<>'-statement is not defined - behavior may change in the future");
}
[^\t\r\n>]+ { filename = yytext; }
">" {
BEGIN(INITIAL);
Expand Down
2 changes: 1 addition & 1 deletion tests/data/scad/misc/linenumber.scad
@@ -1,7 +1,7 @@
use <line 1> include <line 1>

cube("line 3");

// see merge request #4221 and #4211 for context
include
< line 6
line 7
Expand Down
5 changes: 5 additions & 0 deletions tests/regression/echotest/linenumber-expected.echo
@@ -1,6 +1,11 @@
WARNING: Can't open library 'line 1'. in file ../../tests/data/scad/misc/linenumber.scad, line 1
WARNING: Can't open include file 'line 1'. in file ../../tests/data/scad/misc/linenumber.scad, line 1
WARNING: new lines in 'include<>'-statement is not defined - behavior may change in the future in file ../../tests/data/scad/misc/linenumber.scad, line 7
WARNING: new lines in 'include<>'-statement is not defined - behavior may change in the future in file ../../tests/data/scad/misc/linenumber.scad, line 8
WARNING: new lines in 'include<>'-statement is not defined - behavior may change in the future in file ../../tests/data/scad/misc/linenumber.scad, line 9
WARNING: new lines in 'include<>'-statement is not defined - behavior may change in the future in file ../../tests/data/scad/misc/linenumber.scad, line 10
WARNING: Can't open include file 'line 9'. in file ../../tests/data/scad/misc/linenumber.scad, line 10
WARNING: new lines 'use<>'-statement is not defined - behavior may change in the future in file ../../tests/data/scad/misc/linenumber.scad, line 16
WARNING: Can't open library 'line 16'. in file ../../tests/data/scad/misc/linenumber.scad, line 16
WARNING: Unable to convert cube(size="line 3", ...) parameter to a number or a vec3 of numbers in file linenumber.scad, line 3
WARNING: Unable to convert cube(size="line 12", ...) parameter to a number or a vec3 of numbers in file linenumber.scad, line 12
Expand Down

0 comments on commit b9fff2b

Please sign in to comment.