Slide 1

Slide 1 text

ԘҪඒ࡙ !TIJPJNN!DPF@ .BS ࣛࣇౡ3VCZձٞ ͨͷ͍͠3VCZͷߏจղੳπΞʔ

Slide 2

Slide 2 text

ࣗݾ঺հ (JU)VC!TIJPJNN 5XJUUFS!DPF@ גࣜձࣾΤεɾΤϜɾΤε 'VLVPLBSCग़਎"TBLVTBSCҭͪ ࡀ͔Βࡀ·ͰࣛࣇౡʹॅΜͰ͍·ͨ͠ ͜ͷ͋ͨΓ ࣾձ՝୊ʹऔΓ૊Έ͍ͨ3VCZେ޷͖ΤϯδχΞ͕ ηΧϯυΩϟϦΞʹΤεɾΤϜɾΤεΛબΜͩཧ༝ IUUQTUFDICNTNTDPKQFOUSZ

Slide 3

Slide 3 text

ࣛࣇౡ3VCZձٞͷςʔϚ ͱ͍͏͜ͱͰɺ࠷ۙݸਓతʹڵຯ͕޿͕ͬͨ 3VCZͷ಺ଆͷੈքͷ͓࿩Λ͍ͨ͠ͱࢥ͍·͢ IUUQTLSVCZDPNLBHPTIJNBSVCZLBJHJBCPVU 3VCZͰ޿͕Δੈքɺ3VCZͰ͸͡ΊΑ͏

Slide 4

Slide 4 text

ͱ͸͍͑ ʮ3VCZͷ಺ଆͷੈքʯͱ͍ͬͯ΋ɺ ࣮ࡍʹ͸ͱͯ΋޿େͰ͍ΖΜͳ੾Γޱ͕͋Γ·͢Ͷ

Slide 5

Slide 5 text

ʮ3VCZͷ಺ଆͷੈքʯ ࠓճ͸ͦͷதͰ΋ ɹ3VCZ .3* ͕ ɹͲΜͳ;͏ʹίʔυΛ࣮ߦ͍ͯ͠Δͷ͔ ͷҰ෦Ͱ͋Δߏจղੳʹ εϙοτϥΠτΛ౰ͯͯΈ͍ͨͱࢥ͍·͢

Slide 6

Slide 6 text

ʮ3VCZͷ಺ଆͷੈքʯ ·ͣ͸3VCZ͕ίʔυΛ࣮ߦ͢Δ·Ͱʹ 3VCZ .3* ͷ಺ଆͰͲΜͳ͜ͱ͕ى͍ͬͯ͜Δͷ͔ ͦͷશମ૾ΛோΊͯΈ͍ͨͱࢥ͍·͢

Slide 7

Slide 7 text

3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ ιʔείʔυ 1 + 2

Slide 8

Slide 8 text

3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ ιʔείʔυ 1 + 2 ࣮ߦ

Slide 9

Slide 9 text

3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ ιʔείʔυΛ ҙຯతʹղऍ͢Δॲཧ ιʔείʔυΛ ୯ޠ୯Ґʹ੾Γग़͢ॲཧ ߏจղੳ ιʔείʔυ ࣈ۟ղੳ 1 + 2

Slide 10

Slide 10 text

3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ ιʔείʔυΛ ҙຯతʹղऍͨ͠໦ߏ଄ͷσʔλ ߏจղੳ ιʔείʔυ ࣈ۟ղੳ 1 + 2 (OPCALL@1:0-1:5 (LIT@1:0-1:1 1) :+ (LIST@1:4-1:5 (LIT@1:4-1:5 2) nil))) ߏจ໦

Slide 11

Slide 11 text

3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ ߏจղੳ ίϯύΠϧ ιʔείʔυ ࣈ۟ղੳ 1 + 2 (OPCALL@1:0-1:5 (LIT@1:0-1:1 1) :+ (LIST@1:4-1:5 (LIT@1:4-1:5 2) nil))) ߏจ໦

Slide 12

Slide 12 text

3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ ϓϩάϥϜΛ࣮ࡍʹ࣮ߦ͢Δ໋ྩྻ ߏจղੳ ίϯύΠϧ ιʔείʔυ :"37όΠτίʔυ ࣈ۟ղੳ 1 + 2 == disasm: #@-e:1 (1,0)-(1,5)> (catch: false) 0000 putobject 1 ( 1)[Li] 0002 putobject 2 0004 send , nil 0007 leave (OPCALL@1:0-1:5 (LIT@1:0-1:1 1) :+ (LIST@1:4-1:5 (LIT@1:4-1:5 2) nil))) ߏจ໦

Slide 13

Slide 13 text

3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ ߏจղੳ ίϯύΠϧ ιʔείʔυ :"37όΠτίʔυ ࣈ۟ղੳ :"37্Ͱ࣮ߦ 1 + 2 == disasm: #@-e:1 (1,0)-(1,5)> (catch: false) 0000 putobject 1 ( 1)[Li] 0002 putobject 2 0004 send , nil 0007 leave (OPCALL@1:0-1:5 (LIT@1:0-1:1 1) :+ (LIST@1:4-1:5 (LIT@1:4-1:5 2) nil))) ߏจ໦

Slide 14

Slide 14 text

ߏจղੳ ίϯύΠϧ ιʔείʔυ :"37όΠτίʔυ ࣈ۟ղੳ :"37্Ͱ࣮ߦ ࣮ߦ݁Ռ > 3 1 + 2 3VCZ͕ίʔυΛ࣮ߦ͢Δ·ͰͷྲྀΕ == disasm: #@-e:1 (1,0)-(1,5)> (catch: false) 0000 putobject 1 ( 1)[Li] 0002 putobject 2 0004 send , nil 0007 leave (OPCALL@1:0-1:5 (LIT@1:0-1:1 1) :+ (LIST@1:4-1:5 (LIT@1:4-1:5 2) nil))) ߏจ໦

Slide 15

Slide 15 text

ຊൃදͰͷείʔϓ 3VCZ .3* ͷ಺ଆͷੈքͰɺ 3VCZ͕ιʔείʔυΛಡΈղ͍͍ͯ͘աఔΛ 3VCZͱҰॹʹମݧͯ͠Έ͍ͨͱࢥ͍·͢ ͨͷ͍͠3VCZͷߏจղੳπΞʔ ߏจղੳ ίϯύΠϧ ιʔείʔυ :"37όΠτίʔυ ࣈ۟ղੳ :"37্Ͱ࣮ߦ ࣮ߦ݁Ռ ߏจ໦

Slide 16

Slide 16 text

.3*ͷߏจղੳ

Slide 17

Slide 17 text

ύʔαͱεΩϟφ ύʔαͱݺ͹ΕΔؔ਺͕ ߏจղੳΛߦ͏ εΩϟφͱݺ͹ΕΔؔ਺͕ ࣈ۟ղੳΛߦ͏ ߏจղੳ ίϯύΠϧ ιʔείʔυ :"37όΠτίʔυ ࣈ۟ղੳ :"37্Ͱ࣮ߦ ࣮ߦ݁Ռ ߏจ໦

Slide 18

Slide 18 text

.3*ʹ͓͚ΔεΩϟφͷओͳ͸ͨΒ͖ ιʔείʔυ͔Β୯ޠΛ੾Γग़͠ɺ ɹᶃͦͷ୯ޠͷछྨΛࣔ͢ه߸ΛܾΊΔ ɹᶄͦͷ୯ޠͷ࣮ମΛද͢஋Λͭ͘Δ ɹᶅ୯ޠ͝ͱʹه߸ʹ஋Λඥ͚ͮͯύʔαʹ౉͢ ͱ͍͏ॲཧΛߦ͏

Slide 19

Slide 19 text

;ͨͨͼ͋Δͱ͜Ζʹ͜Μͳιʔείʔυ͕ 1 + 2 .3*ʹ͓͚ΔεΩϟφͷओͳ͸ͨΒ͖

Slide 20

Slide 20 text

ᶃ୯ޠ͝ͱʹछྨΛࣔ͢ه߸ΛܾΊΔ U*/5&(&3 b` U*/5&(&3 1 + 2 .3*ʹ͓͚ΔεΩϟφͷओͳ͸ͨΒ͖ ੔਺஋ Ճࢉه߸ ੔਺஋ ه߸ ҙຯ

Slide 21

Slide 21 text

ᶄͦͷ୯ޠͷ࣮ମΛද͢஋Λͭ͘Δ ͜ͷ஋͸ޙͰߏจ໦Λ࡞ΔͨΊͷࡐྉʹͳΔ /0%&@-*5 1 + 2 /0%&@-*5 .3*ʹ͓͚ΔεΩϟφͷओͳ͸ͨΒ͖ ਺஋Λද͢஋ ਺஋Λද͢஋ Ճࢉه߸ b`

Slide 22

Slide 22 text

ᶅ୯ޠ͝ͱʹه߸ʹ஋Λඥ͚ͮͯύʔαʹ౉͢ 1 + 2 .3*ʹ͓͚ΔεΩϟφͷओͳ͸ͨΒ͖ ه߸ /0%&@-*5 /0%&@-*5 ஋ Ճࢉه߸ b` U*/5&(&3 U*/5&(&3

Slide 23

Slide 23 text

.3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ εΩϟφ͔Βه߸Λड͚औͬͯ ɹᶃه߸Λࣗ෼ࣗ਎ͷελοΫʹͨΊΔ ɹᶄελοΫ಺ͷه߸ͷฒͼ͕ߏจنଇʹҰக͢Δͱɺ ɹɹΑΓந৅౓ͷߴ͍ه߸΁ม׵͢Δ ɹᶅม׵ʹϑοΫͯ͠ߏจ໦Λ૊ΈཱͯΔ ͱ͍͏ॲཧΛߦ͏

Slide 24

Slide 24 text

ͪΐͬͱෳࡶͳͷͰɺ ·ͣ͸ύʔαͷجຊతͳ࢓૊Έ͔Β ֬ೝͯ͠Έ͍ͨͱࢥ͍·͢ ˞.3*͕ར༻͍ͯ͠Δ#JTPOʹΑΔύʔαͷ৔߹

Slide 25

Slide 25 text

ύʔα͸ࣗ෼ࣗ਎ͷதʹه߸ΛͨΊ͓ͯͨ͘Ίͷ ελοΫΛ͍࣋ͬͯΔ εΩϟφ͔Βड͚औͬͨه߸͸ λΠϛϯάΛਤͬͯελοΫʹૹΒΕΔ ͜ΕΛʮه߸Λγϑτ͢Δʯͱ͍͏ ύʔαͷ͘͠ΈελοΫ U*/5&(&3 b` U*/5&(&3

Slide 26

Slide 26 text

ύʔα͸ࣗ෼ࣗ਎ͷதʹͨ͘͞ΜͷߏจنଇΛ͍࣋ͬͯΔ ߏจنଇʹ͸ͲΜͳ಺༰͕ఆٛ͞Ε͍ͯΔ͔ͱ͍͏ͱʜ ύʔαͷ͘͠Έߏจنଇ ߏจنଇྫ

Slide 27

Slide 27 text

ᶃͲΜͳه߸͕ͲΜͳॱ൪ͰฒͿ΂͖͔ ύʔαͷελοΫʹγϑτ͞ΕΔ֤ه߸͸ ͍ͣΕ͔ͷنଇʹఆٛ͞ΕͨॱʹฒͿඞཁ͕͋Δ ύʔαͷ͘͠Έߏจنଇ ߏจنଇྫᶃU*/5&(&3 b` U*/5&(&3ͷॱͰฒͿ U*/5&(&3 b` U*/5&(&3

Slide 28

Slide 28 text

ᶄฒΜͩه߸ྻΛͲΜͳه߸ʹม׵͢Δ͔ ελοΫ಺ͷه߸͕ಛఆͷنଇͷॱ൪௨Γʹἧ͏ͱɺ ͦͷه߸ྻ͸ΑΓந৅౓ͷߴ͍ผͷه߸΁ม׵͞ΕΔ ͜ΕΛʮؐݩʯͱݺͿ ύʔαͷ͘͠Έߏจنଇ ؐݩ ม׵ઌ ม׵ݩ ߏจنଇྫᶄॱ൪௨Γʹه߸͕ฒΜͩΒFYQS΁ؐݩ͢Δ U*/5&(&3 b` U*/5&(&3 FYQS

Slide 29

Slide 29 text

ᶅ௥ՃͰͲΜͳॲཧΛߦ͏͔ Φϓγϣϯ ؐݩʹϑοΫͯ͠௥ՃͰ೚ҙͷॲཧΛߦ͏͜ͱ͕Ͱ͖Δ ͜ͷॲཧͷ͜ͱΛʮΞΫγϣϯʯͱݺͿ .3*Ͱ͸ΞΫγϣϯΛར༻ͯ͠ߏจ໦Λ૊Έཱ͍ͯͯΔ /0%&@-*5 ਺஋ /0%&@-*5 ਺஋ b` Ճࢉه߸ ύʔαͷ͘͠Έߏจنଇ ΞΫγϣϯ ߏจنଇྫᶅ ௥Ճͷॲཧ ؐݩʹϑοΫͯ͠ߏจ໦Λ૊ΈཱͯΔ ߏจ໦ ه߸ͷ஋

Slide 30

Slide 30 text

͜͜·Ͱͷ࿩Λ౿·͑ͯɺ.3*ͷύʔα͕ εΩϟφɺελοΫɺߏจنଇΛۦ࢖ͯ͠ ߏจ໦Λ࡞Γ্͛Δ·Ͱͷ جຊతͳಈ͖Λ௥͍͔͚ͯΈ·͠ΐ͏

Slide 31

Slide 31 text

ύʔα͸εΩϟφ͔ΒૹΒΕ͖ͯͨه߸Λ ελοΫ΁γϑτ͢Δ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ ύʔαͷελοΫ U*/5&(&3 b` U*/5&(&3

Slide 32

Slide 32 text

ελοΫ಺ʹͨ·ͬͨه߸ྻ͕ ͍ͣΕ͔ͷߏจنଇʹҰக͢Δͱʜ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ ύʔαͷελοΫ U*/5&(&3 b` U*/5&(&3 U*/5&(&3 b` U*/5&(&3 FYQS ߏจنଇ ྫ

Slide 33

Slide 33 text

ελοΫ಺ͷه߸ྻ͸ ͦͷنଇʹΑͬͯఆΊΒΕͨผͷه߸ʹؐݩ͞ΕΔ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ ύʔαͷελοΫ FYQS U*/5&(&3 b` U*/5&(&3 FYQS ߏจنଇ ྫ

Slide 34

Slide 34 text

ؐݩલɺελοΫ಺ͷ֤ه߸ʹ͸ ͦΕͧΕͷ࣮ମΛද͢஋͕ඥ͍͍ͮͯΔ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ ஋ ύʔαͷελοΫ /0%&@-*5 /0%&@-*5 Ճࢉه߸ U*/5&(&3 b` U*/5&(&3

Slide 35

Slide 35 text

ύʔα͸ؐݩʹϑοΫͯ͠ɺΞΫγϣϯ಺Ͱ ͜ΕΒͷ஋Λࡐྉʹߏจ໦Λ૊ΈཱͯΔ /0%&@-*5 ਺஋ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ /0%&@-*5 ਺஋ b` Ճࢉه߸ /0%&@01$"-- ߏจ໦ͷࡐྉ ૊ΈཱͯΒΕͨߏจ໦ /0%&@-*5 ਺஋ /0%&@-*5 ਺஋

Slide 36

Slide 36 text

૊ΈཱͯΒΕͨߏจ໦͸ؐݩޙͷه߸ʹඥ͚ͮΒΕΔ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ /0%&@01$"-- /0%&@-*5 ਺஋ /0%&@-*5 ਺஋ ߏจ໦ ύʔαͷελοΫ FYQS

Slide 37

Slide 37 text

࠷ऴతʹ͸͢΂ͯͷιʔείʔυΛಡΈऴ͑ͯɺ ελοΫ಺ͷه߸ྻ͕ه߸QSPHSBN΁ؐݩ͞Εͨ࣌఺Ͱ ߏจղੳ͕ऴྃ͢Δ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ ύʔαͷελοΫ QSPHSBN

Slide 38

Slide 38 text

ه߸QSPHSBN͕ؐݩ͞Εͨ࣌఺Ͱߏจ໦ͷ૊Έཱͯ΋ ׬ྃ͠ɺ͜ͷߏจ໦͸ͦͷޙ:"37όΠτίʔυ΁ ίϯύΠϧ͞ΕΔ .3*ʹ͓͚Δύʔαͷओͳ͸ͨΒ͖ /0%&@01$"-- /0%&@-*5 ਺஋ /0%&@-*5 ਺஋ ߏจ໦ QSPHSBN ύʔαͷελοΫ

Slide 39

Slide 39 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ

Slide 40

Slide 40 text

·ͣ͸ߏจղੳͷ༷ࢠΛಡΉʹ͋ͨͬͯ ศརͳπʔϧΛ͝঺հ͠·͢

Slide 41

Slide 41 text

ߏจղੳศརπʔϧ Φϓγϣϯ 3VCZͷιʔείʔυΛ࣮ߦ͢Δͱ͖ɺ ɹίϚϯυʹɹɹΦϓγϣϯΛ͚ͭΔ͜ͱͰ ߏจղੳͷաఔͷϩάΛඪ४ग़ྗ͢Δ͜ͱ͕Ͱ͖Δ ruby -y $ ruby -ye ‘1 + 2’ … -y

Slide 42

Slide 42 text

.3*ͷ࣮ࡍͷߏจنଇ͸.3*ͷιʔείʔυʹؚ·ΕΔ QBSTFZʹఆٛ͞Ε͍ͯΔ /********************************************************************** parse.y - $Author$ created at: Fri May 28 18:02:42 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto **********************************************************************/ // … %% // … %% // … IUUQTHJUIVCDPNSVCZSVCZCMPCW@@QBSTFZ Ͱғ·Ε͍ͯΔ෦෼ʹߏจنଇ͕ఆٛ͞Ε͍ͯΔ ߏจղੳศརπʔϧ QBSTFZϑΝΠϧ

Slide 43

Slide 43 text

ߏจղੳศརπʔϧ QBSTFZϑΝΠϧ method_call : primary_value call_op operation2 opt_paren_args { $$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$); nd_set_line($$, @3.end_pos.lineno); } ߏจنଇͷಡΈํɹྫQBSTFZ- ؆ུԽ͍ͯ͠·͢

Slide 44

Slide 44 text

ߏจղੳศརπʔϧ QBSTFZϑΝΠϧ method_call : primary_value call_op operation2 opt_paren_args { $$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$); nd_set_line($$, @3.end_pos.lineno); } ؐݩޙͷه߸ ؐݩલͷه߸ྻ ΞΫγϣϯ Φϓγϣφϧ ߏจنଇͷಡΈํɹྫQBSTFZ- ؆ུԽ͍ͯ͠·͢

Slide 45

Slide 45 text

method_call : primary_value call_op operation2 opt_paren_args { $$ = new_qcall(p, $2, $1, $3, $4, &@3, &@$); nd_set_line($$, @3.end_pos.lineno); } ߏจղੳศརπʔϧ QBSTFZϑΝΠϧ ҙຯ ᶃQSJNBSZ@WBMVF DBMM@PQ PQFSBUJPO PQU@QBSFO@BSHT͕ฒΜͩΒ ɹNFUIPE@DBMM΁ؐݩ͢Δ ᶄؐݩʹϑοΫͯ͠OFX@RDBMMؔ਺ͱOE@TFU@MJOFؔ਺Λݺͼग़͢ ؐݩޙͷه߸ ؐݩલͷه߸ྻ ΞΫγϣϯ Φϓγϣφϧ ߏจنଇͷಡΈํɹྫQBSTFZ- ؆ུԽ͍ͯ͠·͢

Slide 46

Slide 46 text

ͦΕͰ͸࣮ࡍʹ.3*͕ߏจղੳΛ͢Δ ଍औΓΛ௥͍͔͚ͯΈ·͠ΐ͏ ࣮ߦ؀ڥ ɹ04NBD04.POUFSFZ ɹ$16"QQMF. ɹ3VCZ

Slide 47

Slide 47 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ ࠓճղੳ͢Δίʔυ͸ ߏจղੳΛ։࢝͢Δ $ ruby -y ίϚϯυΛ࢖༻ͯ͠

Slide 48

Slide 48 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ add_delayed_token:7062 (0: 0|0|0) Starting parse ߏจղੳΛ։࢝

Slide 49

Slide 49 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ add_delayed_token:7062 (0: 0|0|0) Starting parse Entering state 0 Stack now 0 Reducing stack by rule 1 (line 1580): lex_state: NONE -> BEG at line 1581 vtable_alloc:13130: 0x00006000034e9b40 vtable_alloc:13131: 0x00006000034e9b60 cmdarg_stack(push): 0 at line 13144 cond_stack(push): 0 at line 13145 -> $$ = nterm $@1 (1.0-1.0: ) QBSTFZͷߦ໨ʹఆٛ͞Ε͍ͯΔ ߏจنଇʹैͬͯؐݩΛ։࢝

Slide 50

Slide 50 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ add_delayed_token:7062 (0: 0|0|0) Starting parse Entering state 0 Stack now 0 Reducing stack by rule 1 (line 1580): lex_state: NONE -> BEG at line 1581 vtable_alloc:13130: 0x00006000034e9b40 vtable_alloc:13131: 0x00006000034e9b60 cmdarg_stack(push): 0 at line 13144 cond_stack(push): 0 at line 13145 -> $$ = nterm $@1 (1.0-1.0: ) ߏจنଇ͸ࠓ͔Βߏจղੳ͢Δ४උΛ ߦ͏ͨΊͷಛघͳنଇͳͷͰ ࠓճ͸ৄࡉΛׂѪ͠·͢

Slide 51

Slide 51 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 2 Stack now 0 2 Reading a token ͦͷ͙͢ޙɺύʔα͸εΩϟφΛ࢖ͬͯ ιʔείʔυ͔Βه߸ΛಡΈࠐΉ ه߸ΛಡΈࠐΉ

Slide 52

Slide 52 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 2 Stack now 0 2 Reading a token lex_state: BEG -> END at line 9005 lex_state: END -> END at line 8282 parser_dispatch_scan_event:10499 (1: 0|1|5) Next token is token "integer literal" (1.0-1.1: 1) Shifting token "integer literal" (1.0-1.1: 1) ࣍ͷه߸͸JOUFHFSMJUFSBMzͩͬͨ ͷͷ෦෼ JOUFHFSMJUFSBMz U*/5&(&3 Λγϑτ ˞lJOUFHFSMJUFSBMz͸ ɹߏจنଇ্U*/5&(&3ͱදݱ͞ΕΔ U*/5&(&3 ύʔαͷελοΫ

Slide 53

Slide 53 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 41 Stack now 0 2 41 Reducing stack by rule 645 (line 5383): $1 = token "integer literal" (1.0-1.1: 1) -> $$ = nterm simple_numeric (1.0-1.1: NODE_LIT) ߏจنଇʹैͬͯؐݩΛ։࢝ U*/5&(&3ΛTJNQMF@OVNFSJDʹؐݩ // parse.y: L5383 simple_numeric : tINTEGER ύʔαͷελοΫ TJNQMF@OVNFSJD

Slide 54

Slide 54 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 120 Stack now 0 2 120 Reducing stack by rule 643 (line 5372): $1 = nterm simple_numeric (1.0-1.1: NODE_LIT) -> $$ = nterm numeric (1.0-1.1: NODE_LIT) ߏจنଇʹैͬͯؐݩΛ։࢝ TJNQMF@OVNFSJDΛOVNFSJDʹؐݩ // parse.y: L5372 numeric : simple_numeric ύʔαͷελοΫ OVNFSJD

Slide 55

Slide 55 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 119 Stack now 0 2 119 Reducing stack by rule 595 (line 4998): $1 = nterm numeric (1.0-1.1: NODE_LIT) -> $$ = nterm literal (1.0-1.1: NODE_LIT) // parse.y: L4998 literal : numeric ߏจنଇʹैͬͯؐݩΛ։࢝ OVNFSJDΛMJUFSBMʹؐݩ ύʔαͷελοΫ MJUFSBM

Slide 56

Slide 56 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 106 Stack now 0 2 106 Reducing stack by rule 310 (line 3220): $1 = nterm literal (1.0-1.1: NODE_LIT) -> $$ = nterm primary (1.0-1.1: NODE_LIT) // parse.y: L3220 primary : literal ߏจنଇʹैͬͯؐݩΛ։࢝ MJUFSBMΛQSJNBSZʹؐݩ ύʔαͷελοΫ QSJNBSZ

Slide 57

Slide 57 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 106 Stack now 0 2 106 Reducing stack by rule 310 (line 3220): $1 = nterm literal (1.0-1.1: NODE_LIT) -> $$ = nterm primary (1.0-1.1: NODE_LIT) ɾ͜͜·ͰͰͷΛ ɹه߸QSJNBSZͱͯ͠ղੳͰ͖ͨ ɾه߸QSJNBSZ͸ɺ͜ͷޙ ɹͲΜͳه߸ͱ૊Έ߹ΘͤΔ͔ʹΑͬͯ ɹద༻͢Δߏจنଇͱؐݩઌͷه߸͕ ɹมΘΔ ɾύʔα͸ɺ͜ͷޙͷ ɹιʔείʔυʹ͕ଓ͘͜ͱΛ ɹࠓͷ࣌఺Ͱ͸·ͩ஌Βͳ͍ ύʔαͷελοΫ QSJNBSZ ߏจղੳͷݱࡏ஍఺

Slide 58

Slide 58 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 90 Stack now 0 2 90 Reading a token ࣍ͷه߸ΛಡΈࠐΉ ࣍ͷه߸Λ֬ೝ͢ΔͨΊɺ ύʔα͸εΩϟφΛ࢖ͬͯ ιʔείʔυ͔Βه߸ΛಡΈࠐΉ

Slide 59

Slide 59 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 90 Stack now 0 2 90 Reading a token parser_dispatch_scan_event:9833 (1: 1|1|4) lex_state: END -> BEG at line 10181 parser_dispatch_scan_event:10499 (1: 2|1|3) Next token is token '+' (1.2-1.3: ) ࣍ͷه߸͸b`ͩͬͨ ύʔαͷελοΫ QSJNBSZ ύʔα͸࣍ͷه߸͕b`Ͱ͋Δͱ͖ ه߸QSJNBSZʹରͯ͠ ͲΜͳߏจنଇΛద༻͢Δ΂͖͔൑அ͢Δ

Slide 60

Slide 60 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Reading a token parser_dispatch_scan_event:9833 (1: 1|1|4) lex_state: END -> BEG at line 10181 parser_dispatch_scan_event:10499 (1: 2|1|3) Next token is token '+' (1.2-1.3: ) Reducing stack by rule 263 (line 2906): $1 = nterm primary (1.0-1.1: NODE_LIT) -> $$ = nterm arg (1.0-1.1: NODE_LIT) QSJNBSZΛBSHʹؐݩ // parse.y: 2906 arg : primary ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ BSH ˞؆ུԽ͍ͯ͠·͢

Slide 61

Slide 61 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 88 Stack now 0 2 88 Next token is token '+' (1.2-1.3: ) Shifting token '+' (1.2-1.3: ) b`Λγϑτ ύʔαͷελοΫ BSH b` ղੳΛଓ͚ΔͨΊʹύʔα͸ ઌ΄Ͳ֬ೝͨ࣍͠ͷه߸b`Λ ελοΫʹγϑτ͢Δ

Slide 62

Slide 62 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 88 Stack now 0 2 88 Next token is token '+' (1.2-1.3: ) Shifting token '+' (1.2-1.3: ) ɾ͜ͷ࣌఺ͰελοΫ಺ʹ͋Δ ɹ<BSHb`>ͱ͍͏ه߸ͷฒͼͰ ɹؐݩͰ͖Δߏจنଇ͸ଘࡏ͠ͳ͍ ύʔαͷελοΫ BSH b` ߏจղੳͷݱࡏ஍఺

Slide 63

Slide 63 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 367 Stack now 0 2 88 367 Reading a token ࣍ͷه߸ΛಡΈࠐΉ ࣍ʹؐݩͰ͖ΔنଇΛݟ͚ͭΔͨΊɺ ύʔα͸εΩϟφΛ࢖ͬͯ ࣍ͷه߸ΛಡΈࠐΉ

Slide 64

Slide 64 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 367 Stack now 0 2 88 367 Reading a token parser_dispatch_scan_event:9833 (1: 3|1|2) lex_state: BEG -> END at line 9005 lex_state: END -> END at line 8282 parser_dispatch_scan_event:10499 (1: 4|1|1) Next token is token "integer literal" (1.4-1.5: 2) Shifting token "integer literal" (1.4-1.5: 2) ࣍ͷه߸͸lJOUFHFSMJUFSBMzͩͬͨ ͷͷ෦෼ lJOUFHFSMJUFSBMz U*/5&(&3 Λγϑτ ύʔαͷελοΫ BSH b` U*/5&(&3

Slide 65

Slide 65 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 41 Stack now 0 2 88 367 41 Reducing stack by rule 645 (line 5383): $1 = token "integer literal" (1.4-1.5: 2) -> $$ = nterm simple_numeric (1.4-1.5: NODE_LIT) ߏจنଇʹैͬͯؐݩΛ։࢝ U*/5&(&3ΛTJNQMF@OVNFSJDʹؐݩ // parse.y: L5383 simple_numeric : tINTEGER ύʔαͷελοΫ BSH b` TJNQMF@OVNFSJD

Slide 66

Slide 66 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 120 Stack now 0 2 88 367 120 Reducing stack by rule 643 (line 5372): $1 = nterm simple_numeric (1.4-1.5: NODE_LIT) -> $$ = nterm numeric (1.4-1.5: NODE_LIT) ߏจنଇʹैͬͯؐݩΛ։࢝ TJNQMF@OVNFSJDΛOVNFSJDʹؐݩ // parse.y: L5372 numeric : simple_numeric ύʔαͷελοΫ BSH b` OVNFSJD

Slide 67

Slide 67 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 119 Stack now 0 2 88 367 119 Reducing stack by rule 595 (line 4998): $1 = nterm numeric (1.4-1.5: NODE_LIT) -> $$ = nterm literal (1.4-1.5: NODE_LIT) // parse.y: L4998 literal : numeric ߏจنଇʹैͬͯؐݩΛ։࢝ OVNFSJDΛMJUFSBMʹؐݩ ύʔαͷελοΫ BSH b` MJUFSBM

Slide 68

Slide 68 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 106 Stack now 0 2 88 367 106 Reducing stack by rule 310 (line 3220): $1 = nterm literal (1.4-1.5: NODE_LIT) -> $$ = nterm primary (1.4-1.5: NODE_LIT) // parse.y: L3220 primary : literal ߏจنଇʹैͬͯؐݩΛ։࢝ MJUFSBMΛQSJNBSZʹؐݩ ύʔαͷελοΫ BSH b` QSJNBSZ

Slide 69

Slide 69 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 106 Stack now 0 2 88 367 106 Reducing stack by rule 310 (line 3220): $1 = nterm literal (1.4-1.5: NODE_LIT) -> $$ = nterm primary (1.4-1.5: NODE_LIT) ɾ ઌ΄Ͳͱಉ͘͡ ɾه߸QSJNBSZ͸ɺ͜ͷޙ ɹͲΜͳه߸ͱ૊Έ߹ΘͤΔ͔ʹΑͬͯ ɹద༻͢Δߏจنଇͱؐݩઌͷه߸͕ ɹมΘΔ ɾύʔα͸ɺ͜ͷޙ ɹιʔείʔυ͕ऴྃ͢Δ͜ͱΛ ɹࠓͷ࣌఺Ͱ͸·ͩ஌Βͳ͍ ύʔαͷελοΫ BSH b` QSJNBSZ ߏจղੳͷݱࡏ஍఺

Slide 70

Slide 70 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 90 Stack now 0 2 88 367 90 Reading a token ࣍ͷه߸ΛಡΈࠐΉ ͦΕΛ֬ೝ͢ΔͨΊɺύʔα͸ εΩϟφΛ࢖ͬͯ࣍ͷه߸ΛಡΈࠐΉ

Slide 71

Slide 71 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 90 Stack now 0 2 88 367 90 Reading a token lex_state: END -> BEG at line 9900 parser_dispatch_scan_event:10499 (1: 5|1|0) Next token is token '\n' (1.5-1.6: ) ࣍ͷه߸͸baO վߦίʔυ ͩͬͨ ύʔαͷελοΫ BSH b` QSJNBSZ ύʔα͸࣍ͷه߸͕baO`Ͱ͋Δͱ͖ ه߸QSJNBSZʹରͯ͠ͲΜͳߏจنଇΛ ద༻͢Δ΂͖͔൑அ͢Δ

Slide 72

Slide 72 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 90 Stack now 0 2 88 367 90 Reading a token lex_state: END -> BEG at line 9900 parser_dispatch_scan_event:10499 (1: 5|1|0) Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 263 (line 2906): $1 = nterm primary (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.4-1.5: NODE_LIT) QSJNBSZΛBSHʹؐݩ // parse.y: 2906 arg : primary ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ BSH b` BSH ελοΫʹ BSH b` BSH͕ฒΜͩ ˞؆ུԽ͍ͯ͠·͢

Slide 73

Slide 73 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 602 Stack now 0 2 88 367 602 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 231 (line 2745): $1 = nterm arg (1.0-1.1: NODE_LIT) $2 = token '+' (1.2-1.3: ) $3 = nterm arg (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.0-1.5: NODE_OPCALL) // parse.y: L2745 arg : arg ‘+’ arg BSHb`BSHΛBSHʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ BSH ˞؆ུԽ͍ͯ͠·͢

Slide 74

Slide 74 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 602 Stack now 0 2 88 367 602 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 231 (line 2745): $1 = nterm arg (1.0-1.1: NODE_LIT) $2 = token '+' (1.2-1.3: ) $3 = nterm arg (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.0-1.5: NODE_OPCALL) // parse.y: L2745 BSHBSHb`BSH \ DBMM@CJO@PQ Q b ! ! ^ ˞؆ུԽ͍ͯ͠·͢ ͜ͷߏจنଇʹ͸ ߏจ໦Λ૊ΈཱͯΔͨΊͷ ΞΫγϣϯ͕ఆٛ͞Ε͍ͯΔ

Slide 75

Slide 75 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 602 Stack now 0 2 88 367 602 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 231 (line 2745): $1 = nterm arg (1.0-1.1: NODE_LIT) $2 = token '+' (1.2-1.3: ) $3 = nterm arg (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.0-1.5: NODE_OPCALL) ˞؆ུԽ͍ͯ͠·͢ ߏจ໦Λ૊ΈཱͯΔؔ਺͕ ݺͼग़͞Ε͍ͯΔ // parse.y: L2745 BSHBSHb`BSH \ DBMM@CJO@PQ Q b ! ! ^

Slide 76

Slide 76 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 602 Stack now 0 2 88 367 602 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 231 (line 2745): $1 = nterm arg (1.0-1.1: NODE_LIT) $2 = token '+' (1.2-1.3: ) $3 = nterm arg (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.0-1.5: NODE_OPCALL) BSHBSHb`BSH \ DBMM@CJO@PQ Q b ! ! ^ ˞؆ུԽ͍ͯ͠·͢ Ҿ਺ʹه߸ͷ஋Λ౉͍ͯ͠Δ ʜࠨͷBSHͷ஋ ਺஋ b`ʜՃࢉه߸ ʜӈͷBSHͷ஋ ਺஋ // parse.y: L2745

Slide 77

Slide 77 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 602 Stack now 0 2 88 367 602 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 231 (line 2745): $1 = nterm arg (1.0-1.1: NODE_LIT) $2 = token '+' (1.2-1.3: ) $3 = nterm arg (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.0-1.5: NODE_OPCALL) ˞؆ུԽ͍ͯ͠·͢ ͜ͷؔ਺Λ࣮ߦ͢Δͱ ૊ΈཱͯΒΕͨߏจ໦͕ฦͬͯ͘Δ // parse.y: L2745 BSHBSHb`BSH \ DBMM@CJO@PQ Q b ! ! ^

Slide 78

Slide 78 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 602 Stack now 0 2 88 367 602 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 231 (line 2745): $1 = nterm arg (1.0-1.1: NODE_LIT) $2 = token '+' (1.2-1.3: ) $3 = nterm arg (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.0-1.5: NODE_OPCALL) ˞؆ུԽ͍ͯ͠·͢ ૊ΈཱͯΒΕͨߏจ໦͕ ؐݩޙͷه߸BSHʹඥͮ͘஋Λද͢ ʹ୅ೖ͞ΕΔ BSHBSHb`BSH \ DBMM@CJO@PQ Q b ! ! ^ // parse.y: L2745

Slide 79

Slide 79 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 602 Stack now 0 2 88 367 602 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 231 (line 2745): $1 = nterm arg (1.0-1.1: NODE_LIT) $2 = token '+' (1.2-1.3: ) $3 = nterm arg (1.4-1.5: NODE_LIT) -> $$ = nterm arg (1.0-1.5: NODE_OPCALL) ύʔαͷελοΫ BSH /0%&@01$"-- /0%&@-*5 ਺஋ /0%&@-*5 ਺஋ ߏจ໦ ͜ΕʹΑͬͯؐݩޙͷه߸BSHʹ ߏจ໦͕ඥ͍ͮͨঢ়ଶʹͳΔ

Slide 80

Slide 80 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 88 Stack now 0 2 88 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 65 (line 2051): $1 = nterm arg (1.0-1.5: node_opcall) -> $$ = nterm expr (1.0-1.5: node_opcall) // parse.y: 2051 expr : arg BSHΛFYQSʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ FYQS ˞؆ུԽ͍ͯ͠·͢

Slide 81

Slide 81 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 75 Stack now 0 2 75 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 37 (line 1853): $1 = nterm expr (1.0-1.5: NODE_OPCALL) -> $$ = nterm stmt (1.0-1.5: NODE_OPCALL) // parse.y: 1853 stmt : expr FYQSΛTUNUʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ TUNU ˞؆ུԽ͍ͯ͠·͢

Slide 82

Slide 82 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 73 Stack now 0 2 73 Next token is token '\n' (1.5-1.6: ) Reducing stack by rule 7 (line 1635): $1 = nterm stmt (1.0-1.5: NODE_OPCALL) -> $$ = nterm top_stmt (1.0-1.5: NODE_OPCALL) // parse.y: 1635 top_stmt : stmt TUNUΛUPQ@TUNUʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ UPQ@TUNU ˞؆ུԽ͍ͯ͠·͢

Slide 83

Slide 83 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 72 Stack now 0 2 72 Reducing stack by rule 5 (line 1619): $1 = nterm top_stmt (1.0-1.5: NODE_OPCALL) -> $$ = nterm top_stmts (1.0-1.5: NODE_OPCALL) // parse.y: 1619 top_stmts : top_stmt UPQ@TUNUΛUPQ@TUNUTʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ UPQ@TUNUT ˞؆ུԽ͍ͯ͠·͢

Slide 84

Slide 84 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 72 Stack now 0 2 72 Reducing stack by rule 5 (line 1619): $1 = nterm top_stmt (1.0-1.5: NODE_OPCALL) -> $$ = nterm top_stmts (1.0-1.5: NODE_OPCALL) ɾ͜͜·ͰͰ ɹΛղੳͰ͖ͨ ɾ͋ͱ͸վߦίʔυaOΛ ɹಡΈࠐΜͰ͜ͷߦΛऴ୺ͤ͞Δ ɹඞཁ͕͋Δ ύʔαͷελοΫ UPQ@TUNUT ߏจղੳͷݱࡏ஍఺ ˞վߦޙʹϝιουݺͼग़͠ͷAA υοτ ͕ ɹଓ͘έʔε͸εΩϟφͰରԠ͍ͯ͠·͕͢ ɹࠓճ͸ղઆΛׂѪ͠·͢

Slide 85

Slide 85 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 71 Stack now 0 2 71 Next token is token '\n' (1.5-1.6: ) Shifting token '\n' (1.5-1.6: ) baOΛγϑτ ࣍ͷه߸͸aO ߦ຤ ͩͬͨ ύʔαͷελοΫ UPQ@TUNUT baO`

Slide 86

Slide 86 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 310 Stack now 0 2 71 310 Reducing stack by rule 778 (line 6115): $1 = token '\n' (1.5-1.6: ) -> $$ = nterm term (1.5-1.5: ) // parse.y: 6115 term : ‘\n’ baO`ΛUFSNʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ UPQ@TUNUT UFSN

Slide 87

Slide 87 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 312 Stack now 0 2 71 312 Reducing stack by rule 779 (line 6122): $1 = nterm term (1.5-1.5: ) -> $$ = nterm terms (1.5-1.5: ) // parse.y: 6122 terms : term UFSNΛUFSNTʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ UPQ@TUNUT UFSNT

Slide 88

Slide 88 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 312 Stack now 0 2 71 312 Reducing stack by rule 779 (line 6122): $1 = nterm term (1.5-1.5: ) -> $$ = nterm terms (1.5-1.5: ) ɾ͜͜·ͰͰ ɹaOΛղੳͰ͖ͨ ɾύʔα͸͜ͷίʔυ͕ ɹ͜͜ͰऴΘΔͷ͔ɺ ɹ͜ͷޙ͞ΒʹߦҎ্ଓ͍͍ͯ͘ͷ͔Λ ɹࠓͷ࣌఺Ͱ͸·ͩ஌Βͳ͍ ύʔαͷελοΫ UPQ@TUNUT UFSNT ߏจղੳͷݱࡏ஍఺

Slide 89

Slide 89 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 313 Stack now 0 2 71 313 Reading a token ͦΕΛ֬ೝ͢ΔͨΊɺύʔα͸ εΩϟφΛ࢖ͬͯ࣍ͷه߸ΛಡΈࠐΉ ࣍ͷه߸ΛಡΈࠐΉ

Slide 90

Slide 90 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 313 Stack now 0 2 71 313 Reading a token Now at end of input. ͔͠͠ɺ͜ͷίʔυ͸͜ͷҰߦͰ ऴ͍ྃͯ͠ΔͷͰ࣍ͷߦ͸ଘࡏ͠ͳ͍ ࣍ͷೖྗ͸ͳ͍

Slide 91

Slide 91 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 313 Stack now 0 2 71 313 Reading a token Now at end of input. ࣍ͷೖྗ͸ͳ͍ ύʔαͷελοΫ UPQ@TUNUT UFSNT ύʔα͸࣍ͷه߸͕ଘࡏ͠ͳ͍ͱ͖ ه߸UFSNTʹରͯ͠ͲΜͳߏจنଇΛ ద༻͢Δ΂͖͔൑அ͢Δ

Slide 92

Slide 92 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 313 Stack now 0 2 71 313 Reading a token Now at end of input. Reducing stack by rule 769 (line 6094): $1 = nterm terms (1.5-1.5: ) -> $$ = nterm opt_terms (1.5-1.5: ) // parse.y: 6094 opt_terms : terms UFSNTΛPQU@UFSNTʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ UPQ@TUNUT PQU@UFSNT ελοΫʹ UPQ@TUNUT PQU@UFSNT͕ฒΜͩ

Slide 93

Slide 93 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 311 Stack now 0 2 71 311 Reducing stack by rule 3 (line 1606): $1 = nterm top_stmts (1.0-1.5: NODE_OPCALL) $2 = nterm opt_terms (1.5-1.5: ) -> $$ = nterm top_compstmt (1.0-1.5: NODE_OPCALL) // parse.y: 1606 top_compstmt : top_stmts opt_terms UPQ@TUNUT PQU@UFSNTΛ UPQ@DPNQTUNUʹؐݩ ߏจنଇʹैͬͯؐݩΛ։࢝ ύʔαͷελοΫ UPQ@DPNQTUNUT

Slide 94

Slide 94 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 70 Stack now 0 2 70 Reducing stack by rule 2 (line 1580): $1 = nterm $@1 (1.0-1.0: ) $2 = nterm top_compstmt (1.0-1.5: NODE_OPCALL) … cmdarg_stack(pop): 0 at line 13166 cond_stack(pop): 0 at line 13167 -> $$ = nterm program (1.0-1.5: ) // parse.y: 1580 program : top_compstmt UPQ@DPNQTUNUΛQSPHSBNʹؐݩ ύʔαͷελοΫ QSPHSBN ߏจنଇʹैͬͯؐݩΛ։࢝

Slide 95

Slide 95 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 70 Stack now 0 2 70 Reducing stack by rule 2 (line 1580): $1 = nterm $@1 (1.0-1.0: ) $2 = nterm top_compstmt (1.0-1.5: NODE_OPCALL) … cmdarg_stack(pop): 0 at line 13166 cond_stack(pop): 0 at line 13167 -> $$ = nterm program (1.0-1.5: ) ύʔαͷελοΫ QSPHSBN ɾه߸QSPHSBN΁ ɹؐݩ͢Δ͜ͱ͕Ͱ͖ͨͨΊ ɹύʔα͸͜͜·ͰͰ ɹߏจղੳΛऴྃ͢Δ ߏจղੳͷݱࡏ஍఺

Slide 96

Slide 96 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 1 Stack now 0 1 Now at end of input. Shifting token "end-of-input" (1.6-1.6: ) Entering state 3 Stack now 0 1 3 Stack now 0 1 3 Cleanup: popping token "end-of-input" (1.6-1.6: ) Cleanup: popping nterm program (1.0-1.5: ) ελοΫΛۭʹͯ͠ ਖ਼ৗʹೖྗ͕ऴΘͬͨ͜ͱΛ֬ೝ͠ɺ ॲཧΛऴྃ ޙॲཧͷͨΊɺ ೖྗͷऴྃΛදݱ͢Δه߸Λ ελοΫʹγϑτ

Slide 97

Slide 97 text

ͨͷ͍͠3VCZͷߏจղੳπΞʔ $ ruby -ye ‘1 + 2’ … Entering state 1 Stack now 0 1 Now at end of input. Shifting token "end-of-input" (1.6-1.6: ) Entering state 3 Stack now 0 1 3 Stack now 0 1 3 Cleanup: popping token "end-of-input" (1.6-1.6: ) Cleanup: popping nterm program (1.0-1.5: ) a໨త஍΁౸ண ߏจղੳͷݱࡏ஍఺

Slide 98

Slide 98 text

͓͔ͭΕ͞·Ͱͨ͠ 3VCZͱҰॹʹ८ΔߏจղੳπΞʔ͸ ͓ͨͷ͠Έ͍͚ͨͩͨͰ͠ΐ͏͔

Slide 99

Slide 99 text

·ͱΊ ɹɹΦϓγϣϯ͕͋Ε͹͍ͭͰ΋Ͳ͜Ͱ΋ खܰʹߏจղੳϩάΛग़ྗͰ͖·͢ QBSTFZϑΝΠϧ͕͋Ε͹ΑΓৄࡉʹ ߏจղੳͷ࣮ࡍΛ֬ೝ͢Δ͜ͱ͕Ͱ͖·͢ -y Έͳ͞Μ΋ͥͻ͓खݩͷ.3*Ͱ͓ࢼ͍ͩ͘͠͞

Slide 100

Slide 100 text

͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ 4QFDJBMUIBOLTUP ܟশུ !TQJLFPMBG !NJOFSPBPLJ ࢀߟॻ੶ 3VCZιʔείʔυ׬શղઆɹୈೋ෦ʮߏจղੳʯ IUUQTJMPWFSVCZOFUKBSIHCPPL 3VCZͷ͘͠Έɹ̍ࣈ۟ղੳͱߏจղੳ