ecmarkup icon indicating copy to clipboard operation
ecmarkup copied to clipboard

Grammarkdown 2.2.5 new features may help with linting/diagnostics

Open rbuckton opened this issue 3 years ago • 1 comments

@bakkot I've added a few features to grammarkdown that may be useful for ecmarkup linting:

  • Significant indentation gets reset after each grammarkdown top-level element is parsed
  • @define directives only apply to the lines that follow, and can be reset
  • New @line directives allow you to customize what grammarkdown reports for diagnostic messages

You can read more about them in the release info here: https://github.com/rbuckton/grammarkdown/releases/tag/2.2.5

In summary, the goal is that you could extract the entire grammar of an ecmarkup file into a single grammarkdown file for the purposes of checking/linting:

spec.html

<emu-clause id="...">
  <h1>Syntax</h1>
  <emu-grammar>
    Production :
      Nonterminal1
      Nonterminal2
  </emu-grammar>
  <emu-clause id="...">
    <h1>Static Semantics</h1>
    <emu-grammar>Production : Nonterminal1</emu-grammar>
  </emu-clause>
</emu-clause>

spec.html.grammarkdown (generated)

@line 4 "spec.html"
    Production :
      Nonterminal1
      Nonterminal2
@define noStrictParametricProductions true
@line 10 "spec.html"
                 Production : Nontermnal1
@define noStrictParametricProductions default

I'm also considering adding a way to make HTML transformations easier, possibly by adding an @ directive to specify an id attribute in the ecmarkup content generated by grammarkdown so that you might be able to leverage document.getElementById against the JSDOM generated by the output to extract the results.

I added most of these features to support changes I've been working on for my ecmarkup VSCode extension pet project in an effort to make my own life easier, and thought they might be helpful for ecmarkup itself as well.

rbuckton avatar Sep 19 '20 22:09 rbuckton

Neat! I'll play around with this next time I need to tweak the grammar linting process.

bakkot avatar Sep 20 '20 06:09 bakkot