Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Macro に備えて構文木を 10min で学ぶ / Learn Syntax T...

Kuniwak
August 24, 2023

Swift Macro に備えて構文木を 10min で学ぶ / Learn Syntax Tree for Swift Macro in 10 minutes

来るべき Swift Macro に備えて Swift の構文木について学びましょう。この発表の前半では Swift Macro を定義する際に理解が必要な「構文木」とは何かを初心者向けに説明します。
https://dena.connpass.com/event/291447/

Kuniwak

August 24, 2023
Tweet

More Decks by Kuniwak

Other Decks in Programming

Transcript

  1. 9 @OptionSet<Int> struct Permissions { private enum Perm: Int {

    case read case write case execute 
 } } struct Permissions { private enum Perm: Int { case read case write case execute 
 } static let read: Self = 
 Self(rawValue: 1 << Perm.rea 
 static let write: Self = 
 Self(rawValue: 1 << Perm.wri 
 static let execute: Self = 
 Self(rawValue: 1 << Perm.exe } "UUBDIFE.BDSPͷྫ Attached macro ల։
  2. if let self = self {} if let self =

    self {} JGจ ෳจ ৚݅ 15 JGจ͸ʮ৚݅ʯͱʮෳจʯͰ 
 ߏ੒͞Ε͍ͯΔ
  3. if let self = self {} if let self =

    self {} JGจ ෳจ 0QUJPOଋറ৚݅ 16 ࠓճͷ৚݅෦෼ʹ͸ɺ 
 ʮ0QUJPOଋറ৚݅ʯͱ 
 ݺ͹Ε͍ͯΔ΋ͷ͕ೖΔ
  4. if let self = self {} if let self =

    self {} JGจ ෳจ 0QUJPOଋറ৚݅ ม਺ࣜ ม਺ύλʔϯ if let self = self {} 17 0QUJPOଋറ৚݅͸ɺ୅ೖઌͷ 
 ʮม਺ύλʔϯʯͱ୅ೖ͢Δ஋ͷ 
 ʮม਺ࣜʯͰߏ੒͞Ε͍ͯΔ
  5. if let self = self {} if let self =

    self {} if let self = self {} 18 ͜ͷΑ͏ʹɺίʔυΛ෼ղͯ͠ 
 ߏ੒ཁૉΛḷ͍ͬͯ͘ͱɺ 
 ίʔυΛʮ໦ߏ଄ʯͱͯ͠ 
 ѻ͍ͬͯΔ͜ͱʹؾͮ͘
  6. 19 ෳจ JGจ ෳจ ม਺ύλʔϯ ม਺ࣜ 0QUJPOଋറ৚݅ if let self

    = self {} if let self = self {} if let self = self {}
  7. 22 TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF

    FYFDVUF ղੳ @OptionSet<Int> struct Permissions { private enum Perm: Int { case read case write case execute 
 } }
  8. 23 TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF

    FYFDVUF TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF FYFDVUF ม਺એݴ ॳظԽઅ SFBE  ม਺એݴ ॳظԽઅ XSJU  ม਺એݴ ॳظԽઅ FYFD  ௥Ճ มܗ ੳ
  9. struct Permissions { private enum Perm: Int { case read

    case write case execute 
 } static let read: Self = 
 Self(rawValue: 1 << Perm.rea 
 static let write: Self = 
 Self(rawValue: 1 << Perm.wri 
 static let execute: Self = 
 Self(rawValue: 1 << Perm.exe } 24 TUSVDUએݴ 1FSNJTTJPOT FOVNએݴ 1FSN $BTFએݴ $BTFએݴ $BTFએݴ SFBE XSJUF FYFDVUF ม਺એݴ ॳظԽઅ SFBE  ม਺એݴ ॳظԽઅ XSJU  ม਺એݴ ॳظԽઅ FYFD  ௥Ճ ௥Ճ ίʔυ ͱͯ͠ 
 ݟΔͱ มܗ