grammars-v4
grammars-v4 copied to clipboard
Update HTMLLexer.g4
Hello, I created one of the most complete and professional grammars possible for the web. You can use this grammar for html, js, css, and sass. It supports several programming languages in one grammar. You can make your own changes in it. The fact is this. I can't make a parser, I leave it to you, the final output is shown in the image I posted, I hope you accept these changes and I will be motivated to create more and better grammars.
The fact is this. I can't make a parser, I leave it to you,
All grammars in this repo are for parsers, so a grammar that is just for lexing is new. One solution is to just have a parser grammar that accepts all tokens: parser grammar HTMLParser; options { tokenVocab = HTMLLexer; } htmlDocument : .*? EOF;
. If you want to add this, make a new directory html/, and move the old html/ grammar to html/ohtml/, and add your new grammar in html/html/.
That said, there are problems with your lexer grammar. There are a half-dozen warnings from the Antlr Tool on this grammar.
$ antlr4 *.g4
warning(184): HTMLLexer.g4:1202:0: One of the token Colon values unreachable. : is always overlapped by token Colen
warning(184): HTMLLexer.g4:1230:0: One of the token Hash values unreachable. # is always overlapped by token HASHSTYLE
warning(184): HTMLLexer.g4:466:0: One of the token HtmlAttr values unreachable. pattern is always overlapped by token HtmlTags
warning(184): HTMLLexer.g4:466:0: One of the token HtmlAttr values unreachable. oncanplaythrough is always overlapped by token HtmlAttr
warning(184): HTMLLexer.g4:466:0: One of the token HtmlAttr values unreachable. rows is always overlapped by token HtmlAttr
warning(146): HTMLLexer.g4:288:0: non-fragment lexer rule COLORUPPERCASE can match the empty string
These indicate string literal overlap, which is not acceptable. I plan to add a switch to treat all warnings as errors in the future, which means the grammar won't pass testing.
Hello, thank you for your reply. In the next few hours, I will create a new folder in my repository and try again to request a pull
@kaby76 G4Compiler
This is my grammar executor I get error from here I don't do it, at least in the log cat of my program
@kaby76 G4Compiler
This is my grammar executor I get error from here I don't do it, at least in the log cat of my program
You need to add your listener before calling the tool to compile each .g4!