|
[#1180] |
project: compiler |
priority: medium |
category: bug |
|
submitter |
assigned to |
status |
date submitted |
|
Nikolay |
Lex |
fixed |
2007-06-17 19:01:10.0 |
subject |
[contrib #653] scanner can fall to endless loop |
code |
in CharArrayReader.scala:53
def next: Char = {
//cline = nextline
//ccol = nextcol
if(!hasNext)
return SU // there is an endless stream of SU's at the end
oldBp = bp
oldCh = ch;
ch = buf(bp)
in Scanners.scala:395
private def fetchToken(): unit = {
if (token == EOF) return
lastPos = in.cpos - 1 // Position.encode(in.cline, in.ccol)
//var index = bp
while (true) {
in.ch match {
case ' ' | '\t' | CR | LF | FF =>
in.next |
what happened |
when called nextToken at end of file, endless loop begins in fetchToken. This is due of in.ch not updated and un\
conditional while(true) loop executed. token never set to EOF due of SU (SU never assigned to in.ch)
|
what expected |
chararray should set ch to SU and optionally while(true) should be replaced while(in.hasNext)
minimal fix:
def next: Char = {
//cline = nextline
//ccol = nextcol
if(!hasNext) {
ch = SU
return SU // there is an endless stream of SU's at the end
}
|
[back to overview] |