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

Update HTMLLexer.g4 #4092

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update HTMLLexer.g4 #4092

wants to merge 1 commit into from

Conversation

appt2
Copy link

@appt2 appt2 commented May 13, 2024

Screenshot_2024-05-13-14-26-27-869_Ninja coder Ghostemane code

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.

@kaby76
Copy link
Contributor

kaby76 commented May 13, 2024

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.

@appt2
Copy link
Author

appt2 commented May 13, 2024

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

@appt2
Copy link
Author

appt2 commented May 13, 2024

@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
Copy link
Contributor

kaby76 commented May 13, 2024

@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!

@teverett teverett added the html label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants