Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@buggyorg/lisgy

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@buggyorg/lisgy

create simple buggy graphs from lisp code

latest
npmnpm
Version
0.1.8
Version published
Maintainers
1
Created
Source

lisgy

create simple buggy graphs from lisp code

(defco newCoName [inputA inputB] 
  {:output1 (math/less inputA inputB) 
   :output2 (math/add inputA inputB)})

TODO

  • Anonymous functions #(...)
  • Better error handling with lines for components/edn objects

DONE

  • set a specific input port e.g. (FN :portB (exprs1) :portA (exprs2))
  • get a specific output port with (port :outputPort node)
  • let
  • support for new components with just one default output port
  • if same as logic/mux -> (defco if [check truePath falsePath] (logic/mux truePath falsePath check))
  • (import ...) Include default mappings e.g. + to math/add
  • Extra node infos with {:var value}
  • syntax errors with lines

API

; new component with named output ports
(defco name [inputs*] [:output (exprs1) ...])

; new component with just one output port (default name 'value')
(defco name [inputs*] (exprs1))

; Anonymous functions 
(lambda [args] (...))
(fn [args] (...))

; Define
(def name value)
; Example: use + instead of math/add
(def + math/add)
(+ 2 3)

; Let
(let [var1 (exprs1) var2 (exprs2) ...]
     ... ; use new variables
         ; only the last exprs node is 'returned'
     )
; Example
(stdout
  (let [a 5
        txt "some text"
        tt "check true"
        ff "check false"
        check (< a 3)]
        (stdout txt)
        (if check tt ff)))


; Import
(import all) ; or math,logic,io,control,functional,array,translator
(+ 2 3)


; Set extra node infos, e.g. the name with {}
(+ 2 3 {:name add23})


; Intern
; Define the ports of a extern component
(defcop name [inputs*] [outputs*])




; TODO / NYI (Not yet implemented) !!!
; Anonymous functions 
#(...) ; with %n for the nth arg (1-based)

example code

(def add math/add) ; rename math/add to add
(defcop add [s1 s2] [sum]) ; define the input/output ports for add
(def mul math/multiply) ; rename math/multiply to mul
; lisgy will get the defcop for math/ multiply automatic

; define a new component 'add2' with a default output port 'value' and the input port 'a''
(defco add2 [a] (add a 2)) 
(defco sub [a b] (add a (mul b -1)))
(defco math 
  [a b] 
  [:add (add a b)
   :mul (mul a b)
   :sub (sub a b)
   :a2 (add2 a)
   :b2 (add2 b)])

(defco math2
  [a]
  (let [* mul
        a2 (* a 2)]
        (* a2 8)))

; full example
(defcop math/less [isLess than] [value])
(defcop math/add [s1 s2] [sum])
(def + math/add)
(def < math/less)

(defco test [a b] [:add (+ a b) 
                   :less (< a b) 
                   :fn (fn [c d] (< (+ a c) 
                                    (+ b d)))])

cli

  Usage: lisgy [options] [command]


  Commands:

    parse [lisp_code]

  Options:
  
    -h, --help             output usage information
    -V, --version          output the version number
    -e, --elastic <host>   The elastic server to connect to. Defaults to BUGGY_COMPONENT_LIBRARY_HOST=http://localhost:9200
    -n, --nice             Pretty print all JSON output
    -k, --kgraph           Print the graph in kgraph format
    -r, --resolve          Print the resolved json
    -v, --verbose [depth]  Print further information.
    --nocolor              Disable color output


installation

npm i @buggyorg/lisgy

alternativ via git

git clone https://github.com/BuggyOrg/lisgy.git
# global
cd lisgy
npm i -g
# or as alias
npm i
alias lisgy='PATH TO LISGY FOLDER/lib/cli.js'

examples

lisgy parse -n '(lambda (a b) (math/add a b))' > parsed.json

# with stdin
echo '(lambda (a b) (math/add a b))' | lisgy parse -n > parsed.json

# open an editor (default nano)
lisgy parse -n > parsed.json

# use a input file
lisgy parse code.lisp -n > parsed.json

FAQs

Package last updated on 11 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts