{"id":10,"date":"2021-06-15T02:53:14","date_gmt":"2021-06-15T02:53:14","guid":{"rendered":"https:\/\/blogs.scummvm.org\/djsrv\/?p=10"},"modified":"2021-06-15T02:53:14","modified_gmt":"2021-06-15T02:53:14","slug":"chunk-expressions","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/djsrv\/2021\/06\/15\/chunk-expressions\/","title":{"rendered":"Chunk Expressions"},"content":{"rendered":"\n<p>This week I started wrapping up work on one of the last major Lingo features which was still unimplemented &#8211; chunk expressions.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"668\" height=\"536\" src=\"https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-from-2021-06-14-20-14-50-1.png\" alt=\"\" class=\"wp-image-13\" srcset=\"https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-from-2021-06-14-20-14-50-1.png 668w, https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-from-2021-06-14-20-14-50-1-300x241.png 300w, https:\/\/blogs.scummvm.org\/djsrv\/wp-content\/uploads\/sites\/4\/2021\/06\/Screenshot-from-2021-06-14-20-14-50-1-480x385.png 480w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/figure>\n\n\n\n<p>Chunk expressions refer to chunks of text, such as <code>char 3 of \"test\"<\/code>, <code>word 1 to 10 of variable<\/code>, or <code>item 3 of \"foo,bar,baz\"<\/code>. These can be used to used to manipulate text in various ways, like highlighting chunks of text like in the screenshot above, deleting chunks of text, or inserting text before\/into\/after chunks of text.<\/p>\n\n\n\n<p>After refactoring how references to text chunks work and implementing the <code>hilite<\/code> and <code>delete<\/code> commands, I ran into my old foe the Lingo parser again. Right now, the Lingo parser can&#8217;t differentiate between when we need something&#8217;s value (e.g. <code>put char 1 of variable<\/code>) and when we need a reference to something (e.g. <code>hilite char 1 of variable<\/code>). The current hack is to always push a reference and evaluate that reference later if needed. The parser&#8217;s gotten rather brittle, so it&#8217;s been difficult to change it to remove this hack&#8230; or to make any changes, really.<\/p>\n\n\n\n<p>To solve this, I&#8217;ve started a major refactoring of the Lingo compiler which should make it a lot more flexible. This will allow references to be properly handled, and it should also allow us to eliminate most of the grammar&#8217;s plentiful hacks. I&#8217;ll be working on this most of this week, so more on this later!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week I started wrapping up work on one of the last major Lingo features which was still unimplemented &#8211; chunk expressions. Chunk expressions refer to chunks of text, such as char 3 of &#8220;test&#8221;, word 1 to 10 of variable, or item 3 of &#8220;foo,bar,baz&#8221;. These can be used to used to manipulate text [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-10","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts\/10","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/comments?post=10"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts\/10\/revisions"}],"predecessor-version":[{"id":14,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/posts\/10\/revisions\/14"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/media?parent=10"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/categories?post=10"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/djsrv\/wp-json\/wp\/v2\/tags?post=10"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}