Created
October 15, 2023 23:03
-
-
Save darknoon/38acc36ab3844043e1b241d77b054962 to your computer and use it in GitHub Desktop.
Minimal gbnf for jsx-ish content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Trying to debug why this is slow | |
# root rule | |
root ::= jsxElement | |
# Main JSX Element | |
jsxElement ::= | |
"<" jsxElementName jsxAttributesOpt ">" jsxChildrenOpt "</" jsxElementName ">" | |
# JSX Self-Closing Element | |
jsxSelfClosingElement ::= | |
"<" jsxElementName jsxAttributesOpt "/>" | |
# JSX Element Name (simplified) | |
jsxElementName ::= "div" | "p" | "span" | "a" | "button" | "input" | "label" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | |
# JSX Attributes | |
jsxAttributesOpt ::= (" " jsxAttribute)* | |
jsxAttribute ::= jsxAttributeName "=" jsxAttributeValue | |
jsxAttributeName ::= "className" | |
jsxAttributeValue ::= | |
"\"" [^\"]* "\"" # String Literal | |
# JSX Children | |
jsxChildrenOpt ::= jsxChild+ | |
jsxChild ::= | |
jsxText | | |
jsxElement | | |
jsxSelfClosingElement | |
# JSX Text (simplified) | |
jsxText ::= [^<>{]+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment