HaxeCheckstyle / haxeparser

A Haxe parser for Haxe
61 stars 23 forks source link

Bad comment after block handling #6

Closed mcheshkov closed 10 years ago

mcheshkov commented 10 years ago

This code breaks haxelib version of parser with MissingSemicolon.

package haxelint;

class Test {
    function main() {
        if(true){
            trace("ok");
        }
        //
    }
}

That happens because semicolon() uses last.tok and comment tokens are junked out inside the peek, replacing actual last token.

Simn commented 10 years ago

Thanks for reporting. I came across this as well but tried to forget about it because it likely means rewriting the token caching mechanism.

mcheshkov commented 10 years ago

In haxe implementation, Comment tokens are filtered out in Stream.from, so before any stream peek or junk know about it. I used Stream subclass, with constructor taking that function and caching inside stream, it's pretty simple

mcheshkov commented 10 years ago

Didnt realise that Stream Is my code, not library. I'll try to make pull request for this in couple of days.

Simn commented 10 years ago

Thanks!