Mercurial Hosting > luan
comparison core/src/luan/impl/LuanParser.java @ 247:b5995d77878a
fix parsing of comments
git-svn-id: https://luan-java.googlecode.com/svn/trunk@248 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Fri, 10 Oct 2014 14:21:45 +0000 |
parents | 2ed8465a9d62 |
children | e0fb8a49e031 |
comparison
equal
deleted
inserted
replaced
246:58752e3e4c5c | 247:b5995d77878a |
---|---|
225 | 225 |
226 private boolean StmtSep(List<Stmt> stmts) throws ParseException { | 226 private boolean StmtSep(List<Stmt> stmts) throws ParseException { |
227 parser.begin(); | 227 parser.begin(); |
228 if( parser.match( ';' ) ) | 228 if( parser.match( ';' ) ) |
229 return parser.success(); | 229 return parser.success(); |
230 if( parser.match( "--" ) ) { | |
231 while( parser.noneOf("\r\n") ); | |
232 } | |
233 if( EndOfLine() ) | 230 if( EndOfLine() ) |
234 return parser.success(); | 231 return parser.success(); |
235 parser.rollback(); | 232 parser.rollback(); |
236 Stmt stmt = TemplateStmt(); | 233 Stmt stmt = TemplateStmt(); |
237 if( stmt != null ) { | 234 if( stmt != null ) { |
1347 } | 1344 } |
1348 return parser.failure(null); | 1345 return parser.failure(null); |
1349 } | 1346 } |
1350 | 1347 |
1351 private void Spaces(In in) throws ParseException { | 1348 private void Spaces(In in) throws ParseException { |
1352 while( parser.anyOf(" \t") || Comment() || ContinueOnNextLine() || in.parens && NewLine() ); | 1349 while( parser.anyOf(" \t") || Comment() || ContinueOnNextLine() || in.parens && EndOfLine() ); |
1353 } | 1350 } |
1354 | 1351 |
1355 private boolean ContinueOnNextLine() { | 1352 private boolean ContinueOnNextLine() { |
1356 parser.begin(); | 1353 parser.begin(); |
1357 return parser.match('\\') && EndOfLine() ? parser.success() : parser.failure(); | 1354 return parser.match('\\') && EndOfLine() ? parser.success() : parser.failure(); |
1358 } | 1355 } |
1359 | 1356 |
1360 private boolean NewLine() { | 1357 private boolean Comment() throws ParseException { |
1361 if( !EndOfLine() ) | 1358 if( LongComment() ) |
1362 return false; | 1359 return true; |
1363 if( parser.match("--") ) { | 1360 if( parser.match("--") ) { |
1364 while( parser.noneOf("\r\n") ); | 1361 while( parser.noneOf("\r\n") ); |
1365 } | 1362 return true; |
1366 return true; | 1363 } |
1367 } | 1364 return false; |
1368 | 1365 } |
1369 private boolean Comment() throws ParseException { | 1366 |
1367 private boolean LongComment() throws ParseException { | |
1370 parser.begin(); | 1368 parser.begin(); |
1371 if( !parser.match("--[") ) | 1369 if( !parser.match("--[") ) |
1372 return parser.failure(); | 1370 return parser.failure(); |
1373 int start = parser.currentIndex(); | 1371 int start = parser.currentIndex(); |
1374 while( parser.match('=') ); | 1372 while( parser.match('=') ); |