grammars-v4
grammars-v4 copied to clipboard
Html Grammer error
Grammar error Hello, I am using your Html grammar and the style tag and script are not colored like other tags.
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.