Skip to content

docs(parser): add CST Structure section to README#473

Open
harshanacz wants to merge 1 commit into
SAP:masterfrom
harshanacz:docs/cst-structure-readme
Open

docs(parser): add CST Structure section to README#473
harshanacz wants to merge 1 commit into
SAP:masterfrom
harshanacz:docs/cst-structure-readme

Conversation

@harshanacz

Copy link
Copy Markdown

Summary

Add a new CST Structure subsection under Usage in packages/parser/README.md with a comprehensive JSON example showing the Chevrotain CST output for nested XML elements.

The example covers:

  • Root element with open/close tags (OPEN, Name, START_CLOSE, SLASH_OPEN, END_NAME, END)
  • Nested content node containing child elements
  • Child element with attribute (Name, EQUALS, STRING) and chardata (TEXT)
  • Self-closing element (SLASH_CLOSE)

The structure accurately reflects:

  • The grammar rules in packages/parser/lib/parser.js
  • The ElementCtx, AttributeCtx, ContentCtx, and ChardataCtx type definitions in packages/parser/api.d.ts
  • Chevrotain's array-of-tokens convention

Closes #470

Add a new 'CST Structure' subsection under 'Usage' with a concrete
JSON example showing the Chevrotain CST output for a self-closing
element (<xs:element name="api" />). The example accurately reflects
the grammar rules in parser.js and the type definitions in api.d.ts.

Closes SAP#470
@harshanacz harshanacz force-pushed the docs/cst-structure-readme branch from b210a26 to 2923713 Compare July 9, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add CST structure example and explanation to @xml-tools/parser README

1 participant