[swift-dev] Making sense of Swift AST - pattern_binding_decl and var_decl

Slava Pestov spestov at apple.com
Fri Dec 18 15:52:25 CST 2015


I'm still learning, but I think its just the distinction between introducing the name and performing the name binding. Consider this example,

let (x, y) = (1, 2)

This parses into one PatternBindingDecl and two VarDecls.

Slava

> On Dec 18, 2015, at 8:08 AM, Lee M via swift-dev <swift-dev at swift.org> wrote:
> 
> With the code: var foo = true, swift parses this into the following AST:
> 
> (pattern_binding_decl
>     (pattern_named 'foo')
>     (boolean_literal_expr type='<null>' value=true))
> (var_decl "foo" type='<null type>' storage_kind=stored)))
> 
> I'm wondering why VarDecl and PatternBindingDecl are separate nodes in the tree and not nested somehow, as they both represent similar things..?
> 
> Might be a trivial question as I'm not a compiler guru. I'm porting parts of the AST representation to another language for a project.
> 
> Thanks!
>  _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151218/78b82c15/attachment.html>


More information about the swift-dev mailing list