Swift Grammar

Hello everyone! I’d like to know something:

  • First, is Swift’s grammar context-free or is It context-sensitive? (I don’t mean any part of the language, but the whole language)

  • Secondly, if the grammar is context-free, what algorithm is used to parse the language? (LR, LL, LALR, GLR, SLR)

2 Likes

You can find the grammar in the book.

Swift’s parser is a hand-coded (non-naive) recursive descent parser. You can read the headers and implementation.

1 Like