File tree Expand file tree Collapse file tree 7 files changed +56
-0
lines changed
Expand file tree Collapse file tree 7 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -232,9 +232,15 @@ std::vector<Token> tokenize(const std::string &source)
232232 t.text .push_back (c);
233233 }
234234 } else if (c == ' %' ) {
235+ if (i+1 >= source.length ()) {
236+ break ;
237+ }
235238 if (source.at (i+1 ) == ' |' ) {
236239 int level = 0 ;
237240 do {
241+ if (i+1 >= source.length ()) {
242+ error (t, " Missing closing comment '|%'" );
243+ }
238244 if (source.at (i) == ' %' && source.at (i+1 ) == ' |' ) {
239245 level++;
240246 i += 2 ;
Original file line number Diff line number Diff line change 1+ %! Missing closing comment '|%'
2+
3+ %| Block Comment, without proper ending comment token.
Original file line number Diff line number Diff line change 1+ %! Missing closing comment '|%'
2+
3+ %| This test is specifically designed to BEGIN the Block-Comment ending token,
4+ but leaving off the last part of it, as well as ANY other data in the file.
5+ This will test the lexers ability to handle a case where it THINKS the
6+ token is ABOUT to end, but it does not, which is why there is NO LF at the
7+ end of this file, and why the test result appears at the top. |%
8+
9+ %| Block Comment, without proper ending comment token.|
Original file line number Diff line number Diff line change 1+ %! Missing closing comment '|%'
2+
3+ %| Block Comment, without proper ending comment token.%|
Original file line number Diff line number Diff line change 1+ %! Missing closing comment '|%'
2+
3+ %| Block Comment, without proper ending comment token.%|%%
Original file line number Diff line number Diff line change 1+ %= Passed.
2+
3+ %| This test is testing the COMMENT token on the last line of a source file.
4+ A line that does not end, thus making sure the lexer lexes the line properly
5+ and prints the correct "Test Passed" message to the test harness. |%
6+
7+ print("Passed.")%
Original file line number Diff line number Diff line change 1+ %|--------------------------------------------------------------------------|%
2+ %| Testing "FlowerBox Comments..." |%
3+ %| Test Set : comments.simple |%
4+ %| Created On : 2014-10-21 |%
5+ %| Updated On : 2014-10-21 |%
6+ %| Created By : Larry Frieson |%
7+ %|--------------------------------------------------------------------------|%
8+ print("FlowerBox Comments ok.")
9+ %= FlowerBox Comments ok.
10+
11+ % Regular Simple-Lang comments...
12+ print("Regular Comments ok.")
13+
14+ %= Regular Comments ok.
15+
16+ %|
17+ %|
18+ %|
19+ Testing Nested Comments...
20+ |%
21+ |%
22+ |%
23+
24+ print("Nested Comments ok.")
25+ %= Nested Comments ok.
You can’t perform that action at this time.
0 commit comments