all repos — min @ 7adba219eb272fce58000acec484266d6f95d4b7

A small but practical concatenative programming language.

Modified expect behavior.
h3rald h3rald@h3rald.com
Fri, 21 Jul 2017 22:24:26 +0200
commit

7adba219eb272fce58000acec484266d6f95d4b7

parent

3babdef752debb327486d11a262b42966cb52a20

4 files changed, 36 insertions(+), 50 deletions(-)

jump to
M lib/min_lang.nimlib/min_lang.nim

@@ -3,6 +3,7 @@ critbits,

strutils, sequtils, parseopt2, + algorithm, json, os, logging

@@ -544,7 +545,7 @@

def.symbol("expect") do (i: In): var q: MinValue i.reqQuotationOfSymbols q - i.push(i.expect(q.qVal.mapIt(it.getString())).newVal(i.scope)) + i.push(i.expect(q.qVal.mapIt(it.getString()).reversed).newVal(i.scope)) # Converters
M site/contents/_includes/_reference-lang.mdsite/contents/_includes/_reference-lang.md

@@ -97,17 +97,17 @@ {#op||exit||{{i}}||{{null}}||

Exits the program or shell with {{i}} as return code. #} {#op||expect||{{q1}}||{{q2}}|| -> Validates the first _n_ elements of the stack against the type descriptions specified in {{q1}} (_n_ is {{q1}}'s length) and if all the elements are valid returns them wrapped in {{q2}}. +> Validates the first _n_ elements of the stack against the type descriptions specified in {{q1}} (_n_ is {{q1}}'s length) and if all the elements are valid returns them wrapped in {{q2}} (in reverse order). > > %sidebar% > > Example > > -> > Assuming that the following elements are on the stack (from top to bottom): `1 "test" 3.4` +> > Assuming that the following elements are on the stack (from top to bottom): > > -> > the following: +> > `1 "test" 3.4` > > -> > `(int string num) expect` +> > the following program evaluates to `true`: > > -> > produces: `(1 "test" 3.4)`#} +> > `(int string num) expect (3.4 "test" 1) ==` {#op||float||{{any}}||{{flt}}|| > Converts {{any}} to an integer value based on the following rules:
M site/rules.minsite/rules.min

@@ -2,56 +2,50 @@ 'hastysite import

;Routing ( - =meta + (dict) expect -> =meta meta /id :id meta /ext :ext ( ((id "home" ==) ( - meta "index" %id #meta - meta ".html" %ext #meta + meta ( + ("index" %id) + (".html" %ext) + ) tap )) ((ext ".md" ==) ( - meta ".html" %ext #meta - meta "$1/index" (id) => % %id #meta + meta ( + (".html" %ext) + ("$1/index" (id) => % %id) + ) tap )) ) case - meta ) :set-destination ;Processing operators ( - :tpl - =meta - meta /path :path - " - Processing $1: $2" (tpl path) => % notice - meta input-fread :contents - meta settings /title %site #meta - meta settings /version %version #meta - contents meta markdown @contents - meta contents %contents #meta - tpl meta mustache :page - meta page %contents #meta - meta + ('sym dict) expect -> :tpl =meta + "" :page + "" :contents + " - Processing $1: $2" (tpl (meta /path)) => % notice + meta ( + (input-fread @contents meta) + (settings /title %site) + (settings /version %version) + (=temp contents temp markdown @contents temp) + (contents %contents) + (=temp tpl temp mustache @page temp) + (page %contents) + ) tap ) :process-md-with-template ( - =meta + (dict) expect -> =meta meta /content-type :ct meta ct process-md-with-template ) :process-md-content ( - =meta - meta /path :path - " - Processing stylesheet: $1" (path) => % notice - meta input-fread :contents - contents preprocess-css @contents - meta contents %contents #meta - meta -) :preprocess-css-content - -( - =meta + (dict) expect -> =meta meta /ext :ext meta (

@@ -60,23 +54,12 @@ ) case

) :process-content ;Main -assets ( - =meta - meta /ext :ext - meta - ( - ((".css" ext ==) ( - preprocess-css-content - output-fwrite - )) - ((true) (copy2output)) - ) case -) foreach - contents ( + (dict) expect -> dup ( ((/id "^_includes" match) ()) ;Ignore files starting with underscore. ((true) (process-content set-destination output-fwrite)) ) case -) foreach+) foreach +assets (copy2output) foreach
M tests/lang.mintests/lang.min

@@ -192,6 +192,8 @@ ) tap!

s1 "test123" == ) assert + (1 "test" 3.4 (int string num) expect (3.4 "test" 1) ==) assert + report ; Tidy up clear-stack