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

Dynamic naming / name from the input data #168

Open
cmsmcq opened this issue Dec 13, 2022 · 7 comments
Open

Dynamic naming / name from the input data #168

cmsmcq opened this issue Dec 13, 2022 · 7 comments

Comments

@cmsmcq
Copy link
Contributor

cmsmcq commented Dec 13, 2022

Issue 13 suggests allowing different nonterminals to be serialized with the same element or attribute name, in a way that allows the expected name to be determined by inspection of the grammar.

Experience with ixml grammars for parsing XML suggests it may be helpful to contemplate allowing elements and attributes to carry names given in (or more generally derived from) the input stream.

Other use cases:

  • parsing LaTeX and turning \begin{x} ... \end{x} into an element named x. Or more generally, parsing the input language for any similar document formatter (Script, runoff, roff, ...)
  • parsing comma-delimited data streams with header lines

More use cases would be helpful.

Two observations may be in order:

  • This can in fact be handled fairly easily by a downstream transformation (as can the functionality of issue 13).
  • It's easy to imagine specifying the dynamic name using some expression language; that expression language could easily turn into a very steep slippery slope. It may be possible to avoid sliding down that slope by restricting ourselves to the ability expressions with the meaning "the string value of [some specific instance of some specific nonterminal]"; the complexity is then restricted to the problem of pointing to specific instances of specific nonterminals.
@LdBeth
Copy link

LdBeth commented Jan 11, 2023

I have started trying out IXML and encountered similar problem of embedding some markup in the input that can be converted to XML tags in the final form.

I suppose XML with an unconstrained set of tag is not covered by CFG. Actually, if the input is structured (i.e. can be handled by grammar below) it is not necessary to have the closing tag carrying a tag name (by specify -closetag).

line: (text; node)+ .
node: @opentag, text, @closetag

If one wants to verify input is well formed XML, or a “proper” LaTeX markup, it would likely be done in a XSLT post pass.

I think that leads to the demand for an implementation definable extension to IXML that adds the source location to the resulting XML, that for any serious markup development this can be used as concrete syntax tree.

Now, for certain markup design, the closing tag is optional or implicit. One example is GML which influenced HTML to allow the closing </p> become optional. In such cases IXML is more like a lexer and further parsing requires the power of XSLT.

@spemberton
Copy link
Member

spemberton commented Jan 11, 2023 via email

@LdBeth
Copy link

LdBeth commented Jan 11, 2023 via email

@spemberton
Copy link
Member

spemberton commented Jan 11, 2023 via email

@cmsmcq
Copy link
Contributor Author

cmsmcq commented Jan 11, 2023 via email

@cmsmcq
Copy link
Contributor Author

cmsmcq commented Jan 11, 2023 via email

@spemberton
Copy link
Member

spemberton commented Jan 12, 2023 via email

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

No branches or pull requests

3 participants