Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text in comments should not be highlighted #1

Open
andyli opened this issue Jun 28, 2018 · 0 comments
Open

Text in comments should not be highlighted #1

andyli opened this issue Jun 28, 2018 · 0 comments

Comments

@andyli
Copy link

andyli commented Jun 28, 2018

class Test {
    static function main() {
        var code = '
            /*
            * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
            * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
            * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
            * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
            * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
            * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
            * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
            * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
            * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
            * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
            * DAMAGE.
            */
        ';
        var html = highlighter.Highlighter.syntaxHighlightHaxe(code);
        trace(html);
    }
}

The above code gives runtime error for Neko:

Called from ? line 1
Called from Test.hx line 18
Called from highlighter/Highlighter.hx line 70
Called from /home/andy/.opam/4.06.1/share/haxe/std/neko/_std/EReg.hx line 105
Uncaught exception - An error occurred while running pcre_exec
Error: Command failed with error 1

It is because the content of the comment are highlighted and apparently too complex for the neko regexp to handle. For other targets, e.g. --interp, the output is:

src/Test.hx:19:
            <span class=cmt>/*
            * <span class=type>THIS</span> <span class=type>SOFTWARE</span> <span class=type>IS</span> <span class=type>PROVIDED</span> <span class=type>BY</span> <span class=type>THE</span> <span class=type>HAXE</span> <span class=type>PROJECT</span> <span class=type>CONTRIBUTORS</span> <span class=str>"<span class=type>AS</span> <span class=type>IS</span>"</span> <span class=type>AND</span> <span class=type>ANY</span>
            * <span class=type>EXPRESS</span> <span class=type>OR</span> <span class=type>IMPLIED</span> <span class=type>WARRANTIES</span>, <span class=type>INCLUDING</span>, <span class=type>BUT</span> <span class=type>NOT</span> <span class=type>LIMITED</span> <span class=type>TO</span>, <span class=type>THE</span> <span class=type>IMPLIED</span>
            * <span class=type>WARRANTIES</span> <span class=type>OF</span> <span class=type>MERCHANTABILITY</span> <span class=type>AND</span> <span class=type>FITNESS</span> <span class=type>FOR</span> <span class=type>A</span> <span class=type>PARTICULAR</span> <span class=type>PURPOSE</span> <span class=type>ARE</span>
            * <span class=type>DISCLAIMED</span>. <span class=type>IN</span> <span class=type>NO</span> <span class=type>EVENT</span> <span class=type>SHALL</span> <span class=type>THE</span> <span class=type>HAXE</span> <span class=type>PROJECT</span> <span class=type>CONTRIBUTORS</span> <span class=type>BE</span> <span class=type>LIABLE</span> <span class=type>FOR</span>
            * <span class=type>ANY</span> <span class=type>DIRECT</span>, <span class=type>INDIRECT</span>, <span class=type>INCIDENTAL</span>, <span class=type>SPECIAL</span>, <span class=type>EXEMPLARY</span>, <span class=type>OR</span> <span class=type>CONSEQUENTIAL</span>
            * <span class=type>DAMAGES</span> (<span class=type>INCLUDING</span>, <span class=type>BUT</span> <span class=type>NOT</span> <span class=type>LIMITED</span> <span class=type>TO</span>, <span class=type>PROCUREMENT</span> <span class=type>OF</span> <span class=type>SUBSTITUTE</span> <span class=type>GOODS</span> <span class=type>OR</span>
            * <span class=type>SERVICES</span>; <span class=type>LOSS</span> <span class=type>OF</span> <span class=type>USE</span>, <span class=type>DATA</span>, <span class=type>OR</span> <span class=type>PROFITS</span>; <span class=type>OR</span> <span class=type>BUSINESS</span> <span class=type>INTERRUPTION</span>) <span class=type>HOWEVER</span>
            * <span class=type>CAUSED</span> <span class=type>AND</span> <span class=type>ON</span> <span class=type>ANY</span> <span class=type>THEORY</span> <span class=type>OF</span> <span class=type>LIABILITY</span>, <span class=type>WHETHER</span> <span class=type>IN</span> <span class=type>CONTRACT</span>, <span class=type>STRICT</span>
            * <span class=type>LIABILITY</span>, <span class=type>OR</span> <span class=type>TORT</span> (<span class=type>INCLUDING</span> <span class=type>NEGLIGENCE</span> <span class=type>OR</span> <span class=type>OTHERWISE</span>) <span class=type>ARISING</span> <span class=type>IN</span> <span class=type>ANY</span> <span class=type>WAY</span>
            * <span class=type>OUT</span> <span class=type>OF</span> <span class=type>THE</span> <span class=type>USE</span> <span class=type>OF</span> <span class=type>THIS</span> <span class=type>SOFTWARE</span>, <span class=type>EVEN</span> <span class=type>IF</span> <span class=type>ADVISED</span> <span class=type>OF</span> <span class=type>THE</span> <span class=type>POSSIBILITY</span> <span class=type>OF</span> <span class=type>SUCH</span>
            * <span class=type>DAMAGE</span>.
            */</span>

This is one source of some internal server errors found in lib.haxe.org. e.g. http://lib.haxe.org/p/HUGS/0.3.0/files/haxe/Log.hx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant