{"id":62,"date":"2020-12-29T20:22:18","date_gmt":"2020-12-30T04:22:18","guid":{"rendered":"https:\/\/altscript.com\/?page_id=62"},"modified":"2022-08-09T11:27:08","modified_gmt":"2022-08-09T18:27:08","slug":"ason-source-format","status":"publish","type":"page","link":"https:\/\/altscript.com\/?page_id=62","title":{"rendered":"ASON Source Format"},"content":{"rendered":"\n<p><strong>ASON is the AltScript Object Notation<\/strong>. It is the source format used for both data and code.<\/p>\n\n\n\n<p>ASON consists of <strong><em>blocks<\/em><\/strong> that hold <strong><em>values<\/em><\/strong> and <strong><em>words<\/em><\/strong>.<\/p>\n\n\n\n<h2>Blocks<\/h2>\n\n\n\n<p>There are two types of blocks: array blocks and object blocks.<\/p>\n\n\n\n<h3>Array Blocks<\/h3>\n\n\n\n<p><strong>Array blocks<\/strong> are free-form containers. Use them for arrays, lists, queues, stacks, and even code. They are denoted by square brackets [ ] and hold a sequence of values, words, or other blocks. Notice there are no commas.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91; 1 2 3 4 5 ]\n&#91; \"A\" \"B\" \"C\" ]\n&#91; 123 4.56 $78.90 ]\n&#91; Mr \"John\" \"Smith\" 1990-12-1 john@jsmith.org ]\n&#91;\n  \"Reno\" NV\n  \"Eureka\" CA\n  \"Boston\" MA\n  \"Miami\" FL\n]\n&#91; &lt;p&gt; 2020-6-18\/12:43:50 &lt;\/p&gt; ]\n&#91; if time &gt; 10:30 &#91; turn-off back-light ]]\n&#91; at &#91; 10:22 15:30 ] activate &#91; front side back ]]\n&#91; TCP address 138.197.200.83 for http:\/\/altscript.com ]<\/code><\/pre>\n\n\n\n<p>So, what are the unquoted words above? They are <strong><em>symbols<\/em><\/strong>. They boost the expressive power of ASON considerably. More on this below.<\/p>\n\n\n\n<p class=\"has-vivid-red-color has-text-color\"><strong><em>Important Rule:<\/em><\/strong> <strong>Use white-space not commas to separate values.<\/strong> Commas provide no added benefit, and they prevent blocks from being used for code.<\/p>\n\n\n\n<h3>Object Blocks<\/h3>\n\n\n\n<p><strong>Object blocks<\/strong> hold key-value pairs.  They are denoted by rounded braces { } and hold words (as keys) followed by values or blocks.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{ name: \"John Smith\" age: 27 }\n{ site: \"Altscript\" url: http:\/\/altscript.com }\n{ directions: &#91; up down left right ] }\n{\n    first-name:  \"John\"\n    last-name:   \"Smith\"\n    birth-date:  1990-7-4\n    clock-color: 255.80.30\n    wake-time:   &#91; 7:44 weekdays 9:00 weekends ]\n    services:    &#91; http:\/\/spotify.com http:\/\/pandora.com ]\n    song-id:     #\"C23A9F87D457\"\n}<\/code><\/pre>\n\n\n\n<p>Special rules apply if the value part on the right contains multiple values. This is still an association block but may require special <em>interpretation as code<\/em>. That will be covered in the AltScript document, but here&#8217;s an example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    start-time: 10:30\n    stop-time: start-time + 3:00\n}<\/code><\/pre>\n\n\n\n<h3>Expression blocks<\/h3>\n\n\n\n<p><strong>Expression blocks<\/strong> are containers just like array blocks except they are used for grouping values and words into evaluated expressions. They are denoted by parentheses ().<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>( 123 + 456 )\n( 10:30 - 3:00 )\n( 2021-2-1 - 365 )\n( 1.20.00 + 0.0.1 )\n( length? first-name )\n( \"Bob\" + \" \" + \"Smith\" )\n((degrees - 32) \/ 9) * 5\n&#91; (123 + 456) (10.7 + 8.95) ]<\/code><\/pre>\n\n\n\n<p>More about evaluation is covered in the AltScript document.<\/p>\n\n\n\n<h2>Values<\/h2>\n\n\n\n<p>A wide variety of values are recognized directly in source format. You&#8217;ve seen some of them in the above examples. Notice that they are written in a simple, obvious way. <em>No special constructors are needed.<\/em><\/p>\n\n\n\n<h3>Numerical Values<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>123      - integer\n1.23     - decimal floating point\n1,23     - decimal alternate format (European)\n$1.23    - high precision decimal for currency\n1.2.3    - tuple for versions, colors, IP addresses\n1..20    - range for indexes\n12x340   - pair for X\/Y coordinates\n#1A2B    - hexadecimal integer<\/code><\/pre>\n\n\n\n<h3>Dates and Times<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>2021-4-5  - date (year, month, day)\n10:23:45  - time (hours, minutes, seconds)\n2021-4-5-10:23:45 - date and time\n2021-4-5-10:23:45-8:00 - date, time, plus timezone<\/code><\/pre>\n\n\n\n<h3>Strings and Binary<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\"abc\"    - string\n''abc''  - long strings (spans many lines or other strings)\n&lt;abc&gt;    - hypertext tag\n%abc     - file, directory, or path\nabc:\/\/   - URL\/URI\nab@cde   - email address\n#\"a1b2c\" - binary base-16 format (hexadecimal)\n##\"atbfc\"- binary base-64 format<\/code><\/pre>\n\n\n\n<h2>Words<\/h2>\n\n\n\n<p>As seen above, words can be used as symbols. They are not the same as quoted strings. They represent a unique symbolic value and can be used symbolically, representing just themselves, or they can be used as variables that hold values. They provide substantial expressive power in ASON.<\/p>\n\n\n\n<p>Words begin with a letter, followed by other letters, numbers, or special characters. There is no distinction between upper and lower case letters. It&#8217;s case insensitive.<\/p>\n\n\n\n<p>In the above examples you saw these word formats being used:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>abc  - a word, used as variable in code or symbol in data\nabc: - define word or key (called a \"set-word\")<\/code><\/pre>\n\n\n\n<p>In addition, AltScript programs make use of other forms of words:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:abc - get variable value, unevaluated (get-word)\n'abc - refer to word as a value (symbol reference)\n.abc - selector for contexts, objects, functions, modules\n\/abc - refinement for paths and functions\n@abc - literal values like @true, @false, @none, @string, @nan<\/code><\/pre>\n\n\n\n<p>Also, certain types of compound words are supported:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>abc.def  - field selection\nabc.def: - set a field variable\n:abc.def - get a field variable, unevaluated\nabc\/def  - file path or function refinement<\/code><\/pre>\n\n\n\n<p>The details of words will be explained in detail in the AltScript section.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ASON is the AltScript Object Notation. It is the source format used for both data and code. ASON consists of blocks that hold values and words. Blocks There are two types of blocks: array blocks and object blocks. Array Blocks Array blocks are free-form containers. Use them for arrays, lists, queues, stacks, and even code. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/altscript.com\/index.php?rest_route=\/wp\/v2\/pages\/62"}],"collection":[{"href":"https:\/\/altscript.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/altscript.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/altscript.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/altscript.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=62"}],"version-history":[{"count":13,"href":"https:\/\/altscript.com\/index.php?rest_route=\/wp\/v2\/pages\/62\/revisions"}],"predecessor-version":[{"id":196,"href":"https:\/\/altscript.com\/index.php?rest_route=\/wp\/v2\/pages\/62\/revisions\/196"}],"wp:attachment":[{"href":"https:\/\/altscript.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}