all repos — min @ 34de6c3dd6ebd34a80fe90dba143c2cf69706515

A small but practical concatenative programming language.

Added support for sharpbang.
* Closes #4.
h3rald h3rald@h3rald.com
Fri, 27 Oct 2017 20:52:29 +0200
commit

34de6c3dd6ebd34a80fe90dba143c2cf69706515

parent

524121b82fbcdfc2ec50e00ffbb5d11692763978

3 files changed, 16 insertions(+), 4 deletions(-)

jump to
M min.nimmin.nim

@@ -149,11 +149,19 @@ proc minString*(buffer: string) =

minStream(newStringStream(buffer), "input") proc minFile*(filename: string) = - var stream = newFileStream(filename, fmRead) - if stream == nil: + var fileLines = newSeq[string](0) + var contents = "" + try: + fileLines = filename.readFile().splitLines() + except: fatal("Cannot read from file: "& filename) quit(3) - minStream(stream, filename) + + if fileLines[0].len >= 2 and fileLines[0][0..1] == "#!": + contents = fileLines[1..fileLines.len-1].join("\n") + else: + contents = fileLines.join("\n") + minStream(newStringStream(contents), filename) proc minFile*(file: File, filename="stdin") = var stream = newFileStream(stdin)
M min.vimmin.vim

@@ -34,6 +34,7 @@ syntax match minSymbol ;[a-zA-Z._][a-zA-Z0-9/!?+*._-]*;

syntax match minParen ;(\|); +syntax match minSharpBang /\%^#!.*/ " Highlighting

@@ -53,5 +54,6 @@ hi default link minQuotedSymbol Special

hi default link minBoundSymbol Special hi default link minQuotedBoundSymbol Special hi default link minParen Special +hi default link minSharpBang Preproc let b:current_syntax = "min"
M tests/all.mintests/all.min

@@ -1,3 +1,5 @@

+#!/usr/bin/env min + ; Load test files 0 :failures symbols size :total-symbols

@@ -19,4 +21,4 @@ 'fs load

'crypto load "=" 70 repeat puts! "Total Failures: $1" (failures) => % puts! -failures exit+failures exit