grammars-v4 icon indicating copy to clipboard operation
grammars-v4 copied to clipboard

Html Grammer error

Open appt2 opened this issue 1 year ago • 1 comments

Screenshot_2023-11-21-13-38-50-743_Ninja coder Ghostemane code Grammar error Hello, I am using your Html grammar and the style tag and script are not colored like other tags.

appt2 avatar Nov 21 '23 11:11 appt2

The fact that you haven't gotten any responses from any of your issues here, is most likely because you're simply posting images/videos of things you observe. It is not clear how you've reached the state that you post an image/video of. It could very well be that you're invoking the wrong parser rule, or that there is a bug in your code that is responsible for coloring the HTML.

If I run the following code:

import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;

public class HTMLDemo {
    
    public static void main(String[] args) {
    
        String html = "<html>\n" +
                "  <head>\n" +
                "    <style>\n" +
                "      color : read;\n" +
                "      position :0;\n" +
                "      \n" +
                "    </style>\n" +
                "    <script>\n" +
                "      window.getElement(){\n" +
                "        {\n" +
                "        \n" +
                "      }\n" +
                "      }\n" +
                "    </script>\n" +
                "  </head>\n" +
                "  <body>\n" +
                "    <h1> </h1>\n" +
                "  </body>\n" +
                "</html>";

        HTMLLexer lexer = new HTMLLexer(CharStreams.fromString(html));
        HTMLParser parser = new HTMLParser(new CommonTokenStream(lexer));
        ParseTree root = parser.htmlDocument();
        System.out.println(root.toStringTree(parser));
    }
}

I get no error. So my guess is that you're doing something wrong that causes the colors to be off.

bkiers avatar Dec 28 '23 13:12 bkiers