Skip to content

Automatically generate the grammar overview#2135

Merged
andralex merged 3 commits intodlang:masterfrom
wilzbach:generate-grammar
Jan 29, 2018
Merged

Automatically generate the grammar overview#2135
andralex merged 3 commits intodlang:masterfrom
wilzbach:generate-grammar

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Jan 28, 2018

I guess that tells all?

61 additions and 1,851 deletions.

This isn't perfect yet, but already pretty cool.

TODO:

There are 8 new modules which contained D grammar which have been forgotten.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

}
}
return entries;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is copied from the footer generation. I plan to move the footer generation to this script too, see e.g. #2061 (but that isn't a top priority as the footer already exists and we don't add new pages frequently).

auto ps = line.splitter(ddocEntryStart).dropOne.front.splitter(",");
auto name = ps.front.stripExtension.withExtension(".dd").to!string;
auto fileName = specDir.buildPath(name);
auto title = ps.dropOne.front.idup.strip;
Copy link
Contributor Author

@wilzbach wilzbach Jan 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to have shift - front and popFront in one step.

{
foreach (i, entry; specTocEntries)
{
if (entry.fileName.endsWith("grammar.dd", "lex.dd", "simd.dd"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • sim.dd defines this:
$(GRAMMAR
$(I typeNN)
)
  • lex.dd is excluded in the current spec

image

@wilzbach wilzbach changed the title [WIP] Automatically generate the grammar overview Automatically generate the grammar overview Jan 29, 2018
@wilzbach wilzbach removed the WIP label Jan 29, 2018
Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa that's great work!!

@andralex andralex merged commit a816a21 into dlang:master Jan 29, 2018
@wilzbach wilzbach deleted the generate-grammar branch January 29, 2018 11:44
@CyberShadow
Copy link
Member

@wilzbach
I noticed https://dlang.org/spec/grammar.html has some broken links (e.g. what __PRETTY_FUNCTION__ links to) and I don't understand why. When I look at the original location for that grammar block, in lex, it looks fine (in lex.verbatim it shows as $(LINK2 expression.html#specialkeywords, $(D __PRETTY_FUNCTION__))). But in grammar.verbatim it shows up as $(D $(RELATIVE_LINK2 specialkeywords, __PRETTY_FUNCTION__)). I don't know where the RELATIVE_LINK2 is coming from.

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.

4 participants

Comments