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

Grammar railroad diagram #448

Closed
mingodad opened this issue Oct 23, 2024 · 1 comment
Closed

Grammar railroad diagram #448

mingodad opened this issue Oct 23, 2024 · 1 comment

Comments

@mingodad
Copy link

Looking for a railroad diagram for the Swift language I did converted you grammar and https://github.com/swiftlang/swift-book/blob/main/TSPL.docc/ReferenceManual/SummaryOfTheGrammar.md and it seems that there is several missing items on the official documentation.

See here swiftlang/swift-book#337 .

@alex-pinkus
Copy link
Owner

There are a few reasons why this doesn’t match the official grammar. One is that, for reasons of parsing latency, some of the constructs in the grammar have to be simplified to reduce the number of unique parsing states (pattern matching, for instance) — this is done in places where we can make the grammar more permissive without losing specificity. Another is that the actual Swift compiler seems to encode a variety of precedence rules that don’t make it into the grammar, so ambiguous cases would be handled differently between the compiler and a strictly translated version of the grammar. Another third reason is that simply isn’t what I started with when I built this as a hobby project, so the names differ for things I added early.

If you have specific missing features you need then please list them, but simply linking to an issue describing the EBNF for the two grammars is not particularly actionable for me.

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

2 participants